aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/tests/test_moderation.py
diff options
context:
space:
mode:
authortilly-Q <nattilypigeonfowl@gmail.com>2013-08-29 17:31:19 -0400
committertilly-Q <nattilypigeonfowl@gmail.com>2013-08-29 17:31:19 -0400
commit1bb367f6136ae4cbcdf6dd86af65eb613913dbd8 (patch)
treec3565801fcf21de1383b5bdb764208b3a98c8e49 /mediagoblin/tests/test_moderation.py
parentdfd66b789cd6cc9470c2a98bcbda9ee5e0f3ad0f (diff)
downloadmediagoblin-1bb367f6136ae4cbcdf6dd86af65eb613913dbd8.tar.lz
mediagoblin-1bb367f6136ae4cbcdf6dd86af65eb613913dbd8.tar.xz
mediagoblin-1bb367f6136ae4cbcdf6dd86af65eb613913dbd8.zip
This is a quick commit. I gave admins the ability to ban or unban users
straight from the moderation.users_detail page. I also changed the UserBan.expiration_date type from DateTime into Date. I also began work on the Terms of Service, pulled from another website (which will be cited clearly before I'm done). I added new tests as well for the ban/unbanning. Lastly, I added a few `user_not_banned` decorators to relevant views, so banned users cannot access any pages.
Diffstat (limited to 'mediagoblin/tests/test_moderation.py')
-rw-r--r--mediagoblin/tests/test_moderation.py47
1 files changed, 44 insertions, 3 deletions
diff --git a/mediagoblin/tests/test_moderation.py b/mediagoblin/tests/test_moderation.py
index d4f57c74..6160ce3d 100644
--- a/mediagoblin/tests/test_moderation.py
+++ b/mediagoblin/tests/test_moderation.py
@@ -21,6 +21,7 @@ from mediagoblin.tests.tools import (fixture_add_user,
from mediagoblin.db.models import User, CommentReport, MediaComment, UserBan
from mediagoblin.moderation.tools import take_away_privileges, give_privileges
from mediagoblin.tools import template, mail
+from datetime import date, timedelta
from webtest import AppError
@@ -160,7 +161,9 @@ VGhpcyBpcyB5b3VyIGxhc3Qgd2FybmluZywgcmVndWxhci4uLi4=\n',
response, context = self.do_post(
{'action_to_resolve':[u'userban', u'delete'],
- 'targeted_user':self.user.id},
+ 'targeted_user':self.user.id,
+ 'why_user_was_banned':u'',
+ 'user_banned_until':u''},
url='/mod/reports/{0}/'.format(comment_report.id))
assert response.status == '302 FOUND'
self.query_for_users()
@@ -189,6 +192,44 @@ VGhpcyBpcyB5b3VyIGxhc3Qgd2FybmluZywgcmVndWxhci4uLi4=\n',
def testAllModerationViews(self):
self.login(u'moderator')
- self.test_app.get('/mod/reports/')
- self.test_app.get('/mod/users/')
+ username = self.user.username
+ fixture_add_comment_report(reported_user=self.admin_user)
+ response = self.test_app.get('/mod/reports/')
+ assert response.status == "200 OK"
+
+ response = self.test_app.get('/mod/reports/1/')
+ assert response.status == "200 OK"
+
+ response = self.test_app.get('/mod/users/')
+ assert response.status == "200 OK"
+
+ user_page_url = '/mod/users/{0}/'.format(username)
+ response = self.test_app.get(user_page_url)
+ assert response.status == "200 OK"
+
self.test_app.get('/mod/media/')
+ assert response.status == "200 OK"
+
+ def testBanUnBanUser(self):
+ self.login(u'admin')
+ username = self.user.username
+ user_id = self.user.id
+ ban_url = '/mod/users/{0}/ban/'.format(username)
+ response, context = self.do_post({
+ 'user_banned_until':u'',
+ 'why_user_was_banned':u'Because I said so'},
+ url=ban_url)
+
+ assert response.status == "302 FOUND"
+ user_banned = UserBan.query.filter(UserBan.user_id==user_id).first()
+ assert user_banned is not None
+ assert user_banned.expiration_date is None
+ assert user_banned.reason == u'Because I said so'
+
+ response, context = self.do_post({},
+ url=ban_url)
+
+ assert response.status == "302 FOUND"
+ user_banned = UserBan.query.filter(UserBan.user_id==user_id).first()
+ assert user_banned is None
+