From 9b5d9cfe9cbd42d07822317fe82b7088967d0568 Mon Sep 17 00:00:00 2001 From: Oliver Falk Date: Tue, 19 Feb 2019 12:59:51 +0100 Subject: [PATCH] More tests --- ivatar/ivataraccount/test_views.py | 48 ++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/ivatar/ivataraccount/test_views.py b/ivatar/ivataraccount/test_views.py index a7f94a1..a17051f 100644 --- a/ivatar/ivataraccount/test_views.py +++ b/ivatar/ivataraccount/test_views.py @@ -40,6 +40,8 @@ class Tester(TestCase): # pylint: disable=too-many-public-methods email = '%s@%s.%s' % (username, random_string(), random_string(2)) # Dunno why random tld doesn't work, but I'm too lazy now to investigate openid = 'http://%s.%s.%s/' % (username, random_string(), 'org') + first_name = random_string() + last_name = random_string() def login(self): ''' @@ -55,6 +57,8 @@ class Tester(TestCase): # pylint: disable=too-many-public-methods self.user = User.objects.create_user( username=self.username, password=self.password, + first_name=self.first_name, + last_name=self.last_name, ) def test_new_user(self): @@ -704,6 +708,22 @@ class Tester(TestCase): # pylint: disable=too-many-public-methods self.user.confirmedemail_set.first().photo, self.user.photo_set.first()) + def test_no_photo_to_email(self): + ''' + Test assigning photo to mail address + ''' + self.test_confirm_email() + url = reverse( + 'assign_photo_email', + args=[self.user.confirmedemail_set.first().id]) + response = self.client.post(url, { + 'photoNone': True, + }, follow=True) + self.assertEqual(response.status_code, 200, 'cannot un-assign photo?') + self.assertEqual( + self.user.confirmedemail_set.first().photo, + None) + def test_assign_photo_to_email_wo_photo_for_testing_template(self): # pylint: disable=invalid-name ''' Test assign photo template @@ -1441,3 +1461,31 @@ class Tester(TestCase): # pylint: disable=too-many-public-methods 200, 'Old password as entered incorrectly, site should raise an error' ) + + def test_profile_must_list_first_and_lastname(self): + ''' + Test if profile view correctly lists first -/last name + ''' + self.login() + response = self.client.get(reverse('profile')) + self.assertContains( + response, + self.first_name, + 1, + 200, + 'First name not listed in profile page', + ) + self.assertContains( + response, + self.last_name, + 1, + 200, + 'Last name not listed in profile page', + ) + self.assertContains( + response, + self.first_name + ' ' + self.last_name, + 1, + 200, + 'First and last name not correctly listed in profile page', + )