Commits

Vladimir Mihailenco committed 2d4a4e9

Fix tests

Comments (0)

Files changed (1)

         for parent in Parent.objects.all():
             print 'parent.id', parent.id
 
-        for mti in Mti.objects.only('id', 'bar'):
-            parent = Parent.objects.get(id=mti.id)
+        for mti in Mti.objects.only('bar'):
+            parent = Parent.objects.get(id=mti.parent_ptr_id)
+            self.assertEqual(parent.foo, mti.bar + 2)
 
-            print mti.id
-            print mti.pk
-            print mti.parent_ptr_id
-            print mti._meta.pk.attname
-            #parent = mti.parent_ptr
-            #self.assertEqual(mti.bar, parent.foo - 2)
-        self.fail()
+            parent = mti.parent_ptr
+            self.assertEqual(parent.foo, mti.bar + 2)
 
     def test_mti_with_params(self):
         """Test, that pool is flushed according to config"""
 
             op.save(mti2)
             self.assertNotEqual(mti1.id, None, 'Pool is not flushed yet')
-            self.assertNotEqual(mti2.id, None, 'Pool is not flushed yet')
+            self.assertNotEqual(mti2.id, None, 'Pool is not flushed yet')
+
+    def test_delete(self):
+        mti = Mti(foo=2, bar=0)
+        mti.save()
+
+        mti_id = mti.pk
+        parent_id = mti.parent_ptr_id
+
+        Mti.objects.only('bar').get(pk=mti_id)
+        parent = Parent.objects.get(pk=parent_id)
+
+        with BatchOperation() as op:
+            op.delete(mti)
+
+        try:
+            Mti.objects.only('bar').get(pk=mti_id)
+        except Mti.DoesNotExist:
+            pass
+        else:
+            self.fail('Mti record was not deleted')
+
+        try:
+            parent = Parent.objects.get(pk=parent_id)
+        except Parent.DoesNotExist:
+            pass
+        else:
+            self.fail('Parent record was not deleted')
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.