Commit 790328df by Greg Price

Add acceptance test for one-click unsubscribe page

parent 47b51e93
...@@ -129,6 +129,13 @@ def should_have_link_with_id_and_text(step, link_id, text): ...@@ -129,6 +129,13 @@ def should_have_link_with_id_and_text(step, link_id, text):
assert_equals(link.text, text) assert_equals(link.text, text)
@step(r'should see a link to "([^"]*)" with the text "([^"]*)"$')
def should_have_link_with_path_and_text(step, path, text):
link = world.browser.find_link_by_text(text)
assert len(link) > 0
assert_equals(link.first["href"], django_url(path))
@step(r'should( not)? see "(.*)" (?:somewhere|anywhere) (?:in|on) (?:the|this) page') @step(r'should( not)? see "(.*)" (?:somewhere|anywhere) (?:in|on) (?:the|this) page')
def should_see_in_the_page(step, doesnt_appear, text): def should_see_in_the_page(step, doesnt_appear, text):
if doesnt_appear: if doesnt_appear:
......
Feature: One-click unsubscribe
As a user with notifications enabled
I want to be able to unsubscribe from notifications
Scenario: Unsubscribe when not logged in
Given I am an edX user
And I am not logged in
And I have notifications enabled
When I access my unsubscribe url
Then my notifications should be disabled
And I should see "Unsubscribe Successful!" somewhere on the page
And I should see "Click here to return to your dashboard" somewhere on the page
And I should see a link to "/dashboard" with the text "here"
Scenario: Unsubscribe when logged in
Given I am a logged in user
And I have notifications enabled
When I access my unsubscribe url
Then my notifications should be disabled
And I should see "Unsubscribe Successful!" somewhere on the page
And I should see "Click here to return to your dashboard" somewhere on the page
And I should see a link to "/dashboard" with the text "here"
from django.contrib.auth.models import User
from lettuce import step, world
from notification_prefs import NOTIFICATION_PREF_KEY
from user_api.models import UserPreference
USERNAME = "robot"
UNSUB_TOKEN = "av9E-14sAP1bVBRCPbrTHQ=="
@step(u"I have notifications enabled")
def enable_notifications(step_):
user = User.objects.get(username=USERNAME)
UserPreference.objects.create(user=user, key=NOTIFICATION_PREF_KEY, value=UNSUB_TOKEN)
@step(u"I access my unsubscribe url")
def access_unsubscribe_url(step_):
world.visit("/notification_prefs/unsubscribe/{0}/".format(UNSUB_TOKEN))
@step(u"my notifications should be disabled")
def notifications_should_be_disabled(step_):
user = User.objects.get(username=USERNAME)
assert not UserPreference.objects.filter(user=user, key=NOTIFICATION_PREF_KEY).exists()
...@@ -79,6 +79,10 @@ XQUEUE_INTERFACE = { ...@@ -79,6 +79,10 @@ XQUEUE_INTERFACE = {
# acceptance tests. This makes them faster and more reliable # acceptance tests. This makes them faster and more reliable
MITX_FEATURES['STUB_VIDEO_FOR_TESTING'] = True MITX_FEATURES['STUB_VIDEO_FOR_TESTING'] = True
# Forums are disabled in test.py to speed up unit tests, but we do not have
# per-test control for acceptance tests
MITX_FEATURES['ENABLE_DISCUSSION_SERVICE'] = True
# Include the lettuce app for acceptance testing, including the 'harvest' django-admin command # Include the lettuce app for acceptance testing, including the 'harvest' django-admin command
INSTALLED_APPS += ('lettuce.django',) INSTALLED_APPS += ('lettuce.django',)
LETTUCE_APPS = ('courseware',) LETTUCE_APPS = ('courseware',)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment