X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/6a259b96cff47e1fd64cbfd6f3d1e1d8e8b6486c..d05a1d784f2f0dbad6839c672cae8226d1b0fa9d:/apps/dvcs/tests/__init__.py?ds=inline diff --git a/apps/dvcs/tests/__init__.py b/apps/dvcs/tests/__init__.py index de77d991..868f00a3 100755 --- a/apps/dvcs/tests/__init__.py +++ b/apps/dvcs/tests/__init__.py @@ -4,7 +4,8 @@ from dvcs.models import Document class ADocument(Document): - pass + class Meta: + app_label = 'dvcs' class DocumentModelTests(TestCase): @@ -156,3 +157,22 @@ class DocumentModelTests(TestCase): c3 = doc.commit(description="Commit B1", text=text_b1, parent=c1) c4 = doc.commit(description="Commit C1", text=text_c1, parent=c1) self.assertTextEqual(doc.materialize(), text_merged) + + + def test_prepend_history(self): + doc1 = ADocument.objects.create() + doc2 = ADocument.objects.create() + doc1.commit(text='Commit 1') + doc2.commit(text='Commit 2') + doc2.prepend_history(doc1) + self.assertEqual(ADocument.objects.all().count(), 1) + self.assertTextEqual(doc2.at_revision(1).materialize(), 'Commit 1') + self.assertTextEqual(doc2.materialize(), 'Commit 2') + + def test_prepend_to_self(self): + doc = ADocument.objects.create() + doc.commit(text='Commit 1') + with self.assertRaises(AssertionError): + doc.prepend_history(doc) + self.assertTextEqual(doc.materialize(), 'Commit 1') +