From c7563a5a6409a90634fafd555e2b3be99d866085 Mon Sep 17 00:00:00 2001 From: Simon Hanna Date: Sun, 3 Jan 2016 00:37:22 +0100 Subject: [PATCH] Add documentation to tests --- .bzrignore | 2 ++ .../openlp_plugins/songs/test_songformat.py | 31 ++++++++++++++----- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/.bzrignore b/.bzrignore index 272c37e88..2e2e4891f 100644 --- a/.bzrignore +++ b/.bzrignore @@ -43,3 +43,5 @@ __pycache__ .coverage cover *.kdev4 +./.coveragerc +./coverage diff --git a/tests/functional/openlp_plugins/songs/test_songformat.py b/tests/functional/openlp_plugins/songs/test_songformat.py index bcfbfe2a5..be4216ef5 100644 --- a/tests/functional/openlp_plugins/songs/test_songformat.py +++ b/tests/functional/openlp_plugins/songs/test_songformat.py @@ -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")