Author: ramiro
Date: 2012-03-10 09:36:41 -0800 (Sat, 10 Mar 2012)
New Revision: 17676

Added:
   django/trunk/tests/regressiontests/createsuperuser/
   django/trunk/tests/regressiontests/createsuperuser/__init__.py
   django/trunk/tests/regressiontests/createsuperuser/models.py
   django/trunk/tests/regressiontests/createsuperuser/tests.py
Modified:
   django/trunk/django/contrib/auth/tests/__init__.py
   django/trunk/django/contrib/auth/tests/management.py
Log:
Fixed #17327 (again) -- Moved createsuperuser tests added in r17665.

In their new location they won't cause multi-db-related errors when
users run contrib.auh tests together with their application tests.

Thanks brianriley for the patch.

Modified: django/trunk/django/contrib/auth/tests/__init__.py
===================================================================
--- django/trunk/django/contrib/auth/tests/__init__.py  2012-03-10 17:24:11 UTC 
(rev 17675)
+++ django/trunk/django/contrib/auth/tests/__init__.py  2012-03-10 17:36:41 UTC 
(rev 17676)
@@ -12,8 +12,6 @@
 from django.contrib.auth.tests.management import (
     GetDefaultUsernameTestCase,
     ChangepasswordManagementCommandTestCase,
-    MultiDBChangepasswordManagementCommandTestCase,
-    MultiDBCreatesuperuserTestCase,
 )
 from django.contrib.auth.tests.models import (ProfileTestCase, 
NaturalKeysTestCase,
     LoadDataWithoutNaturalKeysTestCase, LoadDataWithNaturalKeysTestCase,

Modified: django/trunk/django/contrib/auth/tests/management.py
===================================================================
--- django/trunk/django/contrib/auth/tests/management.py        2012-03-10 
17:24:11 UTC (rev 17675)
+++ django/trunk/django/contrib/auth/tests/management.py        2012-03-10 
17:36:41 UTC (rev 17676)
@@ -2,7 +2,6 @@
 
 from django.contrib.auth import models, management
 from django.contrib.auth.management.commands import changepassword
-from django.core.management import call_command
 from django.test import TestCase
 
 
@@ -70,53 +69,3 @@
             stdout=self.stdout,
             stderr=self.stderr
         )
-
-
-class MultiDBChangepasswordManagementCommandTestCase(TestCase):
-    multi_db = True
-
-    def setUp(self):
-        self.user = 
models.User.objects.db_manager('other').create_user(username='joe', 
password='qwerty')
-        self.stdout = StringIO()
-
-    def tearDown(self):
-        self.stdout.close()
-
-    def 
test_that_changepassword_command_with_database_option_uses_given_db(self):
-        """
-        Executing the changepassword management command with a database option
-        should operate on the specified DB
-        """
-        self.assertTrue(self.user.check_password('qwerty'))
-        command = changepassword.Command()
-        command._get_pass = lambda *args: 'not qwerty'
-
-        command.execute("joe", database='other', stdout=self.stdout)
-        command_output = self.stdout.getvalue().strip()
-
-        self.assertEquals(command_output, "Changing password for user 
'joe'\nPassword changed successfully for user 'joe'")
-        
self.assertTrue(models.User.objects.using('other').get(username="joe").check_password("not
 qwerty"))
-
-
-class MultiDBCreatesuperuserTestCase(TestCase):
-    multi_db = True
-
-    def test_createsuperuser_command_with_database_option(self):
-        " createsuperuser command should operate on specified DB"
-        new_io = StringIO()
-
-        call_command("createsuperuser",
-            interactive=False,
-            username="joe",
-            email="[email protected]",
-            database='other',
-            stdout=new_io
-        )
-        command_output = new_io.getvalue().strip()
-
-        self.assertEqual(command_output, 'Superuser created successfully.')
-
-        u = models.User.objects.using('other').get(username="joe")
-        self.assertEqual(u.email, '[email protected]')
-
-        new_io.close()

Added: django/trunk/tests/regressiontests/createsuperuser/__init__.py
===================================================================
Added: django/trunk/tests/regressiontests/createsuperuser/models.py
===================================================================
Added: django/trunk/tests/regressiontests/createsuperuser/tests.py
===================================================================
--- django/trunk/tests/regressiontests/createsuperuser/tests.py                 
        (rev 0)
+++ django/trunk/tests/regressiontests/createsuperuser/tests.py 2012-03-10 
17:36:41 UTC (rev 17676)
@@ -0,0 +1,57 @@
+from StringIO import StringIO
+
+from django.contrib.auth import models
+from django.contrib.auth.management.commands import changepassword
+from django.core.management import call_command
+from django.test import TestCase
+
+
+class MultiDBChangepasswordManagementCommandTestCase(TestCase):
+    multi_db = True
+
+    def setUp(self):
+        self.user = 
models.User.objects.db_manager('other').create_user(username='joe', 
password='qwerty')
+        self.stdout = StringIO()
+
+    def tearDown(self):
+        self.stdout.close()
+
+    def 
test_that_changepassword_command_with_database_option_uses_given_db(self):
+        """
+        Executing the changepassword management command with a database option
+        should operate on the specified DB
+        """
+        self.assertTrue(self.user.check_password('qwerty'))
+        command = changepassword.Command()
+        command._get_pass = lambda *args: 'not qwerty'
+
+        command.execute("joe", database='other', stdout=self.stdout)
+        command_output = self.stdout.getvalue().strip()
+
+        self.assertEquals(command_output, "Changing password for user 
'joe'\nPassword changed successfully for user 'joe'")
+        
self.assertTrue(models.User.objects.using('other').get(username="joe").check_password("not
 qwerty"))
+
+
+class MultiDBCreatesuperuserTestCase(TestCase):
+    multi_db = True
+
+    def test_createsuperuser_command_with_database_option(self):
+        " createsuperuser command should operate on specified DB"
+        new_io = StringIO()
+
+        call_command("createsuperuser",
+            interactive=False,
+            username="joe",
+            email="[email protected]",
+            database='other',
+            stdout=new_io
+        )
+        command_output = new_io.getvalue().strip()
+
+        self.assertEqual(command_output, 'Superuser created successfully.')
+
+        u = models.User.objects.using('other').get(username="joe")
+        self.assertEqual(u.email, '[email protected]')
+
+        new_io.close()
+

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to