

def _assert_crud(self, instance, defaults=None, updates=None):
    self.assertIsNone(getattr(instance, 'id', None))
    self._assert_values_equal(instance, values=defaults)
    saved = self.access_type.add_or_update(instance)
    self.assertIsNotNone(saved.id)
    self._assert_fields_equal(instance, saved, exclude=['id'])
    retrieved = self.access_type.get_by_id(saved.id)
    self._assert_fields_equal(saved, retrieved)
    for (k, v) in six.iteritems((updates or {
        
    })):
        setattr(instance, k, v)
    updated = self.access_type.add_or_update(instance)
    self._assert_fields_equal(instance, updated)
    retrieved = self.access_type.get_by_id(instance.id)
    retrieved.delete()
    self.assertRaises(ValueError, self.access_type.get_by_id, instance.id)

dataset/ETHPy150Open StackStorm/st2/st2tests/st2tests/base.py DbModelTestCase._assert_crud/original