Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
253 changes: 0 additions & 253 deletions openedx/core/djangoapps/user_api/tests/test_constants.py

This file was deleted.

68 changes: 35 additions & 33 deletions openedx/core/djangoapps/user_authn/views/tests/test_register.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from django.test.client import RequestFactory
from django.test.utils import override_settings
from django.urls import reverse
from django_countries import countries
from openedx_events.testing import OpenEdxEventsTestMixin
from social_django.models import Partial, UserSocialAuth
from testfixtures import LogCapture
Expand Down Expand Up @@ -60,7 +61,6 @@
fake_requested_retirement,
setup_retirement_states, # noqa: F401
)
from openedx.core.djangoapps.user_api.tests.test_constants import SORTED_COUNTRIES
from openedx.core.djangoapps.user_api.tests.test_helpers import TestCaseForm
from openedx.core.djangoapps.user_api.tests.test_views import UserAPITestCase
from openedx.core.djangolib.testing.utils import CacheIsolationTestCase, skip_unless_lms
Expand Down Expand Up @@ -733,22 +733,7 @@ def test_extension_form_fields(self):
def test_register_form_third_party_auth_running_google(self, input_country_code, expected_country_code,
input_username, expected_username):
no_extra_fields_setting = {}
country_options = (
[
{
"name": "--",
"value": "",
"default": False
}
] + [
{
"value": country_code,
"name": str(country_name),
"default": country_code == expected_country_code
}
for country_code, country_name in SORTED_COUNTRIES
]
)
country_options = self._expected_country_options(expected_country_code)

provider = self.configure_google_provider(enabled=True)
with simulate_running_pipeline(
Expand Down Expand Up @@ -1088,22 +1073,7 @@ def test_registration_form_state(self):
)

def test_registration_form_country(self):
country_options = (
[
{
"name": "--",
"value": "",
"default": True
}
] + [
{
"value": country_code,
"name": str(country_name),
"default": False
}
for country_code, country_name in SORTED_COUNTRIES
]
)
country_options = self._expected_country_options()
self._assert_reg_field(
{"country": "required"},
{
Expand Down Expand Up @@ -1859,6 +1829,38 @@ def test_register_autogenerated_duplicate_username(self,
}
)

def _expected_country_options(self, default_code=""):
"""
Build the options the country select is expected to offer: the empty
placeholder followed by every country django-countries knows about,
with `default` set on the one matching default_code.

The options are derived from django_countries.countries rather than
from a hardcoded list so that upstream renames (and our own
COUNTRIES_OVERRIDE entries) don't turn into test failures. What this
asserts is our own behavior: the placeholder comes first, and exactly
one option is marked as the default.

Iterate `countries` directly instead of sorting the names here.
django-countries orders by locale-aware collation, which is not plain
string sort: "Åland Islands" collates as "Aland" and so comes second,
not last.
"""
return [
{
"name": "--",
"value": "",
"default": default_code == ""
}
] + [
{
"value": country_code,
"name": str(country_name),
"default": country_code == default_code
}
for country_code, country_name in countries
]

def _assert_fields_match(self, actual_field, expected_field):
"""
Assert that the actual field and the expected field values match.
Expand Down
6 changes: 3 additions & 3 deletions openedx/core/lib/tests/test_jwt.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import pytest
from freezegun import freeze_time
from jwt.exceptions import ExpiredSignatureError, InvalidSignatureError, MissingRequiredClaimError
from jwt.exceptions import DecodeError, ExpiredSignatureError, InvalidSignatureError, MissingRequiredClaimError

from openedx.core.djangolib.testing.utils import skip_unless_lms
from openedx.core.lib.jwt import _encode_and_sign, create_jwt, unpack_and_verify, unpack_jwt
Expand Down Expand Up @@ -53,7 +53,7 @@ def test_malformed_token(self):
token = create_jwt(test_user_id, test_timeout, test_claims, test_now)
token = token + "a"

with pytest.raises(InvalidSignatureError):
with pytest.raises(DecodeError):
unpack_and_verify(token)


Expand Down Expand Up @@ -84,7 +84,7 @@ def test_malformed_token(self):
token = create_jwt(test_user_id, test_timeout, test_claims, test_now)
token = token + "a"

with pytest.raises(InvalidSignatureError):
with pytest.raises(DecodeError):
unpack_jwt(token, test_user_id, test_now)

def test_unpack_token_with_invalid_user(self):
Expand Down
Loading
Loading