Skip to content

Commit

Permalink
Merge pull request openedx#461 from Stanford-Online/giulio/remove-dis…
Browse files Browse the repository at this point in the history
…able-cme-reg-tests

remove DISABLE_CME_REGISTRATION_TESTS
  • Loading branch information
caesar2164 committed May 11, 2016
2 parents 8eeb560 + a1e63aa commit 714207b
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 81 deletions.
3 changes: 0 additions & 3 deletions cms/envs/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,6 @@

FEATURES['ENABLE_SERVICE_STATUS'] = True

# This is to disable tests CME Registration tests, under common, that will not pass when run under CMS
FEATURES['DISABLE_CME_REGISTRATION_TESTS'] = True

# Toggles embargo on for testing
FEATURES['EMBARGO'] = True

Expand Down
115 changes: 38 additions & 77 deletions common/djangoapps/cme_registration/tests/registration_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"""

import unittest
from textwrap import dedent
from mock import Mock, patch

from django.conf import settings
Expand Down Expand Up @@ -67,16 +66,14 @@ def setUp(self):
'county_province': 'county_province',
}

@unittest.skipIf(settings.FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False),
dedent("""Skipping Test because the url is not in CMS"""))
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Run only in LMS')
def test_badly_formed_message(self):

url = reverse('create_account')
response = self.client.post(url, {})
self.assertContains(response, '{"field": "username", "value": "Error (401 username). E-mail us.", "success": false}')

@unittest.skipIf(settings.FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False),
dedent("""Skipping Test because the url is not in CMS"""))
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Run only in LMS')
def test_last_name_required(self):

self.post_vars['last_name'] = ''
Expand All @@ -85,8 +82,7 @@ def test_last_name_required(self):

self.assertContains(response, '{"field": "last_name", "value": "Enter your last name", "success": false}')

@unittest.skipIf(settings.FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False),
dedent("""Skipping Test because the url is not in CMS"""))
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Run only in LMS')
def test_first_name_required(self):

self.post_vars['first_name'] = ''
Expand All @@ -95,8 +91,7 @@ def test_first_name_required(self):

self.assertContains(response, '{"field": "first_name", "value": "Enter your first name", "success": false}')

@unittest.skipIf(settings.FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False),
dedent("""Skipping Test because the url is not in CMS"""))
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Run only in LMS')
def test_middle_initial_length(self):

self.post_vars['middle_initial'] = 'ABC'
Expand All @@ -105,8 +100,7 @@ def test_middle_initial_length(self):

self.assertContains(response, '{"field": "middle_initial", "value": "Enter your middle initial as a single character", "success": false}')

@unittest.skipIf(settings.FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False),
dedent("""Skipping Test because the url is not in CMS"""))
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Run only in LMS')
def test_birth_date_required(self):

self.post_vars['birth_date'] = ''
Expand All @@ -115,8 +109,7 @@ def test_birth_date_required(self):

self.assertContains(response, '{"field": "birth_date", "value": "Enter your birth date", "success": false}')

@unittest.skipIf(settings.FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False),
dedent("""Skipping Test because the url is not in CMS"""))
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Run only in LMS')
def test_birth_date_format1(self):

self.post_vars['birth_date'] = '0102'
Expand All @@ -125,8 +118,7 @@ def test_birth_date_format1(self):

self.assertContains(response, '{"field": "birth_date", "value": "Enter your birth date as MM/DD", "success": false}')

@unittest.skipIf(settings.FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False),
dedent("""Skipping Test because the url is not in CMS"""))
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Run only in LMS')
def test_birth_date_format2(self):

self.post_vars['birth_date'] = '14/02'
Expand All @@ -135,8 +127,7 @@ def test_birth_date_format2(self):

self.assertContains(response, '{"field": "birth_date", "value": "month must be in 1..12", "success": false}')

@unittest.skipIf(settings.FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False),
dedent("""Skipping Test because the url is not in CMS"""))
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Run only in LMS')
def test_professional_designation_required(self):

self.post_vars['professional_designation'] = ''
Expand All @@ -145,8 +136,7 @@ def test_professional_designation_required(self):

self.assertContains(response, '{"field": "professional_designation", "value": "Choose your professional designation", "success": false}')

@unittest.skipIf(settings.FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False),
dedent("""Skipping Test because the url is not in CMS"""))
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Run only in LMS')
def test_license_number_required(self):

self.post_vars['professional_designation'] = 'DO'
Expand All @@ -156,8 +146,7 @@ def test_license_number_required(self):

self.assertContains(response, '{"field": "license_number", "value": "Enter your license number", "success": false}')

@unittest.skipIf(settings.FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False),
dedent("""Skipping Test because the url is not in CMS"""))
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Run only in LMS')
def test_license_country_required(self):

self.post_vars['professional_designation'] = 'DO'
Expand All @@ -167,8 +156,7 @@ def test_license_country_required(self):

self.assertContains(response, '{"field": "license_country", "value": "Choose your license country", "success": false}')

@unittest.skipIf(settings.FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False),
dedent("""Skipping Test because the url is not in CMS"""))
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Run only in LMS')
def test_license_state_required(self):

self.post_vars['license_country'] = 'United States'
Expand All @@ -178,8 +166,7 @@ def test_license_state_required(self):

self.assertContains(response, '{"field": "license_state", "value": "Choose your license state", "success": false}')

@unittest.skipIf(settings.FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False),
dedent("""Skipping Test because the url is not in CMS"""))
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Run only in LMS')
def test_physician_status_required(self):

self.post_vars['professional_designation'] = 'DO'
Expand All @@ -189,8 +176,7 @@ def test_physician_status_required(self):

self.assertContains(response, '{"field": "physician_status", "value": "Enter your physician status", "success": false}')

@unittest.skipIf(settings.FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False),
dedent("""Skipping Test because the url is not in CMS"""))
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Run only in LMS')
def test_patient_population_required(self):

self.post_vars['professional_designation'] = 'DO'
Expand All @@ -200,8 +186,7 @@ def test_patient_population_required(self):

self.assertContains(response, '{"field": "patient_population", "value": "Choose your patient population", "success": false}')

@unittest.skipIf(settings.FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False),
dedent("""Skipping Test because the url is not in CMS"""))
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Run only in LMS')
def test_specialty_required(self):

self.post_vars['professional_designation'] = 'DO'
Expand All @@ -211,8 +196,7 @@ def test_specialty_required(self):

self.assertContains(response, '{"field": "specialty", "value": "Choose your specialty", "success": false}')

@unittest.skipIf(settings.FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False),
dedent("""Skipping Test because the url is not in CMS"""))
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Run only in LMS')
def test_sub_specialty_not_required(self):

self.post_vars['sub_specialty'] = ''
Expand All @@ -221,8 +205,7 @@ def test_sub_specialty_not_required(self):

self.assertContains(response, '"success": true')

@unittest.skipIf(settings.FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False),
dedent("""Skipping Test because the url is not in CMS"""))
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Run only in LMS')
def test_affiliation_required(self):

self.post_vars['affiliation'] = ''
Expand All @@ -231,8 +214,7 @@ def test_affiliation_required(self):

self.assertContains(response, '{"field": "affiliation", "value": "Choose your affiliation", "success": false}')

@unittest.skipIf(settings.FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False),
dedent("""Skipping Test because the url is not in CMS"""))
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Run only in LMS')
def test_sub_affiliation_field(self):

self.post_vars['affiliation'] = 'Packard Children\'s Health Alliance'
Expand Down Expand Up @@ -261,8 +243,7 @@ def test_sub_affiliation_field(self):

self.assertContains(response, '{"field": "sub_affiliation", "value": "Enter your Packard Children\'s Health Alliance affiliation", "success": false}')

@unittest.skipIf(settings.FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False),
dedent("""Skipping Test because the url is not in CMS"""))
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Run only in LMS')
def test_sunet_id_required(self):

self.post_vars['affiliation'] = 'Stanford University'
Expand All @@ -272,8 +253,7 @@ def test_sunet_id_required(self):

self.assertContains(response, '{"field": "sunet_id", "value": "Enter your SUNet ID", "success": false}')

@unittest.skipIf(settings.FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False),
dedent("""Skipping Test because the url is not in CMS"""))
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Run only in LMS')
def test_stanford_department_required(self):

self.post_vars['affiliation'] = 'Stanford University'
Expand All @@ -283,8 +263,7 @@ def test_stanford_department_required(self):

self.assertContains(response, '{"field": "stanford_department", "value": "Choose your Stanford department", "success": false}')

@unittest.skipIf(settings.FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False),
dedent("""Skipping Test because the url is not in CMS"""))
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Run only in LMS')
def test_address_1_required(self):

self.post_vars['address_1'] = ''
Expand All @@ -293,8 +272,7 @@ def test_address_1_required(self):

self.assertContains(response, '{"field": "address_1", "value": "Enter your Address 1", "success": false}')

@unittest.skipIf(settings.FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False),
dedent("""Skipping Test because the url is not in CMS"""))
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Run only in LMS')
def test_city_required(self):

self.post_vars['city'] = ''
Expand All @@ -303,8 +281,7 @@ def test_city_required(self):

self.assertContains(response, '{"field": "city", "value": "Enter your city", "success": false}')

@unittest.skipIf(settings.FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False),
dedent("""Skipping Test because the url is not in CMS"""))
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Run only in LMS')
def test_country_required(self):

self.post_vars['country'] = ''
Expand All @@ -313,8 +290,7 @@ def test_country_required(self):

self.assertContains(response, '{"field": "country", "value": "Choose your country", "success": false}')

@unittest.skipIf(settings.FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False),
dedent("""Skipping Test because the url is not in CMS"""))
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Run only in LMS')
def test_state_required(self):

self.post_vars['country'] = 'United States'
Expand All @@ -324,8 +300,7 @@ def test_state_required(self):

self.assertContains(response, '{"field": "state", "value": "Choose your state", "success": false}')

@unittest.skipIf(settings.FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False),
dedent("""Skipping Test because the url is not in CMS"""))
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Run only in LMS')
def test_postal_code_required(self):

self.post_vars['postal_code'] = ''
Expand All @@ -334,8 +309,7 @@ def test_postal_code_required(self):

self.assertContains(response, '{"field": "postal_code", "value": "Enter your postal code", "success": false}')

@unittest.skipIf(settings.FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False),
dedent("""Skipping Test because the url is not in CMS"""))
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Run only in LMS')
def test_specialty_other(self):

self.post_vars['specialty'] = 'Other'
Expand All @@ -345,8 +319,7 @@ def test_specialty_other(self):

self.assertContains(response, '{"field": "specialty", "value": "Enter your specialty.", "success": false}')

@unittest.skipIf(settings.FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False),
dedent("""Skipping Test because the url is not in CMS"""))
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Run only in LMS')
def test_sub_specialty_other(self):

self.post_vars['sub_specialty'] = 'Other'
Expand All @@ -356,8 +329,7 @@ def test_sub_specialty_other(self):

self.assertContains(response, '{"field": "sub_specialty", "value": "Enter your sub-specialty.", "success": false}')

@unittest.skipIf(settings.FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False),
dedent("""Skipping Test because the url is not in CMS"""))
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Run only in LMS')
def test_honor_code_required(self):

del self.post_vars['honor_code']
Expand All @@ -366,8 +338,7 @@ def test_honor_code_required(self):

self.assertContains(response, '{"field": "honor_code", "value": "To enroll, you must follow the honor code.", "success": false}')

@unittest.skipIf(settings.FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False),
dedent("""Skipping Test because the url is not in CMS"""))
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Run only in LMS')
def test_tos_required(self):

del self.post_vars['terms_of_service']
Expand All @@ -376,8 +347,7 @@ def test_tos_required(self):

self.assertContains(response, '{"field": "terms_of_service", "value": "You must accept the terms of service.", "success": false}')

@unittest.skipIf(settings.FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False),
dedent("""Skipping Test because the url is not in CMS"""))
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Run only in LMS')
def test_db_records_created(self):

url = reverse('create_account')
Expand Down Expand Up @@ -428,8 +398,7 @@ def test_db_records_created(self):
user_profile = UserProfile.objects.filter(user=user[0])
self.assertEqual(1, len(user_profile))

@unittest.skipIf(settings.FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False),
dedent("""Skipping Test because the url is not in CMS"""))
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Run only in LMS')
def test_db_records_with_others_created(self):

self.post_vars['specialty'] = 'Other'
Expand Down Expand Up @@ -488,8 +457,7 @@ def test_db_records_with_others_created(self):
user_profile = UserProfile.objects.filter(user=user[0])
self.assertEqual(1, len(user_profile))

@unittest.skipIf(settings.FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False),
dedent("""Skipping Test because the url is not in CMS"""))
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Run only in LMS')
def test_valid_email(self):

self.post_vars['email'] = 'garbage_email_string'
Expand All @@ -498,8 +466,7 @@ def test_valid_email(self):

self.assertContains(response, '{"field": "email", "value": "Valid e-mail is required.", "success": false}')

@unittest.skipIf(settings.FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False),
dedent("""Skipping Test because the url is not in CMS"""))
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Run only in LMS')
def test_valid_username(self):

self.post_vars['username'] = ' $%$%$# '
Expand All @@ -508,8 +475,7 @@ def test_valid_username(self):

self.assertContains(response, '{"field": "username", "value": "Username should only consist of A-Z and 0-9, with no spaces.", "success": false}')

@unittest.skipIf(settings.FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False),
dedent("""Skipping Test because the url is not in CMS"""))
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Run only in LMS')
def test_dupe_username(self):

UserFactory.create(username="student001", email="student001@test.com")
Expand All @@ -520,8 +486,7 @@ def test_dupe_username(self):

self.assertContains(response, '{"field": "username", "value": "An account with the Public Username \'student001\' already exists.", "success": false}')

@unittest.skipIf(settings.FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False),
dedent("""Skipping Test because the url is not in CMS"""))
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Run only in LMS')
def test_register_when_logged_in(self):

user = UserFactory.create(username="student002", email="student002@test.com")
Expand All @@ -531,16 +496,14 @@ def test_register_when_logged_in(self):
response = self.client.post(url, {})
self.assertRedirects(response, reverse('dashboard'), status_code=302)

@unittest.skipIf(settings.FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False),
dedent("""Skipping Test because the url is not in CMS"""))
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Run only in LMS')
def test_register_page_loads(self):

url = reverse('register_user')
response = self.client.post(url, {})
self.assertEqual(response.status_code, 200)

@unittest.skipIf(settings.FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False),
dedent("""Skipping Test because the url is not in CMS"""))
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Run only in LMS')
def test_reroute_activation_email(self):

settings.FEATURES['REROUTE_ACTIVATION_EMAIL'] = 'a@b.edu'
Expand All @@ -552,8 +515,7 @@ def test_reroute_activation_email(self):
self.assertContains(response, '"success": true')

@patch('cme_registration.models.CmeUserProfile.save', Mock(side_effect=Exception()))
@unittest.skipIf(settings.FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False),
dedent("""Skipping Test because the url is not in CMS"""))
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Run only in LMS')
def test_save_profile_exception(self):

url = reverse('create_account')
Expand All @@ -563,8 +525,7 @@ def test_save_profile_exception(self):
self.assertEqual(0, len(cme_user_profile))

@patch('django.contrib.auth.models.User.email_user', Mock(side_effect=Exception()))
@unittest.skipIf(settings.FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False),
dedent("""Skipping Test because the url is not in CMS"""))
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Run only in LMS')
def test_activation_email_exception(self):

url = reverse('create_account')
Expand Down
Loading

0 comments on commit 714207b

Please sign in to comment.