chore: update tests according to is_register_page check (#30986)
This commit is contained in:
@@ -3570,9 +3570,9 @@ REGISTRATION_FIELD_ORDER = [
|
||||
"city",
|
||||
"state",
|
||||
"country",
|
||||
"gender",
|
||||
"year_of_birth",
|
||||
"level_of_education",
|
||||
"gender",
|
||||
"specialty",
|
||||
"profession",
|
||||
"company",
|
||||
|
||||
@@ -96,7 +96,7 @@ class RegistrationFieldsContext(APIView):
|
||||
return (field in self.user_profile_fields or field in ["terms_of_service", "honor_code"] or
|
||||
field in configuration_helpers.get_value('extended_profile_fields', []))
|
||||
|
||||
def _get_fields(self):
|
||||
def get_fields(self):
|
||||
"""
|
||||
Returns the required or optional fields configured in REGISTRATION_EXTRA_FIELDS settings.
|
||||
"""
|
||||
|
||||
@@ -240,7 +240,8 @@ class MFEContextViewTest(ThirdPartyAuthTestMixin, APITestCase):
|
||||
'error_message': '',
|
||||
}
|
||||
}
|
||||
response = self.client.get(self.url)
|
||||
self.query_params.update({'is_register_page': True})
|
||||
response = self.client.get(self.url, self.query_params)
|
||||
assert response.status_code == status.HTTP_200_OK
|
||||
assert response.data['optional_fields']['fields'] == expected_response
|
||||
|
||||
@@ -274,7 +275,8 @@ class MFEContextViewTest(ThirdPartyAuthTestMixin, APITestCase):
|
||||
'type': 'text',
|
||||
}
|
||||
}
|
||||
response = self.client.get(self.url)
|
||||
self.query_params.update({'is_register_page': True})
|
||||
response = self.client.get(self.url, self.query_params)
|
||||
assert response.status_code == status.HTTP_200_OK
|
||||
assert response.data['optional_fields']['fields'] == expected_response
|
||||
|
||||
@@ -292,7 +294,8 @@ class MFEContextViewTest(ThirdPartyAuthTestMixin, APITestCase):
|
||||
"""
|
||||
Test that order of optional fields
|
||||
"""
|
||||
response = self.client.get(self.url)
|
||||
self.query_params.update({'is_register_page': True})
|
||||
response = self.client.get(self.url, self.query_params)
|
||||
assert response.status_code == status.HTTP_200_OK
|
||||
assert list(response.data['optional_fields']['fields'].keys()) == ['specialty', 'goals']
|
||||
|
||||
|
||||
@@ -60,17 +60,17 @@ class MFEContextView(APIView):
|
||||
|
||||
if settings.ENABLE_DYNAMIC_REGISTRATION_FIELDS:
|
||||
if is_register_page:
|
||||
registration_fields = RegistrationFieldsContext()._get_fields() # pylint: disable=protected-access
|
||||
registration_fields = RegistrationFieldsContext().get_fields()
|
||||
context['registration_fields'].update({
|
||||
'fields': registration_fields,
|
||||
'extended_profile': configuration_helpers.get_value('extended_profile_fields', []),
|
||||
})
|
||||
optional_fields = RegistrationFieldsContext('optional')._get_fields() # pylint: disable=protected-access
|
||||
if optional_fields:
|
||||
context['optional_fields'].update({
|
||||
'fields': optional_fields,
|
||||
'extended_profile': configuration_helpers.get_value('extended_profile_fields', []),
|
||||
})
|
||||
optional_fields = RegistrationFieldsContext('optional').get_fields()
|
||||
if optional_fields:
|
||||
context['optional_fields'].update({
|
||||
'fields': optional_fields,
|
||||
'extended_profile': configuration_helpers.get_value('extended_profile_fields', []),
|
||||
})
|
||||
|
||||
return Response(
|
||||
status=status.HTTP_200_OK,
|
||||
|
||||
Reference in New Issue
Block a user