本文整理汇总了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)
示例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)
示例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.')
示例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.')
示例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)