diff --git a/tests/test_progit_flask_ui_admin.py b/tests/test_progit_flask_ui_admin.py
index 0057be0..4dacbde 100644
--- a/tests/test_progit_flask_ui_admin.py
+++ b/tests/test_progit_flask_ui_admin.py
@@ -60,8 +60,9 @@ class PagureFlaskAdmintests(tests.Modeltests):
with tests.user_set(pagure.APP, user):
output = self.app.get('/admin', follow_redirects=True)
self.assertEqual(output.status_code, 200)
- self.assertTrue(
- '
Access restricted ' in output.data)
+ self.assertIn(
+ '\n Access restricted',
+ output.data)
user = tests.FakeUser(
username='pingou',
@@ -89,8 +90,9 @@ class PagureFlaskAdmintests(tests.Modeltests):
with tests.user_set(pagure.APP, user):
output = self.app.post('/admin/gitolite', follow_redirects=True)
self.assertEqual(output.status_code, 200)
- self.assertTrue(
- 'Access restricted ' in output.data)
+ self.assertIn(
+ '\n Access restricted',
+ output.data)
user = tests.FakeUser(
username='pingou',
@@ -118,7 +120,7 @@ class PagureFlaskAdmintests(tests.Modeltests):
self.assertTrue(
'Re-generate user ssh key files' in output.data)
self.assertTrue(
- 'Gitolite ACLs updated '
+ '\n Gitolite ACLs updated'
in output.data)
@patch('pagure.generate_user_key_files')
@@ -136,8 +138,9 @@ class PagureFlaskAdmintests(tests.Modeltests):
with tests.user_set(pagure.APP, user):
output = self.app.post('/admin/ssh', follow_redirects=True)
self.assertEqual(output.status_code, 200)
- self.assertTrue(
- 'Access restricted ' in output.data)
+ self.assertIn(
+ '\n Access restricted',
+ output.data)
user = tests.FakeUser(
username='pingou',
@@ -165,7 +168,7 @@ class PagureFlaskAdmintests(tests.Modeltests):
self.assertTrue(
'Re-generate user ssh key files' in output.data)
self.assertTrue(
- 'User key files regenerated '
+ '\n User key files regenerated'
in output.data)
def test_admin_generate_hook_token(self):
@@ -181,8 +184,9 @@ class PagureFlaskAdmintests(tests.Modeltests):
with tests.user_set(pagure.APP, user):
output = self.app.post('/admin/hook_token', follow_redirects=True)
self.assertEqual(output.status_code, 200)
- self.assertTrue(
- 'Access restricted ' in output.data)
+ self.assertIn(
+ '\n Access restricted',
+ output.data)
user = tests.FakeUser(
username='pingou',
@@ -211,7 +215,7 @@ class PagureFlaskAdmintests(tests.Modeltests):
self.assertTrue(
'Re-generate hook-token for every projects' in output.data)
self.assertTrue(
- 'Hook token all re-generated '
+ '\n Hook token all re-generated'
in output.data)
diff --git a/tests/test_progit_flask_ui_app.py b/tests/test_progit_flask_ui_app.py
index 3c2cf07..700539e 100644
--- a/tests/test_progit_flask_ui_app.py
+++ b/tests/test_progit_flask_ui_app.py
@@ -185,9 +185,9 @@ class PagureFlaskApptests(tests.Modeltests):
output = self.app.post('/new/', data=data)
self.assertEqual(output.status_code, 200)
self.assertIn('Create new Project ', output.data)
- self.assertTrue(
- 'No user "username" found '
- in output.data)
+ self.assertIn(
+ '\n No user "username" found',
+ output.data)
user.username = 'foo'
with tests.user_set(pagure.APP, user):
@@ -195,9 +195,9 @@ class PagureFlaskApptests(tests.Modeltests):
output = self.app.post('/new/', data=data, follow_redirects=True)
self.assertEqual(output.status_code, 200)
self.assertTrue('Project #1
' in output.data)
- self.assertTrue(
- 'Project "project-1" created '
- in output.data)
+ self.assertIn(
+ '\n Project "project-1" created',
+ output.data)
# After
projects = pagure.lib.search_projects(self.session)
@@ -227,10 +227,12 @@ class PagureFlaskApptests(tests.Modeltests):
with tests.user_set(pagure.APP, user):
output = self.app.get('/settings/')
self.assertEqual(output.status_code, 200)
- self.assertTrue("foo's settings " in output.data)
- self.assertTrue(
- ''
- in output.data)
+ self.assertIn(
+ '', output.data)
+ self.assertIn(
+ '', output.data)
csrf_token = output.data.split(
'name="csrf_token" type="hidden" value="')[1].split('">')[0]
@@ -241,10 +243,12 @@ class PagureFlaskApptests(tests.Modeltests):
output = self.app.post('/settings/', data=data)
self.assertEqual(output.status_code, 200)
- self.assertTrue("foo's settings " in output.data)
- self.assertTrue(
- '' in output.data)
+ self.assertIn(
+ '', output.data)
+ self.assertIn(
+ '', output.data)
data['csrf_token'] = csrf_token
@@ -252,14 +256,14 @@ class PagureFlaskApptests(tests.Modeltests):
'/settings/', data=data, follow_redirects=True)
self.assertEqual(output.status_code, 200)
self.assertTrue(
- 'Public ssh key updated '
+ '\n Public ssh key updated'
in output.data)
self.assertIn(
- 'Projects 1 ',
- output.data)
+ '', output.data)
self.assertIn(
- 'Forks 0 ',
- output.data)
+ '', output.data)
ast.return_value = True
output = self.app.get('/settings/')
@@ -281,10 +285,12 @@ class PagureFlaskApptests(tests.Modeltests):
with tests.user_set(pagure.APP, user):
output = self.app.get('/settings/')
self.assertEqual(output.status_code, 200)
- self.assertTrue("foo's settings " in output.data)
- self.assertTrue(
- ''
- in output.data)
+ self.assertIn(
+ '', output.data)
+ self.assertIn(
+ '', output.data)
csrf_token = output.data.split(
'name="csrf_token" type="hidden" value="')[1].split('">')[0]
@@ -316,10 +322,12 @@ class PagureFlaskApptests(tests.Modeltests):
with tests.user_set(pagure.APP, user):
output = self.app.post('/settings/')
self.assertEqual(output.status_code, 200)
- self.assertTrue("foo's settings " in output.data)
- self.assertTrue(
- ''
- in output.data)
+ self.assertIn(
+ '', output.data)
+ self.assertIn(
+ '', output.data)
csrf_token = output.data.split(
'name="csrf_token" type="hidden" value="')[1].split('">')[0]
@@ -331,19 +339,26 @@ class PagureFlaskApptests(tests.Modeltests):
output = self.app.post(
'/settings/email/drop', data=data, follow_redirects=True)
self.assertEqual(output.status_code, 200)
- self.assertTrue("foo's settings " in output.data)
self.assertIn(
- 'You must always have at least one email ',
+ '', output.data)
+ self.assertIn(
+ '', output.data)
+ self.assertIn(
+ '\n You must always have at least one email',
output.data)
user.username = 'pingou'
with tests.user_set(pagure.APP, user):
output = self.app.post('/settings/')
self.assertEqual(output.status_code, 200)
- self.assertTrue("pingou's settings " in output.data)
- self.assertTrue(
- ''
- in output.data)
+ self.assertIn(
+ '', output.data)
+ self.assertIn(
+ '', output.data)
csrf_token = output.data.split(
'name="csrf_token" type="hidden" value="')[1].split('">')[0]
@@ -355,7 +370,9 @@ class PagureFlaskApptests(tests.Modeltests):
output = self.app.post(
'/settings/email/drop', data=data, follow_redirects=True)
self.assertEqual(output.status_code, 200)
- self.assertTrue("pingou's settings " in output.data)
+ self.assertIn(
+ '', output.data)
self.assertEqual(output.data.count('foo@pingou.com'), 4)
data = {
@@ -366,10 +383,12 @@ class PagureFlaskApptests(tests.Modeltests):
output = self.app.post(
'/settings/email/drop', data=data, follow_redirects=True)
self.assertEqual(output.status_code, 200)
- self.assertTrue("pingou's settings " in output.data)
self.assertIn(
- 'You do not have the email: foobar@pingou'
- '.com, nothing to remove ', output.data)
+ '', output.data)
+ self.assertIn(
+ '\n You do not have the '
+ 'email: foobar@pingou.com, nothing to remove', output.data)
data = {
'csrf_token': csrf_token,
@@ -410,32 +429,33 @@ class PagureFlaskApptests(tests.Modeltests):
with tests.user_set(pagure.APP, user):
output = self.app.post('/settings/email/add')
self.assertEqual(output.status_code, 200)
- self.assertTrue('Add new email ' in output.data)
- self.assertTrue(
- ' '
- in output.data)
+
+ self.assertTrue("Add new email " in output.data)
+ self.assertIn(
+ ' ', output.data)
user.username = 'pingou'
with tests.user_set(pagure.APP, user):
output = self.app.post('/settings/email/add')
self.assertEqual(output.status_code, 200)
- self.assertTrue("Add new email " in output.data)
- self.assertTrue(
- ' '
- in output.data)
+ self.assertTrue("Add new email " in output.data)
+ self.assertIn(
+ ' ', output.data)
csrf_token = output.data.split(
'name="csrf_token" type="hidden" value="')[1].split('">')[0]
data = {
- 'email': 'foo@pingou.com',
+ 'email': 'foo2@pingou.com',
}
output = self.app.post(
'/settings/email/add', data=data, follow_redirects=True)
self.assertEqual(output.status_code, 200)
- self.assertTrue("Add new email " in output.data)
- self.assertEqual(output.data.count('foo@pingou.com'), 1)
+ self.assertTrue("Add new email " in output.data)
+ self.assertEqual(output.data.count('foo2@pingou.com'), 1)
# New email
data = {
@@ -446,9 +466,11 @@ class PagureFlaskApptests(tests.Modeltests):
output = self.app.post(
'/settings/email/add', data=data, follow_redirects=True)
self.assertEqual(output.status_code, 200)
- self.assertTrue('pingou\'s settings ' in output.data)
self.assertIn(
- 'Email pending validation ',
+ '', output.data)
+ self.assertIn(
+ '\n Email pending validation',
output.data)
self.assertEqual(output.data.count('foo@pingou.com'), 4)
self.assertEqual(output.data.count('bar@pingou.com'), 4)
@@ -463,13 +485,13 @@ class PagureFlaskApptests(tests.Modeltests):
output = self.app.post(
'/settings/email/add', data=data, follow_redirects=True)
self.assertEqual(output.status_code, 200)
- self.assertTrue('pingou\'s settings ' in output.data)
+ self.assertTrue("Add new email " in output.data)
self.assertIn(
- 'The email: foo@pingou.com is already '
- 'associated to you ', output.data)
+ 'Invalid value, can't be any of: bar@pingou.com, '
+ 'foo@pingou.com. ', output.data)
self.assertEqual(output.data.count('foo@pingou.com'), 5)
self.assertEqual(output.data.count('bar@pingou.com'), 4)
- self.assertEqual(output.data.count('foobar@pingou.com'), 1)
+ self.assertEqual(output.data.count('foobar@pingou.com'), 0)
# Email registered by someone else
data = {
@@ -480,10 +502,10 @@ class PagureFlaskApptests(tests.Modeltests):
output = self.app.post(
'/settings/email/add', data=data, follow_redirects=True)
self.assertEqual(output.status_code, 200)
- self.assertTrue("Add new email " in output.data)
+ self.assertTrue("Add new email " in output.data)
self.assertIn(
- 'Someone else has already registered this '
- 'email ', output.data)
+ 'Invalid value, can't be any of: foo@bar.com. ',
+ output.data)
ast.return_value = True
output = self.app.post('/settings/email/add', data=data)
@@ -507,10 +529,12 @@ class PagureFlaskApptests(tests.Modeltests):
with tests.user_set(pagure.APP, user):
output = self.app.get('/settings/')
self.assertEqual(output.status_code, 200)
- self.assertTrue("pingou's settings " in output.data)
- self.assertTrue(
- ''
- in output.data)
+ self.assertIn(
+ '', output.data)
+ self.assertIn(
+ '', output.data)
csrf_token = output.data.split(
'name="csrf_token" type="hidden" value="')[1].split('">')[0]
@@ -522,7 +546,9 @@ class PagureFlaskApptests(tests.Modeltests):
output = self.app.post(
'/settings/email/default', data=data, follow_redirects=True)
self.assertEqual(output.status_code, 200)
- self.assertTrue("pingou's settings " in output.data)
+ self.assertIn(
+ '', output.data)
self.assertEqual(output.data.count('foo@pingou.com'), 4)
# Set invalid default email
@@ -534,11 +560,14 @@ class PagureFlaskApptests(tests.Modeltests):
output = self.app.post(
'/settings/email/default', data=data, follow_redirects=True)
self.assertEqual(output.status_code, 200)
- self.assertTrue("pingou's settings " in output.data)
+ self.assertIn(
+ '', output.data)
self.assertEqual(output.data.count('foo@pingou.com'), 4)
self.assertIn(
- 'You do not have the email: foobar@pingou'
- '.com, nothing to set ', output.data)
+ '\n You do not have the '
+ 'email: foobar@pingou.com, nothing to set',
+ output.data)
# Set default email
data = {
@@ -549,11 +578,13 @@ class PagureFlaskApptests(tests.Modeltests):
output = self.app.post(
'/settings/email/default', data=data, follow_redirects=True)
self.assertEqual(output.status_code, 200)
- self.assertTrue("pingou's settings " in output.data)
+ self.assertIn(
+ '', output.data)
self.assertEqual(output.data.count('foo@pingou.com'), 4)
self.assertIn(
- 'Default email set to: foo@pingou.com ',
- output.data)
+ '\n Default email set to: '
+ 'foo@pingou.com', output.data)
ast.return_value = True
output = self.app.post('/settings/email/default', data=data)
@@ -588,9 +619,10 @@ class PagureFlaskApptests(tests.Modeltests):
'/settings/email/confirm/foobar', follow_redirects=True)
self.assertEqual(output.status_code, 200)
self.assertIn(
- "pingou's settings ", output.data)
+ '', output.data)
self.assertIn(
- 'No email associated with this token. ',
+ '\n No email associated with this token.',
output.data)
# Confirm email
@@ -598,9 +630,11 @@ class PagureFlaskApptests(tests.Modeltests):
'/settings/email/confirm/abcdef', follow_redirects=True)
self.assertEqual(output.status_code, 200)
self.assertIn(
- "pingou's settings ", output.data)
+ '', output.data)
self.assertIn(
- 'Email validated ', output.data)
+ '\n Email validated',
+ output.data)
userobj = pagure.lib.search_user(self.session, username='pingou')
self.assertEqual(len(userobj.emails), 3)