{"repo":"stphivos/django-mock-queries","free":true,"listed":false,"github":"https://github.com/stphivos/django-mock-queries","clone":"git clone https://github.com/stphivos/django-mock-queries.git","description":"A library for mocking django queryset functions in memory for testing","language":"Python","stars":324,"topics":["django","mocking","unittest","test-driven-development"],"license":"MIT","category":"databases-storage","readme_excerpt":"Django Mock Queries A library for mocking Django queryset functions in memory for testing Features QuerySet style support for method chaining Filtering with Q objects Aggregates generation CRUD functions Field lookups django-rest-framework serializer asserts Examples Test function that uses Django QuerySet: Test django-rest-framework model serializer: Full Example There is a full Django application in the examples/users folder. It shows how to configure django mock queries in your tests and run them with or without setting up a Django database. Running the mock tests without a database can be much faster when your Django application has a lot of database migrations. To run your Django tests without a database, add a new settings file, and call monkey patch test db() . Use a wildcard import to get all the regular settings as well. Then run your Django tests with the new settings file: ./manage.py test --settings=users.settings mocked Here's the pytest equivalent: pytest --ds=users.settings mocked That will run your tests without setting up a test database. All of your tests that use Django mock queries should run fine, but what about the tests that really need a database? ERROR: test create (examples.users.analytics.tests.TestApi) ---------------------------------------------------------------------- Traceback (most recent call last): File \"/.../examples/users/analytics/tests.py\", line 28, in test create start count = User.objects.count() [...] NotSupportedError: Mock database","default_branch":null,"files":null,"tree":[],"storefront":"/r/stphivos","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/stphivos/django-mock-queries/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}