-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ability for tests to use mock models. #3
Comments
Got this approach working on code for a work-project. Just going to paste some stuff here as a remeninder. use the following code when you don't want to do
and in the test: class MyTest(TestCase):
And all we need now is a very basic settings module with a sqlite3 db. That's about it. |
It looks like this issue is actually already solved in a couple of tests, eg: https://github.com/ekohl/django-rest-framework/blob/pep8/djangorestframework/tests/modelviews.py @tomchristie or do you beleaeve there's more work needed done on this issue? |
Ah yeah. Looks done. djangorestframework/tests/models.py exists, and does what this ticket was originally requesting. Thanks! |
At the moment none of the tests are able to create some mock Models and test stuff against them, because the tests don't have a models.py. It be good if we could just do something like add 'models.py' into the tests directory, and add 'djangorestframework.tests' as an INSTALLED_APP in the runtests.py script, or something like that. But needs someone to find out if that'd actually work, how to add them in the runtests.py script, and make sure they're not installed if you just do a regular syncdb on djangorestframework.
For example, would be nice to see some tests to check serializing of nested models, but we wouldn't want those models to actually be installed in djangorestframework by default.
The text was updated successfully, but these errors were encountered: