Add documentation to tests

This commit is contained in:
Simon Hanna 2016-01-03 00:37:22 +01:00
parent 990a8a9502
commit c7563a5a64
2 changed files with 26 additions and 7 deletions

View File

@ -43,3 +43,5 @@ __pycache__
.coverage
cover
*.kdev4
./.coveragerc
./coverage

View File

@ -30,23 +30,40 @@ from openlp.plugins.songs.lib.importer import SongFormat
class TestSongFormat(TestCase):
def test_get_format_list(self):
self.assertEquals(len(SongFormat.get_format_list()), len(SongFormat.__attributes__))
# GIVEN: The SongFormat class
# WHEN: Retrieving the format list
# THEN: All SongFormats should be returned
self.assertEquals(len(SongFormat.get_format_list()), len(SongFormat.__attributes__),
"The returned SongFormats don't match the stored ones")
def test_get_attributed_no_attributes(self):
# GIVEN: A SongFormat
# WHEN: Retrieving all attributes of a SongFormat
for song_format in SongFormat.get_format_list():
self.assertEquals(SongFormat.__attributes__[song_format], SongFormat.get(song_format))
# THEN: All attributes associated with the SongFormat should be returned
self.assertEquals(SongFormat.get(song_format), SongFormat.__attributes__[song_format],
"The returned attributes don't match the stored ones")
def test_get_attributed_single_attribute(self):
# GIVEN: A SongFormat
for song_format in SongFormat.get_format_list():
# WHEN: Retrieving an attribute that overrides the default values
for attribute in SongFormat.get(song_format).keys():
self.assertEquals(SongFormat.get(song_format, attribute),
SongFormat.get(song_format)[attribute])
# THEN: Return the attribute
self.assertEquals(SongFormat.get(song_format, attribute), SongFormat.get(song_format)[attribute],
"The returned attribute doesn't match the stored one")
# WHEN: Retrieving an attribute that was not overridden
for attribute in SongFormat.__defaults__.keys():
if attribute not in SongFormat.get(song_format).keys():
self.assertEquals(SongFormat.get(song_format, attribute),
SongFormat.__defaults__[attribute])
# THEN: Return the default value
self.assertEquals(SongFormat.get(song_format, attribute), SongFormat.__defaults__[attribute],
"The returned attribute does not match the default values stored")
def test_get_attributed_multiple_attributes(self):
# GIVEN: A SongFormat
# WHEN: Retrieving multiple attributes at the same time
for song_format in SongFormat.get_format_list():
self.assertEquals(2, len(SongFormat.get(song_format, 'canDisable', 'availability')))
# THEN: Return all attributes that were specified
self.assertEquals(len(SongFormat.get(song_format, 'canDisable', 'availability')), 2,
"Did not return the correct number of attributes when retrieving multiple attributes at once")