Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def assert_instance_created(self, model_class, **kwargs):
"""
Checks if a model instance was created in the database.
For example::
>>> with self.assert_instance_created(Article, slug='lorem-ipsum'):
... Article.objects.create(slug='lorem-ipsum')
"""
return _InstanceContext(
self.assert_instance_does_not_exist,
self.assert_instance_exists,
model_class,
**kwargs
)
def assert_instance_deleted(self, model_class, **kwargs):
"""
Checks if the model instance was deleted from the database.
For example::
>>> with self.assert_instance_deleted(Article, slug='lorem-ipsum'):
... Article.objects.get(slug='lorem-ipsum').delete()
"""
return _InstanceContext(
self.assert_instance_exists,
self.assert_instance_does_not_exist,
model_class,
**kwargs
)