def test_build_song_footer_base_ccli(self): """ Test build songs footer with basic song and a CCLI number """ # GIVEN: A Song and a Service Item and a configured CCLI license mock_song = MagicMock() mock_song.title = 'My Song' mock_song.copyright = 'My copyright' service_item = ServiceItem(None) Settings().setValue('core/ccli number', '1234') # WHEN: I generate the Footer with default settings self.media_item.generate_footer(service_item, mock_song) # THEN: I get the following Array returned self.assertEqual(service_item.raw_footer, ['My Song', 'My copyright', 'CCLI License: 1234'], 'The array should be returned correctly with a song, an author, copyright and ccli') # WHEN: I amend the CCLI value Settings().setValue('core/ccli number', '4321') self.media_item.generate_footer(service_item, mock_song) # THEN: I would get an amended footer string self.assertEqual(service_item.raw_footer, ['My Song', 'My copyright', 'CCLI License: 4321'], 'The array should be returned correctly with a song, an author, copyright and amended ccli')
def test_build_song_footer_base_ccli(self): """ Test build songs footer with basic song and a CCLI number """ # GIVEN: A Song and a Service Item and a configured CCLI license mock_song = MagicMock() mock_song.title = 'My Song' mock_song.copyright = 'My copyright' service_item = ServiceItem(None) Settings().setValue('core/ccli number', '1234') # WHEN: I generate the Footer with default settings self.media_item.generate_footer(service_item, mock_song) # THEN: I get the following Array returned self.assertEqual(service_item.raw_footer, ['My Song', 'My copyright', 'CCLI License: 1234'], 'The array should be returned correctly with a song, an author, copyright and ccli') # WHEN: I amend the CCLI value Settings().setValue('core/ccli number', '4321') self.media_item.generate_footer(service_item, mock_song) # THEN: I would get an amended footer string self.assertEqual(service_item.raw_footer, ['My Song', 'My copyright', 'CCLI License: 4321'], 'The array should be returned correctly with a song, an author, copyright and amended ccli')
def test_build_song_footer_one_author_hide_written_by(self, MockedSettings): """ Test build songs footer with basic song and one author """ # GIVEN: A Song and a Service Item, mocked settings: False for 'songs/display written by' # and False for 'core/ccli number' (ccli will cause traceback if true) mocked_settings = MagicMock() mocked_settings.value.side_effect = [False, False] MockedSettings.return_value = mocked_settings mock_song = MagicMock() mock_song.title = 'My Song' mock_song.authors_songs = [] mock_author = MagicMock() mock_author.display_name = 'my author' mock_author_song = MagicMock() mock_author_song.author = mock_author mock_song.authors_songs.append(mock_author_song) mock_song.copyright = 'My copyright' service_item = ServiceItem(None) # WHEN: I generate the Footer with default settings author_list = self.media_item.generate_footer(service_item, mock_song) # THEN: I get the following Array returned self.assertEqual(service_item.raw_footer, ['My Song', 'my author', 'My copyright'], 'The array should be returned correctly with a song, one author and copyright,' 'text Written by should not be part of the text.') self.assertEqual(author_list, ['my author'], 'The author list should be returned correctly with one author')
def build_song_footer_base_songbook_test(self): """ Test build songs footer with basic song and a songbook """ # GIVEN: A Song and a Service Item mock_song = MagicMock() mock_song.title = 'My Song' mock_song.copyright = 'My copyright' mock_song.book = MagicMock() mock_song.book.name = "My songbook" mock_song.song_number = 12 service_item = ServiceItem(None) # WHEN: I generate the Footer with default settings self.media_item.generate_footer(service_item, mock_song) # THEN: The songbook should not be in the footer self.assertEqual(service_item.raw_footer, ['My Song', 'My copyright']) # WHEN: I activate the "display songbook" option self.media_item.display_songbook = True self.media_item.generate_footer(service_item, mock_song) # THEN: The songbook should be in the footer self.assertEqual(service_item.raw_footer, ['My Song', 'My copyright', 'My songbook #12'])
def test_build_song_footer_copyright_disabled(self): """ Test building song footer without displaying the copyright symbol """ # GIVEN: A Song and a Service Item; displaying the copyright symbol should be disabled by default mock_song = MagicMock() mock_song.title = 'My Song' mock_song.copyright = 'My copyright' service_item = ServiceItem(None) # WHEN: I generate the Footer with default settings self.media_item.generate_footer(service_item, mock_song) # THEN: The copyright symbol should not be in the footer self.assertEqual(service_item.raw_footer, ['My Song', 'My copyright'])
def test_build_song_footer_copyright_disabled(self): """ Test building song footer without displaying the copyright symbol """ # GIVEN: A Song and a Service Item; displaying the copyright symbol should be disabled by default mock_song = MagicMock() mock_song.title = 'My Song' mock_song.copyright = 'My copyright' service_item = ServiceItem(None) # WHEN: I generate the Footer with default settings self.media_item.generate_footer(service_item, mock_song) # THEN: The copyright symbol should not be in the footer self.assertEqual(service_item.raw_footer, ['My Song', 'My copyright'])
def test_build_song_footer_two_authors(self): """ Test build songs footer with basic song and two authors """ # GIVEN: A Song and a Service Item mock_song = MagicMock() mock_song.title = 'My Song' mock_song.authors_songs = [] mock_author = MagicMock() mock_author.display_name = 'my author' mock_author_song = MagicMock() mock_author_song.author = mock_author mock_author_song.author_type = AuthorType.Music mock_song.authors_songs.append(mock_author_song) mock_author = MagicMock() mock_author.display_name = 'another author' mock_author_song = MagicMock() mock_author_song.author = mock_author mock_author_song.author_type = AuthorType.Words mock_song.authors_songs.append(mock_author_song) mock_author = MagicMock() mock_author.display_name = 'translator' mock_author_song = MagicMock() mock_author_song.author = mock_author mock_author_song.author_type = AuthorType.Translation mock_song.authors_songs.append(mock_author_song) mock_song.copyright = 'My copyright' service_item = ServiceItem(None) # WHEN: I generate the Footer with default settings author_list = self.media_item.generate_footer(service_item, mock_song) # THEN: I get the following Array returned self.assertEqual(service_item.raw_footer, ['My Song', 'Words: another author', 'Music: my author', 'Translation: translator', 'My copyright'], 'The array should be returned correctly with a song, two authors and copyright') self.assertEqual(author_list, ['another author', 'my author', 'translator'], 'The author list should be returned correctly with two authors')
def test_build_song_footer_two_authors(self): """ Test build songs footer with basic song and two authors """ # GIVEN: A Song and a Service Item mock_song = MagicMock() mock_song.title = 'My Song' mock_song.authors_songs = [] mock_author = MagicMock() mock_author.display_name = 'my author' mock_author_song = MagicMock() mock_author_song.author = mock_author mock_author_song.author_type = AuthorType.Music mock_song.authors_songs.append(mock_author_song) mock_author = MagicMock() mock_author.display_name = 'another author' mock_author_song = MagicMock() mock_author_song.author = mock_author mock_author_song.author_type = AuthorType.Words mock_song.authors_songs.append(mock_author_song) mock_author = MagicMock() mock_author.display_name = 'translator' mock_author_song = MagicMock() mock_author_song.author = mock_author mock_author_song.author_type = AuthorType.Translation mock_song.authors_songs.append(mock_author_song) mock_song.copyright = 'My copyright' service_item = ServiceItem(None) # WHEN: I generate the Footer with default settings author_list = self.media_item.generate_footer(service_item, mock_song) # THEN: I get the following Array returned self.assertEqual(service_item.raw_footer, ['My Song', 'Words: another author', 'Music: my author', 'Translation: translator', 'My copyright'], 'The array should be returned correctly with a song, two authors and copyright') self.assertEqual(author_list, ['another author', 'my author', 'translator'], 'The author list should be returned correctly with two authors')
def test_build_song_footer_one_author(self): """ Test build songs footer with basic song and one author """ # GIVEN: A Song and a Service Item mock_song = MagicMock() mock_song.title = 'My Song' mock_song.authors_songs = [] mock_author = MagicMock() mock_author.display_name = 'my author' mock_author_song = MagicMock() mock_author_song.author = mock_author mock_song.authors_songs.append(mock_author_song) mock_song.copyright = 'My copyright' service_item = ServiceItem(None) # WHEN: I generate the Footer with default settings author_list = self.media_item.generate_footer(service_item, mock_song) # THEN: I get the following Array returned self.assertEqual(service_item.raw_footer, ['My Song', 'Written by: my author', 'My copyright'], 'The array should be returned correctly with a song, one author and copyright') self.assertEqual(author_list, ['my author'], 'The author list should be returned correctly with one author')
def build_song_footer_one_author_test(self): """ Test build songs footer with basic song and one author """ # GIVEN: A Song and a Service Item mock_song = MagicMock() mock_song.title = 'My Song' mock_song.authors_songs = [] mock_author = MagicMock() mock_author.display_name = 'my author' mock_author_song = MagicMock() mock_author_song.author = mock_author mock_song.authors_songs.append(mock_author_song) mock_song.copyright = 'My copyright' service_item = ServiceItem(None) # WHEN: I generate the Footer with default settings author_list = self.media_item.generate_footer(service_item, mock_song) # THEN: I get the following Array returned self.assertEqual(service_item.raw_footer, ['My Song', 'Written by: my author', 'My copyright'], 'The array should be returned correctly with a song, one author and copyright') self.assertEqual(author_list, ['my author'], 'The author list should be returned correctly with one author')