

def testIndexFilter(self):
    objects = self.mapper.simplemodel
    (yield self.async.assertEqual(objects.filter(group='g1').count(), 0))
    (v, created) = (yield objects.update_or_create(code='test5', group='g2'))
    (yield self.async.assertEqual(objects.filter(group='g1').count(), 0))
    (yield self.async.assertEqual(objects.filter(group='g2').count(), 1))
    v1 = (yield objects.get(group='g2'))
    self.assertEqual(v, v1)
    (yield self.async.assertRaises(SimpleModel.DoesNotExist, objects.get, group='g1'))
    (v2, created) = (yield objects.update_or_create(code='test6', group='g2'))
    (yield self.async.assertEqual(objects.filter(group='g2').count(), 2))
    (yield self.async.assertRaises(stdnet.QuerySetError, objects.get, group='g2'))

dataset/ETHPy150Open lsbardel/python-stdnet/tests/all/query/manager.py TestManager.testIndexFilter/original