Commit 0d91e61e by Julia Hansbrough Committed by e0d

Added flag for lms-specific functionality

Studio doesn't do email changes, thus has no email reset template; thus, we must disable password/email-reset related tests when running with studio settings
parent f351b050
...@@ -171,4 +171,4 @@ FEATURES['STUDIO_NPS_SURVEY'] = False ...@@ -171,4 +171,4 @@ FEATURES['STUDIO_NPS_SURVEY'] = False
FEATURES['ENABLE_SERVICE_STATUS'] = True FEATURES['ENABLE_SERVICE_STATUS'] = True
# This is to disable a test under the common directory that will not pass when run under CMS # This is to disable a test under the common directory that will not pass when run under CMS
FEATURES['DISABLE_PASSWORD_RESET_EMAIL_TEST'] = True FEATURES['DISABLE_RESET_EMAIL_TEST'] = True
import json import json
import django.db import django.db
import unittest
from student.tests.factories import UserFactory, RegistrationFactory, PendingEmailChangeFactory from student.tests.factories import UserFactory, RegistrationFactory, PendingEmailChangeFactory
from student.views import reactivation_email_for_user, change_email_request, confirm_email_change from student.views import reactivation_email_for_user, change_email_request, confirm_email_change
...@@ -13,6 +14,7 @@ from django.conf import settings ...@@ -13,6 +14,7 @@ from django.conf import settings
from nose.plugins.skip import SkipTest from nose.plugins.skip import SkipTest
from edxmako.shortcuts import render_to_string from edxmako.shortcuts import render_to_string
from util.request import safe_get_host from util.request import safe_get_host
from textwrap import dedent
class TestException(Exception): class TestException(Exception):
...@@ -264,6 +266,9 @@ class EmailChangeConfirmationTests(EmailTestMixin, TransactionTestCase): ...@@ -264,6 +266,9 @@ class EmailChangeConfirmationTests(EmailTestMixin, TransactionTestCase):
self.check_confirm_email_change('email_exists.html', {}) self.check_confirm_email_change('email_exists.html', {})
self.assertFailedBeforeEmailing(email_user) self.assertFailedBeforeEmailing(email_user)
@unittest.skipIf(settings.FEATURES.get('DISABLE_RESET_EMAIL_TEST', False),
dedent("""Skipping Test because CMS has not provided necessary templates for email reset.
If LMS tests print this message, that needs to be fixed."""))
def test_old_email_fails(self, email_user): def test_old_email_fails(self, email_user):
email_user.side_effect = [Exception, None] email_user.side_effect = [Exception, None]
self.check_confirm_email_change('email_change_failed.html', { self.check_confirm_email_change('email_change_failed.html', {
...@@ -272,6 +277,9 @@ class EmailChangeConfirmationTests(EmailTestMixin, TransactionTestCase): ...@@ -272,6 +277,9 @@ class EmailChangeConfirmationTests(EmailTestMixin, TransactionTestCase):
self.assertRolledBack() self.assertRolledBack()
self.assertChangeEmailSent(email_user) self.assertChangeEmailSent(email_user)
@unittest.skipIf(settings.FEATURES.get('DISABLE_RESET_EMAIL_TEST', False),
dedent("""Skipping Test because CMS has not provided necessary templates for email reset.
If LMS tests print this message, that needs to be fixed."""))
def test_new_email_fails(self, email_user): def test_new_email_fails(self, email_user):
email_user.side_effect = [None, Exception] email_user.side_effect = [None, Exception]
self.check_confirm_email_change('email_change_failed.html', { self.check_confirm_email_change('email_change_failed.html', {
...@@ -280,6 +288,9 @@ class EmailChangeConfirmationTests(EmailTestMixin, TransactionTestCase): ...@@ -280,6 +288,9 @@ class EmailChangeConfirmationTests(EmailTestMixin, TransactionTestCase):
self.assertRolledBack() self.assertRolledBack()
self.assertChangeEmailSent(email_user) self.assertChangeEmailSent(email_user)
@unittest.skipIf(settings.FEATURES.get('DISABLE_RESET_EMAIL_TEST', False),
dedent("""Skipping Test because CMS has not provided necessary templates for email reset.
If LMS tests print this message, that needs to be fixed."""))
def test_successful_email_change(self, email_user): def test_successful_email_change(self, email_user):
self.check_confirm_email_change('email_change_successful.html', { self.check_confirm_email_change('email_change_successful.html', {
'old_email': self.user.email, 'old_email': self.user.email,
......
...@@ -82,7 +82,7 @@ class ResetPasswordTests(TestCase): ...@@ -82,7 +82,7 @@ class ResetPasswordTests(TestCase):
self.assertEquals(bad_email_resp.content, json.dumps({'success': True, self.assertEquals(bad_email_resp.content, json.dumps({'success': True,
'value': "('registration/password_reset_done.html', [])"})) 'value': "('registration/password_reset_done.html', [])"}))
@unittest.skipUnless(not settings.FEATURES.get('DISABLE_PASSWORD_RESET_EMAIL_TEST', False), @unittest.skipIf(settings.FEATURES.get('DISABLE_RESET_EMAIL_TEST', False),
dedent("""Skipping Test because CMS has not provided necessary templates for password reset. dedent("""Skipping Test because CMS has not provided necessary templates for password reset.
If LMS tests print this message, that needs to be fixed.""")) If LMS tests print this message, that needs to be fixed."""))
@patch('django.core.mail.send_mail') @patch('django.core.mail.send_mail')
......
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