当前位置: 首页>>代码示例>>Python>>正文


Python MagicMock.author方法代码示例

本文整理汇总了Python中tests.functional.MagicMock.author方法的典型用法代码示例。如果您正苦于以下问题:Python MagicMock.author方法的具体用法?Python MagicMock.author怎么用?Python MagicMock.author使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tests.functional.MagicMock的用法示例。


在下文中一共展示了MagicMock.author方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_build_song_footer_one_author_hide_written_by

# 需要导入模块: from tests.functional import MagicMock [as 别名]
# 或者: from tests.functional.MagicMock import author [as 别名]
    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')
开发者ID:imkernel,项目名称:openlp,代码行数:33,代码来源:test_mediaitem.py

示例2: test_build_song_footer_two_authors

# 需要导入模块: from tests.functional import MagicMock [as 别名]
# 或者: from tests.functional.MagicMock import author [as 别名]
    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')
开发者ID:imkernel,项目名称:openlp,代码行数:40,代码来源:test_mediaitem.py

示例3: build_song_footer_one_author_test

# 需要导入模块: from tests.functional import MagicMock [as 别名]
# 或者: from tests.functional.MagicMock import author [as 别名]
    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')
开发者ID:crossroadchurch,项目名称:paul,代码行数:26,代码来源:test_mediaitem.py


注:本文中的tests.functional.MagicMock.author方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。