Exemplo n.º 1
0
 def testDeleteSimple(self):
     '''Test delete on models without related models'''
     self.data.create()
     Instrument.objects.all().delete()
     self.assertEqual(Instrument.objects.all().count(),0)
     #There should be only one key in the database,
     # The one used to autoincrement the Instrument ids
     keys = list(Instrument._meta.cursor.keys())
     self.assertEqual(len(keys),1)
     self.assertEqual(keys[0],Instrument._meta.autoid())
     Instrument.flush()
     keys = list(Instrument._meta.cursor.keys())
     self.assertEqual(len(keys),0)
Exemplo n.º 2
0
 def testFlushRelatedModel(self):
     self.data.makePositions()
     self.assertTrue(Instrument.flush()>self.data.num_insts)
     self.assertEqual(Position.objects.all().count(),0)
     self.assertEqual(Instrument.objects.all().count(),0)
     # Now we check the database if it is empty as it should
     Fund.flush()
     keys = list(Instrument._meta.cursor.keys())
     self.assertEqual(len(keys),0)
Exemplo n.º 3
0
    def testFlushSimpleModel(self):
        '''Use the class method flush to remove all instances of a
 Model including filters.'''
        self.data.create()
        self.assertTrue(Instrument.flush()>self.data.num_insts)
        self.assertEqual(Instrument.objects.all().count(),0)
        Fund.flush()
        # Now we check the database if it is empty as it should
        keys = list(Instrument._meta.cursor.keys())
        self.assertEqual(len(keys),0)