[damned-lies/person_roken: 7/9] Use force_login in people tests
- From: Claude Paroz <claudep src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [damned-lies/person_roken: 7/9] Use force_login in people tests
- Date: Sun, 31 Jan 2021 17:21:52 +0000 (UTC)
commit ec3ed17d050c235b71fb894204d783fb1a14c99b
Author: Claude Paroz <claude 2xlibre net>
Date: Sun Jan 31 14:03:12 2021 +0100
Use force_login in people tests
people/tests.py | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
---
diff --git a/people/tests.py b/people/tests.py
index ba0219db..1994432a 100644
--- a/people/tests.py
+++ b/people/tests.py
@@ -100,19 +100,19 @@ class PeopleTestCase(TestCase):
self.assertContains(response, "John Nothing")
def test_login_link(self):
- self.pn = self._create_person()
- self.assertTrue(self.client.login(username='jn', password='password'))
+ pn = self._create_person()
+ self.client.force_login(pn)
response = self.client.get(reverse('home'))
self.assertContains(
response,
'<a aria-expanded="false" aria-haspopup="true" role="button" data-toggle="dropdown"
class="dropdown-toggle hidden-xs avatar" href="%s"><img class="img-circle" alt="generic person icon"
src="/static/img/nobody.png"></a>' % (
- reverse('person_detail_username', args=[self.pn.username]),),
+ reverse('person_detail_username', args=[pn.username]),),
html=True
)
def test_edit_details(self):
- self.pn = self._create_person()
- self.client.login(username='jn', password='password')
+ pn = self._create_person()
+ self.client.force_login(pn)
response = self.client.get(reverse('person_detail_change'))
self.assertContains(response, "First name")
post_data = {
@@ -121,12 +121,12 @@ class PeopleTestCase(TestCase):
'image': '', 'webpage_url': "http://www.example.org/"
}
response = self.client.post(reverse('person_detail_change'), post_data)
- self.pn.refresh_from_db()
- self.assertEqual(self.pn.username, 'jn2')
- self.assertEqual(self.pn.email, 'test02 example org')
+ pn.refresh_from_db()
+ self.assertEqual(pn.username, 'jn2')
+ self.assertEqual(pn.email, 'test02 example org')
# bad image url
post_data['image'] = "http://http://www.example.org/image.jpg"
- form = forms.DetailForm(post_data, instance=self.pn)
+ form = forms.DetailForm(post_data, instance=pn)
self.assertFalse(form.is_valid())
self.assertTrue('image' in form.errors)
@@ -236,8 +236,8 @@ class PeopleTestCase(TestCase):
The order of the languages should be case insensitive.
This tests that "français" appears before "Gaeilge".
"""
- Person.objects.create(username='jn', password='password')
- self.client.login(username='jn', password='password')
+ pn = Person.objects.create(username='jn')
+ self.client.force_login(pn)
url = reverse('person_detail_username', kwargs={'slug': 'jn'})
response = self.client.get(url)
all_languages = response.context['all_languages']
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]