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


Python MagicMock.num_chapters方法代码示例

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


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

示例1: test_simple_import

# 需要导入模块: from tests.functional import MagicMock [as 别名]
# 或者: from tests.functional.MagicMock import num_chapters [as 别名]
    def test_simple_import(self, mocked_pysword_modules, mocked_application):
        """
        Test that a simple SWORD import works
        """
        # GIVEN: Test files with a mocked out "manager", "import_wizard", and mocked functions
        #       get_book_ref_id_by_name, create_verse, create_book, session and get_language.
        #       Also mocked pysword structures
        mocked_manager = MagicMock()
        mocked_import_wizard = MagicMock()
        importer = SwordBible(mocked_manager, path='.', name='.', filename='', sword_key='', sword_path='')
        result_file = open(os.path.join(TEST_PATH, 'dk1933.json'), 'rb')
        test_data = json.loads(result_file.read().decode())
        importer.wizard = mocked_import_wizard
        importer.get_book_ref_id_by_name = MagicMock()
        importer.create_verse = MagicMock()
        importer.create_book = MagicMock()
        importer.session = MagicMock()
        importer.get_language = MagicMock(return_value='Danish')
        mocked_bible = MagicMock()
        mocked_genesis = MagicMock()
        mocked_genesis.name = 'Genesis'
        mocked_genesis.num_chapters = 1
        books = {'ot': [mocked_genesis]}
        mocked_structure = MagicMock()
        mocked_structure.get_books.return_value = books
        mocked_bible.get_structure.return_value = mocked_structure
        mocked_bible.get_iter.return_value = [verse[1] for verse in test_data['verses']]
        mocked_module = MagicMock()
        mocked_module.get_bible_from_module.return_value = mocked_bible
        mocked_pysword_modules.SwordModules.return_value = mocked_module

        # WHEN: Importing bible file
        importer.do_import()

        # THEN: The create_verse() method should have been called with each verse in the file.
        self.assertTrue(importer.create_verse.called)
        for verse_tag, verse_text in test_data['verses']:
            importer.create_verse.assert_any_call(importer.create_book().id, 1, int(verse_tag), verse_text)
开发者ID:imkernel,项目名称:openlp,代码行数:40,代码来源:test_swordimport.py


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