incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tvansteenbu...@apache.org
Subject [19/20] git commit: [#6392] ticket:444 Fix tests
Date Tue, 24 Sep 2013 17:37:16 GMT
[#6392] ticket:444 Fix tests


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/4957e128
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/4957e128
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/4957e128

Branch: refs/heads/master
Commit: 4957e128b63cacacabbf6e06f3ee2a84bdc6d51f
Parents: 70e1a8d
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Tue Sep 24 14:31:49 2013 +0300
Committer: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Committed: Tue Sep 24 17:36:25 2013 +0000

----------------------------------------------------------------------
 Allura/allura/tests/functional/test_admin.py | 29 +++++++++++++----------
 1 file changed, 16 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/4957e128/Allura/allura/tests/functional/test_admin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_admin.py b/Allura/allura/tests/functional/test_admin.py
index 38a7272..66cffba 100644
--- a/Allura/allura/tests/functional/test_admin.py
+++ b/Allura/allura/tests/functional/test_admin.py
@@ -168,42 +168,46 @@ class TestProjectAdmin(TestController):
 
     @td.with_wiki
     def test_block_user_empty_data(self):
-        # shouldn't fail
-        self.app.post('/admin/wiki/block_user', params={'username': '', 'perm': '', 'reason':
''})
+        r = self.app.post('/admin/wiki/block_user', params={'username': '', 'perm': '', 'reason':
''})
+        assert_equals(r.json, dict(error='Enter username'))
 
     @td.with_wiki
     def test_unblock_user_empty_data(self):
-        # shouldn't fail
-        self.app.post('/admin/wiki/unblock_user', params={'user_id': '', 'perm': ''})
+        r = self.app.post('/admin/wiki/unblock_user', params={'user_id': '', 'perm': ''})
+        assert_equals(r.json, dict(error='Select user to unblock'))
 
     @td.with_wiki
     def test_block_user(self):
         r = self.app.get('/admin/wiki/permissions')
-        assert '<a href="#" class="block-user">' in r
-        assert '<a href="#" class="block-list">' not in r
+        assert '<input type="checkbox" name="user_id"' not in r
 
-        self.app.post('/admin/wiki/block_user', params={'username': 'test-admin', 'perm':
'read', 'reason': 'Comment'})
+        user = M.User.by_username('test-admin')
+        r = self.app.post('/admin/wiki/block_user', params={'username': 'test-admin', 'perm':
'read', 'reason': 'Comment'})
+        assert_equals(r.json, dict(user_id=str(user._id), username='test-admin', reason='Comment'))
         user = M.User.by_username('test-admin')
         admin_role = user.project_role()
         app = M.Project.query.get(shortname='test').app_instance('wiki')
         ace = M.ACL.contains(M.ACE.deny(admin_role._id, 'read'), app.acl)
         assert_equals(ace.reason, 'Comment')
         r = self.app.get('/admin/wiki/permissions')
-        assert '<a href="#" class="block-list">' in r
         assert '<input type="checkbox" name="user_id" value="%s">test-admin (Comment)'
% user._id in r
 
     @td.with_wiki
     def test_unblock_user(self):
-        self.app.post('/admin/wiki/block_user', params={'username': 'test-admin', 'perm':
'read'})
+        r = self.app.post('/admin/wiki/block_user', params={'username': 'test-admin', 'perm':
'read'})
         user = M.User.by_username('test-admin')
         admin_role = user.project_role()
         app = M.Project.query.get(shortname='test').app_instance('wiki')
         ace = M.ACE.deny(admin_role._id, 'read')
+        r = self.app.get('/admin/wiki/permissions')
+        assert '<input type="checkbox" name="user_id" value="%s">test-admin' % user._id
in r
+        app = M.Project.query.get(shortname='test').app_instance('wiki')
         assert M.ACL.contains(ace, app.acl) is not None
-        self.app.post('/admin/wiki/unblock_user', params={'user_id': str(user._id), 'perm':
'read'})
+        r = self.app.post('/admin/wiki/unblock_user', params={'user_id': str(user._id), 'perm':
'read'})
+        assert_equals(r.json, dict(unblocked=[str(user._id)]))
         assert M.ACL.contains(ace, app.acl) is None
         r = self.app.get('/admin/wiki/permissions')
-        assert '<a href="#" class="block-list">' not in r
+        assert '<input type="checkbox" name="user_id"' not in r
 
     @td.with_wiki
     def test_block_unblock_multiple_users(self):
@@ -219,7 +223,6 @@ class TestProjectAdmin(TestController):
         assert M.ACL.contains(deny_admin, app.acl) is not None
         assert M.ACL.contains(deny_user, app.acl) is not None
         r = self.app.get('/admin/wiki/permissions')
-        assert '<a href="#" class="block-list">' in r
         assert '<input type="checkbox" name="user_id" value="%s">test-admin (Spammer)'
% admin._id in r
         assert '<input type="checkbox" name="user_id" value="%s">test-user' % user._id
in r
 
@@ -229,7 +232,7 @@ class TestProjectAdmin(TestController):
         assert M.ACL.contains(deny_admin, app.acl) is None
         assert M.ACL.contains(deny_user, app.acl) is None
         r = self.app.get('/admin/wiki/permissions')
-        assert '<a href="#" class="block-list">' not in r
+        assert '<input type="checkbox" name="user_id"' not in r
 
     @td.with_wiki
     def test_blocked_users_remains_after_saving_all_permissions(self):


Mime
View raw message