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


Python Book.from_text_and_meta方法代码示例

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


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

示例1: test_simple_import

# 需要导入模块: from catalogue.models import Book [as 别名]
# 或者: from catalogue.models.Book import from_text_and_meta [as 别名]
    def test_simple_import(self, parent_cover_changed):
        child = Book.from_text_and_meta(ContentFile(self.TEXT), self.child)
        parent = Book.from_text_and_meta(ContentFile(self.TEXT), self.parent)
        parent_cover_changed.assert_called_with(child)

        # Now reimport parent.
        parent_cover_changed.reset_mock()
        parent = Book.from_text_and_meta(ContentFile(self.TEXT), self.parent, overwrite=True)
        self.assertEqual(parent_cover_changed.call_count, 0)

        # Now change cover in parent.
        parent_cover_changed.reset_mock()
        self.parent.cover_url = "http://example.com/other-cover.jpg"
        parent = Book.from_text_and_meta(ContentFile(self.TEXT), self.parent, overwrite=True)
        parent_cover_changed.assert_called_with(child)
开发者ID:fnp,项目名称:wolnelektury,代码行数:17,代码来源:test_cover.py

示例2: test_new_child

# 需要导入模块: from catalogue.models import Book [as 别名]
# 或者: from catalogue.models.Book import from_text_and_meta [as 别名]
    def test_new_child(self, parent_cover_changed):
        # Add parent without child first.
        parts, self.parent.parts = self.parent.parts, []
        parent = Book.from_text_and_meta(ContentFile(self.TEXT), self.parent)

        # Now import child and reimport parent.
        child = Book.from_text_and_meta(ContentFile(self.TEXT), self.child)
        self.parent.parts = parts
        parent = Book.from_text_and_meta(ContentFile(self.TEXT), self.parent, overwrite=True)
        parent_cover_changed.assert_called_with(child)

        # Now remove the child.
        parent_cover_changed.reset_mock()
        self.parent.parts = []
        parent = Book.from_text_and_meta(ContentFile(self.TEXT), self.parent, overwrite=True)
        parent_cover_changed.assert_called_with(child)
开发者ID:fnp,项目名称:wolnelektury,代码行数:18,代码来源:test_cover.py

示例3: test_book_with_footnote

# 需要导入模块: from catalogue.models import Book [as 别名]
# 或者: from catalogue.models.Book import from_text_and_meta [as 别名]
    def test_book_with_footnote(self):
        book_text = """<utwor>
        <opowiadanie>
            <akap><pe><slowo_obce>rose</slowo_obce> --- kind of a flower.</pe></akap>
            <akap><pe><slowo_obce>rose</slowo_obce> --- kind of a flower.</pe></akap>
            <akap><pe><slowo_obce>rose</slowo_obce> (techn.) --- #FF007F.</pe></akap>
        </opowiadanie></utwor>
        """

        book = Book.from_text_and_meta(ContentFile(book_text), self.book_info)

        self.assertEqual(
            len(self.client.get('/przypisy/').context['object_list']),
            2,
            'There should be two notes on the note list.')

        self.assertEqual(
            len(self.client.get('/przypisy/?ltr=a').context['object_list']),
            0,
            'There should not be a note for the letter A.')

        self.assertEqual(
            len(self.client.get('/przypisy/?ltr=r').context['object_list']),
            2,
            'Both notes start with the letter R.')

        self.assertEqual(
            len(self.client.get('/przypisy/?qual=techn.').context['object_list']),
            1,
            'There should be a note qualified with \'techn.\' qualifier.')
开发者ID:fnp,项目名称:wolnelektury,代码行数:32,代码来源:tests.py

示例4: test_book_with_footnote

# 需要导入模块: from catalogue.models import Book [as 别名]
# 或者: from catalogue.models.Book import from_text_and_meta [as 别名]
    def test_book_with_footnote(self):
        BOOK_TEXT = """<utwor>
        <opowiadanie>
            <akap><pe><slowo_obce>rose</slowo_obce> --- kind of a flower.</pe></akap>
        </opowiadanie></utwor>
        """

        book = Book.from_text_and_meta(ContentFile(BOOK_TEXT), self.book_info)

        self.assertEqual(
            len(self.client.get('/przypisy/').context['object_list']),
            1,
            'There should be a note on the note list.')

        self.assertEqual(
            len(self.client.get('/przypisy/a/').context['object_list']),
            0,
            'There should not be a note for the letter A.')

        self.assertEqual(
            len(self.client.get('/przypisy/r/').context['object_list']),
            1,
            'There should be a note for the letter R.')
开发者ID:jumasheff,项目名称:wolnelektury,代码行数:25,代码来源:tests.py

示例5: test_change_cover

# 需要导入模块: from catalogue.models import Book [as 别名]
# 或者: from catalogue.models.Book import from_text_and_meta [as 别名]
 def test_change_cover(self, parent_cover_changed):
     child = Book.from_text_and_meta(ContentFile(self.TEXT), self.child)
     parent = Book.from_text_and_meta(ContentFile(self.TEXT), self.parent)
     parent_cover_changed.assert_called_with(child)
开发者ID:fnp,项目名称:wolnelektury,代码行数:6,代码来源:test_cover.py


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