aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/tests
diff options
context:
space:
mode:
Diffstat (limited to 'mediagoblin/tests')
-rw-r--r--mediagoblin/tests/test_edit.py8
-rw-r--r--mediagoblin/tests/test_notifications.py53
2 files changed, 57 insertions, 4 deletions
diff --git a/mediagoblin/tests/test_edit.py b/mediagoblin/tests/test_edit.py
index d70d0478..c43a3a42 100644
--- a/mediagoblin/tests/test_edit.py
+++ b/mediagoblin/tests/test_edit.py
@@ -147,26 +147,26 @@ class TestUserEdit(object):
# Test email already in db
template.clear_test_template_context()
test_app.post(
- '/edit/account/', {
+ '/edit/email/', {
'new_email': 'chris@example.com',
'password': 'toast'})
# Check form errors
context = template.TEMPLATE_TEST_CONTEXT[
- 'mediagoblin/edit/edit_account.html']
+ 'mediagoblin/edit/change_email.html']
assert context['form'].new_email.errors == [
u'Sorry, a user with that email address already exists.']
# Test successful email change
template.clear_test_template_context()
res = test_app.post(
- '/edit/account/', {
+ '/edit/email/', {
'new_email': 'new@example.com',
'password': 'toast'})
res.follow()
# Correct redirect?
- assert urlparse.urlsplit(res.location)[2] == '/u/chris/'
+ assert urlparse.urlsplit(res.location)[2] == '/edit/account/'
# Make sure we get email verification and try verifying
assert len(mail.EMAIL_TEST_INBOX) == 1
diff --git a/mediagoblin/tests/test_notifications.py b/mediagoblin/tests/test_notifications.py
index d52b8d5a..e075d475 100644
--- a/mediagoblin/tests/test_notifications.py
+++ b/mediagoblin/tests/test_notifications.py
@@ -149,3 +149,56 @@ otherperson@example.com\n\nSGkgb3RoZXJwZXJzb24sCmNocmlzIGNvbW1lbnRlZCBvbiB5b3VyI
# User should not have been notified
assert len(notifications) == 1
+
+ def test_mark_all_comment_notifications_seen(self):
+ """ Test that mark_all_comments_seen works"""
+
+ user = fixture_add_user('otherperson', password='nosreprehto')
+
+ media_entry = fixture_media_entry(uploader=user.id, state=u'processed')
+
+ fixture_comment_subscription(media_entry)
+
+ media_uri_id = '/u/{0}/m/{1}/'.format(user.username,
+ media_entry.id)
+
+ # add 2 comments
+ self.test_app.post(
+ media_uri_id + 'comment/add/',
+ {
+ 'comment_content': u'Test comment #43'
+ }
+ )
+
+ self.test_app.post(
+ media_uri_id + 'comment/add/',
+ {
+ 'comment_content': u'Test comment #44'
+ }
+ )
+
+ notifications = Notification.query.filter_by(
+ user_id=user.id).all()
+
+ assert len(notifications) == 2
+
+ # both comments should not be marked seen
+ assert notifications[0].seen == False
+ assert notifications[1].seen == False
+
+ # login with other user to mark notifications seen
+ self.logout()
+ self.login('otherperson', 'nosreprehto')
+
+ # mark all comment notifications seen
+ res = self.test_app.get('/notifications/comments/mark_all_seen/')
+ res.follow()
+
+ assert urlparse.urlsplit(res.location)[2] == '/'
+
+ notifications = Notification.query.filter_by(
+ user_id=user.id).all()
+
+ # both notifications should be marked seen
+ assert notifications[0].seen == True
+ assert notifications[1].seen == True