X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/ce8d791a5298e0cb2569034aec4c8b57afac97b2..b2c05060cee75fc1b6902e08c706ca369a37e1ab:/apps/dvcs/tests/__init__.py?ds=sidebyside 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') +