allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jetm...@apache.org
Subject [16/27] git commit: [#7657] ticket:651 Add tests for enable/disable user
Date Wed, 01 Oct 2014 11:23:57 GMT
[#7657] ticket:651 Add tests for enable/disable user


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

Branch: refs/heads/master
Commit: a178e6fd909c20688528747eba45d865a77cb5cb
Parents: 6b32d2e
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Tue Sep 16 12:14:43 2014 +0300
Committer: Igor Bondarenko <jetmind2@gmail.com>
Committed: Wed Oct 1 10:26:41 2014 +0000

----------------------------------------------------------------------
 .../allura/tests/functional/test_site_admin.py  | 24 ++++++++++++++++++++
 Allura/allura/tests/test_plugin.py              | 17 ++++++++++++++
 2 files changed, 41 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/a178e6fd/Allura/allura/tests/functional/test_site_admin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_site_admin.py b/Allura/allura/tests/functional/test_site_admin.py
index aced210..d51ffc9 100644
--- a/Allura/allura/tests/functional/test_site_admin.py
+++ b/Allura/allura/tests/functional/test_site_admin.py
@@ -388,6 +388,30 @@ class TestUserDetails(TestController):
         r = self.app.get('/nf/admin/user/test-user')
         assert_in(u'Comment by test-admin: I was hêre!', r)
 
+    def test_disable_user(self):
+        assert_equal(M.User.by_username('test-user').disabled, False)
+        r = self.app.get('/nf/admin/user/test-user')
+        form = r.forms[0]
+        assert_equal(form['username'].value, 'test-user')
+        assert_equal(form['status'].value, 'enable')
+        form['status'].value = 'disable'
+        r = form.submit()
+        assert_in(u'User disabled', self.webflash(r))
+        assert_equal(M.User.by_username('test-user').disabled, True)
+
+    def test_enable_user(self):
+        user = M.User.by_username('test-user')
+        user.disabled = True
+        ThreadLocalORMSession.flush_all()
+        assert_equal(M.User.by_username('test-user').disabled, True)
+        r = self.app.get('/nf/admin/user/test-user')
+        form = r.forms[0]
+        assert_equal(form['username'].value, 'test-user')
+        assert_equal(form['status'].value, 'disable')
+        form['status'].value = 'enable'
+        r = form.submit()
+        assert_in(u'User enabled', self.webflash(r))
+        assert_equal(M.User.by_username('test-user').disabled, False)
 
 @task
 def test_task(*args, **kw):

http://git-wip-us.apache.org/repos/asf/allura/blob/a178e6fd/Allura/allura/tests/test_plugin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_plugin.py b/Allura/allura/tests/test_plugin.py
index c19c931..4e9e02c 100644
--- a/Allura/allura/tests/test_plugin.py
+++ b/Allura/allura/tests/test_plugin.py
@@ -19,6 +19,7 @@ import datetime as dt
 import calendar
 
 import tg
+from pylons import tmpl_context as c
 from webob import Request, exc
 from bson import ObjectId
 from ming.orm.ormsession import ThreadLocalORMSession
@@ -41,6 +42,7 @@ from allura.lib.utils import TruthyCallable
 from allura.lib.plugin import ProjectRegistrationProvider
 from allura.lib.plugin import ThemeProvider
 from allura.lib.exceptions import ProjectConflict, ProjectShortnameInvalid
+from allura.tests.decorators import audits
 from alluratest.controller import setup_basic_test, setup_global_objects
 
 
@@ -254,6 +256,21 @@ class TestLocalAuthenticationProvider(object):
         upd = self.provider.get_last_password_updated(user)
         assert_equal(upd, user.last_password_updated)
 
+    def test_enable_user(self):
+        user = Mock(disabled=True, __ming__=Mock(), is_anonymous=lambda: False, _id=ObjectId())
+        c.user = Mock(username='test-admin')
+        with audits('Account enabled by test-admin', user=True):
+            self.provider.enable_user(user)
+            ThreadLocalORMSession.flush_all()
+        assert_equal(user.disabled, False)
+
+    def test_disable_user(self):
+        user = Mock(disabled=False, __ming__=Mock(), is_anonymous=lambda: False, _id=ObjectId())
+        c.user = Mock(username='test-admin')
+        with audits('Account disabled by test-admin', user=True):
+            self.provider.disable_user(user)
+            ThreadLocalORMSession.flush_all()
+        assert_equal(user.disabled, True)
 
 class TestAuthenticationProvider(object):
 


Mime
View raw message