From b9b8560adcbdd1afd58b35efe75f8cfe3dbd59e6 Mon Sep 17 00:00:00 2001 From: Attiya Ishaque Date: Fri, 13 Jan 2023 18:20:05 +0500 Subject: [PATCH] fix: fix the tests in test_register file (#31523) --- .../user_authn/views/registration_form.py | 44 +++++++++---------- .../user_authn/views/tests/test_register.py | 21 --------- 2 files changed, 22 insertions(+), 43 deletions(-) diff --git a/openedx/core/djangoapps/user_authn/views/registration_form.py b/openedx/core/djangoapps/user_authn/views/registration_form.py index 0321250a34..e503265d1e 100644 --- a/openedx/core/djangoapps/user_authn/views/registration_form.py +++ b/openedx/core/djangoapps/user_authn/views/registration_form.py @@ -315,28 +315,6 @@ class RegistrationFormFactory: DEFAULT_FIELDS = ["email", "name", "username", "password"] - EXTRA_FIELDS = [ - "confirm_email", - "first_name", - "last_name", - "city", - "state", - "country", - "gender", - "year_of_birth", - "level_of_education", - "company", - "job_title", - "title", - "mailing_address", - "goals", - "honor_code", - "terms_of_service", - "profession", - "specialty", - "marketing_emails_opt_in", - ] - def _is_field_visible(self, field_name): """Check whether a field is visible based on Django settings. """ return self._extra_fields_setting.get(field_name) in ["required", "optional", "optional-exposed"] @@ -351,6 +329,28 @@ class RegistrationFormFactory: def __init__(self): + self.EXTRA_FIELDS = [ + "confirm_email", + "first_name", + "last_name", + "city", + "state", + "country", + "gender", + "year_of_birth", + "level_of_education", + "company", + "job_title", + "title", + "mailing_address", + "goals", + "honor_code", + "terms_of_service", + "profession", + "specialty", + "marketing_emails_opt_in", + ] + if settings.ENABLE_COPPA_COMPLIANCE and 'year_of_birth' in self.EXTRA_FIELDS: self.EXTRA_FIELDS.remove('year_of_birth') diff --git a/openedx/core/djangoapps/user_authn/views/tests/test_register.py b/openedx/core/djangoapps/user_authn/views/tests/test_register.py index cd5000ed59..22f2985199 100644 --- a/openedx/core/djangoapps/user_authn/views/tests/test_register.py +++ b/openedx/core/djangoapps/user_authn/views/tests/test_register.py @@ -916,9 +916,6 @@ class RegistrationViewTestV1( ) def test_register_form_year_of_birth(self): - # WARNING: This test may fail locally due to a test order issue. If it passes on Github, - # but is failing for you locally, you probably did not cause the problem if you - # are not working on registration. See VAN-900 for more details. this_year = datetime.now(UTC).year year_options = ( [ @@ -1305,9 +1302,6 @@ class RegistrationViewTestV1( REGISTRATION_EXTENSION_FORM='openedx.core.djangoapps.user_api.tests.test_helpers.TestCaseForm', ) def test_field_order(self): - # WARNING: This test may fail locally due to a test order issue. If it passes on Github, - # but is failing for you locally, you probably did not cause the problem if you - # are not working on registration. See VAN-900 for more details. response = self.client.get(self.url) self.assertHttpOK(response) @@ -1370,9 +1364,6 @@ class RegistrationViewTestV1( ], ) def test_field_order_override(self): - # WARNING: This test may fail locally due to a test order issue. If it passes on Github, - # but is failing for you locally, you probably did not cause the problem if you - # are not working on registration. See VAN-900 for more details. response = self.client.get(self.url) self.assertHttpOK(response) @@ -1414,9 +1405,6 @@ class RegistrationViewTestV1( ], ) def test_field_order_invalid_override(self): - # WARNING: This test may fail locally due to a test order issue. If it passes on Github, - # but is failing for you locally, you probably did not cause the problem if you - # are not working on registration. See VAN-900 for more details. response = self.client.get(self.url) self.assertHttpOK(response) @@ -2024,9 +2012,6 @@ class RegistrationViewTestV2(RegistrationViewTestV1): ], ) def test_field_order_invalid_override(self): - # WARNING: This test may fail locally due to a test order issue. If it passes on Github, - # but is failing for you locally, you probably did not cause the problem if you - # are not working on registration. See VAN-900 for more details. response = self.client.get(self.url) self.assertHttpOK(response) @@ -2091,9 +2076,6 @@ class RegistrationViewTestV2(RegistrationViewTestV1): ], ) def test_field_order_override(self): - # WARNING: This test may fail locally due to a test order issue. If it passes on Github, - # but is failing for you locally, you probably did not cause the problem if you - # are not working on registration. See VAN-900 for more details. response = self.client.get(self.url) self.assertHttpOK(response) @@ -2122,9 +2104,6 @@ class RegistrationViewTestV2(RegistrationViewTestV1): REGISTRATION_EXTENSION_FORM='openedx.core.djangoapps.user_api.tests.test_helpers.TestCaseForm', ) def test_field_order(self): - # WARNING: This test may fail locally due to a test order issue. If it passes on Github, - # but is failing for you locally, you probably did not cause the problem if you - # are not working on registration. See VAN-900 for more details. response = self.client.get(self.url) self.assertHttpOK(response)