### Eclipse Workspace Patch 1.0
#P Django trunk
|
|
|
10 | 10 | from django.core import mail |
11 | 11 | from django.core.urlresolvers import reverse |
12 | 12 | |
13 | | class PasswordResetTest(TestCase): |
| 13 | |
| 14 | class BaseAuthTest(TestCase): |
14 | 15 | fixtures = ['authtestdata.json'] |
15 | 16 | urls = 'django.contrib.auth.urls' |
16 | 17 | |
| 18 | def setUp(self): |
| 19 | self.old_TEMPLATE_DIRS = settings.TEMPLATE_DIRS |
| 20 | settings.TEMPLATE_DIRS = ( |
| 21 | os.path.join(os.path.dirname(__file__), 'templates'), |
| 22 | ) |
| 23 | |
| 24 | def tearDown(self): |
| 25 | settings.TEMPLATE_DIRS = self.old_TEMPLATE_DIRS |
| 26 | |
| 27 | |
| 28 | class PasswordResetTest(BaseAuthTest): |
17 | 29 | def test_email_not_found(self): |
18 | 30 | "Error is raised if the provided email address isn't currently registered" |
19 | 31 | response = self.client.get('/password_reset/') |
… |
… |
|
93 | 105 | self.assert_("The two password fields didn't match" in response.content) |
94 | 106 | |
95 | 107 | |
96 | | class ChangePasswordTest(TestCase): |
97 | | fixtures = ['authtestdata.json'] |
98 | | urls = 'django.contrib.auth.urls' |
99 | | |
100 | | def setUp(self): |
101 | | self.old_TEMPLATE_DIRS = settings.TEMPLATE_DIRS |
102 | | settings.TEMPLATE_DIRS = ( |
103 | | os.path.join( |
104 | | os.path.dirname(__file__), |
105 | | 'templates' |
106 | | ) |
107 | | ,) |
108 | | |
109 | | def tearDown(self): |
110 | | settings.TEMPLATE_DIRS = self.old_TEMPLATE_DIRS |
111 | | |
| 108 | class ChangePasswordTest(BaseAuthTest): |
112 | 109 | def login(self, password='password'): |
113 | 110 | response = self.client.post('/login/', { |
114 | 111 | 'username': 'testclient', |
… |
… |
|
165 | 162 | self.fail_login() |
166 | 163 | self.login(password='password1') |
167 | 164 | |
168 | | class LoginTest(TestCase): |
169 | | fixtures = ['authtestdata.json'] |
170 | | urls = 'django.contrib.auth.urls' |
171 | 165 | |
172 | | def setUp(self): |
173 | | self.old_TEMPLATE_DIRS = settings.TEMPLATE_DIRS |
174 | | settings.TEMPLATE_DIRS = (os.path.join(os.path.dirname(__file__), 'templates'),) |
175 | | |
176 | | def tearDown(self): |
177 | | settings.TEMPLATE_DIRS = self.old_TEMPLATE_DIRS |
178 | | |
| 166 | class LoginTest(BaseAuthTest): |
179 | 167 | def test_current_site_in_context_after_login(self): |
180 | 168 | response = self.client.get(reverse('django.contrib.auth.views.login')) |
181 | 169 | self.assertEquals(response.status_code, 200) |
182 | 170 | site = Site.objects.get_current() |
183 | 171 | self.assertEquals(response.context['site'], site) |
184 | 172 | self.assertEquals(response.context['site_name'], site.name) |
185 | | self.assert_(isinstance(response.context['form'], AuthenticationForm), |
| 173 | self.assert_(isinstance(response.context['form'], AuthenticationForm), |
186 | 174 | 'Login form is not an AuthenticationForm') |
187 | | |
188 | | class LogoutTest(TestCase): |
| 175 | |
| 176 | |
| 177 | class LogoutTest(BaseAuthTest): |
189 | 178 | fixtures = ['authtestdata.json'] |
190 | 179 | urls = 'django.contrib.auth.tests.urls' |
191 | 180 | |
… |
… |
|
210 | 199 | self.assert_('Logged out' in response.content) |
211 | 200 | self.confirm_logged_out() |
212 | 201 | |
213 | | def test_logout_with_next_page_specified(self): |
| 202 | def test_logout_with_next_page_specified(self): |
214 | 203 | "Logout with next_page option given redirects to specified resource" |
215 | 204 | self.login() |
216 | 205 | response = self.client.get('/logout/next_page/') |