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
Reset sequences only for tables that exists. #79
Conversation
If using multiple databases setup we need to make sure we aren't trying to reset sequences that doesn't exists in particular DB.
Good catch! I'll give it a try and merge it in. I'm trying to improve test coverage in django-nose. You don't have a test case lying around, do you? |
Unfortunately I don't have any. I can write some, however I don't see 'django_nose/tests', where should I put test for this piece of code? |
If you're willing, that's awesome! Tests are a little weird in django-nose at the moment. Essentially, we have a shell script that runs tests against a dedicated test app over and over, with various settings. So for now, your tests should go in that test app. You can make a fresh settings file (copying settings_with_plugins.py, for example), define multiple DBs in there, and add a line to runtests.sh saying --settings=testapp.settings_with_multi_db. The actual assertions can go in testapp/tests/test_databases.py. Does that make sense? Thanks again! |
Hi Eric, I must agree that tests in the project are weird :) I was trying to follow your guide, create testapp.settings_with_multi_db and put my tests into testapp/tests. However to much of other things needs to be done to create a test case I need:
Also there was a few other issues. That's why I've tried to go with unittests for my method only. Please take a look and tell me what you think. |
Any chance that this will be merged into master? |
I promise it. Sorry I've been unresponsive; blame the startup life and an overabundance of good patches! |
+1 for this pull request. thanks! |
Just have to find an hour or 3 to pay attention to this! :-) |
+1 I have tried with the current repository status and it works like charm. @erikrose is ready to check-in |
The new tests mock the model-loading cache but don't put it back afterward. Working on a fix. |
Thanks! |
Thank you! |
If using multiple databases setup we need to make sure we aren't trying
to reset sequences that doesn't exists in particular DB.
I've faced problem with using REUSE_DB=1 with multidb setup. The problem was that NoseTestSuiteRunner.setup_databases() was trying to execute reset statements for all the models on every connection. My patch adds a check that the model's table is present in DB before executing reset statement.