+ parts=[self.book_info.url],
+ **info_args("Parent")
+ )
+ self.PARENT_TEXT = """<utwor />"""
+ self.parent = models.Book.from_text_and_meta(
+ ContentFile(self.PARENT_TEXT), self.parent_info)
+
+ def test_ok(self):
+ self.assertEqual(
+ list(self.client.get('/katalog/gatunek/x-genre/'
+ ).context['object_list']),
+ [self.parent],
+ u"There should be only parent on common tag page."
+ )
+ pies = models.Tag.objects.get(slug='pies')
+ self.assertEqual(self.parent.theme_counter, {pies.pk: 1},
+ u"There should be child theme in parent theme counter."
+ )
+ epoch = models.Tag.objects.get(slug='x-epoch')
+ self.assertEqual(epoch.book_count, 1,
+ u"There should be only parent in common tag's counter."
+ )
+
+ def test_child_republish(self):
+ CHILD_TEXT = """<utwor>
+ <opowiadanie>
+ <akap><begin id="m01" /><motyw id="m01">Pies, Kot</motyw>
+ Ala ma kota<end id="m01" /></akap>
+ </opowiadanie></utwor>
+ """
+ models.Book.from_text_and_meta(
+ ContentFile(CHILD_TEXT), self.child_info, overwrite=True)
+ self.assertEqual(
+ list(self.client.get('/katalog/gatunek/x-genre/'
+ ).context['object_list']),
+ [self.parent],
+ u"There should only be parent on common tag page."
+ )
+ pies = models.Tag.objects.get(slug='pies')
+ kot = models.Tag.objects.get(slug='kot')
+ self.assertEqual(self.parent.theme_counter, {pies.pk: 1, kot.pk: 1},
+ u"There should be child themes in parent theme counter."
+ )
+ epoch = models.Tag.objects.get(slug='x-epoch')
+ self.assertEqual(epoch.book_count, 1,
+ u"There should only be parent in common tag's counter."
+ )
+
+ def test_book_change_child(self):
+ second_child_info = BookInfoStub(
+ genre='X-Genre',
+ epoch='X-Epoch',
+ kind='Other-Kind',
+ author=PersonStub(("Joe",), "Doe"),
+ **info_args("Second Child")