From 0c117384156f165d23ce3f6fc9f4aac98bee1a3c Mon Sep 17 00:00:00 2001 From: Kevin Kubasik Date: Wed, 1 Jul 2009 22:26:42 +0000 Subject: [PATCH] [gsoc2009-testing] Confirming that test-only models have a table in the db git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/test-improvements@11143 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/db/models/loading.py | 11 ++++++----- tests/regressiontests/admin_views/tests.py | 12 ++++++++++++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/django/db/models/loading.py b/django/db/models/loading.py index fa6e911d12..96ebe43941 100644 --- a/django/db/models/loading.py +++ b/django/db/models/loading.py @@ -200,11 +200,12 @@ class AppCache(object): def remove_model(self, model_name): """Removes a model from the cache. Used when loading test-only models.""" try: - self.write_lock.acquire() - if model_name in self.app_models: - del self.app_models[model_name] - except Exception, e: - raise e + try: + self.write_lock.acquire() + if model_name in self.app_models: + del self.app_models[model_name] + except Exception, e: + raise e finally: self.write_lock.release() diff --git a/tests/regressiontests/admin_views/tests.py b/tests/regressiontests/admin_views/tests.py index 382dfd662b..9cf6a0a944 100644 --- a/tests/regressiontests/admin_views/tests.py +++ b/tests/regressiontests/admin_views/tests.py @@ -74,6 +74,14 @@ class AdminViewBasicTest(TestCase): "Couldn't find an input with the right value in the response." ) + def testAddWithGETArgsTestModel(self): + response = self.client.get('/test_admin/%s/admin_views/sectiontest/add/' % self.urlbit, {'name': 'My TestSection'}) + self.failUnlessEqual(response.status_code, 200) + self.failUnless( + 'value="My TestSection"' in response.content, + "Couldn't find an input with the right value in the response." + ) + def testBasicEditGet(self): """ A smoke test to ensureGET on the change_view works. @@ -300,6 +308,10 @@ class CustomModelAdminTest(AdminViewBasicTest): """ response = self.client.get('/test_admin/%s/admin_views/section/add/' % self.urlbit) self.failUnlessEqual(response.status_code, 200) + def testAddWithGETArgsTestModel(self): + response = self.client.get('/test_admin/%s/admin_views/sectiontest/add/' % self.urlbit, {'name': 'My TestSection'}) + self.failUnlessEqual(response.status_code, 404) + def get_perm(Model, perm): """Return the permission object, for the Model"""