X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/0d2710238c43e233ec76d8afa609704777807f42..bbc5bd6a7c8280758a2388ebffec26e0afc35d00:/apps/catalogue/tests/__init__.py diff --git a/apps/catalogue/tests/__init__.py b/apps/catalogue/tests/__init__.py index 9d0f36f8..600dbd20 100755 --- a/apps/catalogue/tests/__init__.py +++ b/apps/catalogue/tests/__init__.py @@ -57,3 +57,28 @@ class ManipulationTests(TestCase): self.book1.append(Book.objects.get(pk=self.book1.pk)) self.assertEqual(Book.objects.all().count(), 2) self.assertEqual(len(self.book1), 1) + + def test_prepend_history(self): + self.book1.prepend_history(self.book2) + self.assertEqual(Book.objects.all().count(), 1) + self.assertEqual(len(self.book1), 1) + self.assertEqual(self.book1.materialize(), 'book 1') + + def test_prepend_history_to_self(self): + with self.assertRaises(AssertionError): + self.book1.prepend_history(self.book1) + self.assertEqual(Book.objects.all().count(), 2) + self.assertEqual(self.book1.materialize(), 'book 1') + self.assertEqual(self.book2.materialize(), 'book 2') + + def test_split_book(self): + self.book1.chunk_set.create(number=2, title='Second chunk', + slug='book3') + self.book1[1].commit('I survived!') + self.assertEqual(len(self.book1), 2) + self.book1.split() + self.assertEqual(set([b.slug for b in Book.objects.all()]), + set(['book2', '1', 'book3'])) + self.assertEqual( + Book.objects.get(slug='book3').materialize(), + 'I survived!')