How to use the djet.assertions._InstanceContext function in djet

To help you get started, we’ve selected a few djet examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sunscrapers / djet / djet / assertions.py View on Github external
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
        )
github sunscrapers / djet / djet / assertions.py View on Github external
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
        )