forked from openlp/openlp
Add documentation to tests
This commit is contained in:
parent
990a8a9502
commit
c7563a5a64
@ -43,3 +43,5 @@ __pycache__
|
|||||||
.coverage
|
.coverage
|
||||||
cover
|
cover
|
||||||
*.kdev4
|
*.kdev4
|
||||||
|
./.coveragerc
|
||||||
|
./coverage
|
||||||
|
@ -30,23 +30,40 @@ from openlp.plugins.songs.lib.importer import SongFormat
|
|||||||
class TestSongFormat(TestCase):
|
class TestSongFormat(TestCase):
|
||||||
|
|
||||||
def test_get_format_list(self):
|
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):
|
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():
|
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):
|
def test_get_attributed_single_attribute(self):
|
||||||
|
# GIVEN: A SongFormat
|
||||||
for song_format in SongFormat.get_format_list():
|
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():
|
for attribute in SongFormat.get(song_format).keys():
|
||||||
self.assertEquals(SongFormat.get(song_format, attribute),
|
# THEN: Return the attribute
|
||||||
SongFormat.get(song_format)[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():
|
for attribute in SongFormat.__defaults__.keys():
|
||||||
if attribute not in SongFormat.get(song_format).keys():
|
if attribute not in SongFormat.get(song_format).keys():
|
||||||
self.assertEquals(SongFormat.get(song_format, attribute),
|
# THEN: Return the default value
|
||||||
SongFormat.__defaults__[attribute])
|
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):
|
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():
|
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")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user