Commit fab8ab61 by Clinton Blackburn

Merge pull request #114 from edx/clintonb/data-loader-language-fix

Resolved language warnings
parents 0d9df68e 340567d9
...@@ -371,6 +371,12 @@ class DrupalApiDataLoader(AbstractDataLoader): ...@@ -371,6 +371,12 @@ class DrupalApiDataLoader(AbstractDataLoader):
iso_code = body['current_language'] iso_code = body['current_language']
if iso_code is None: if iso_code is None:
return None return None
# NOTE (CCB): Default to U.S. English for edx.org to avoid spewing
# unnecessary warnings.
if iso_code == 'en':
iso_code = 'en-us'
try: try:
return LanguageTag.objects.get(code=iso_code) return LanguageTag.objects.get(code=iso_code)
except LanguageTag.DoesNotExist: except LanguageTag.DoesNotExist:
......
...@@ -26,10 +26,11 @@ from course_discovery.apps.course_metadata.tests.factories import ( ...@@ -26,10 +26,11 @@ from course_discovery.apps.course_metadata.tests.factories import (
ACCESS_TOKEN = 'secret' ACCESS_TOKEN = 'secret'
ACCESS_TOKEN_TYPE = 'Bearer' ACCESS_TOKEN_TYPE = 'Bearer'
COURSES_API_URL = 'https://lms.example.com/api/courses/v1' COURSES_API_URL = 'https://lms.example.com/api/courses/v1'
ORGANIZATIONS_API_URL = 'https://lms.example.com/api/organizations/v0'
MARKETING_API_URL = 'https://example.com/api/catalog/v2/'
ECOMMERCE_API_URL = 'https://ecommerce.example.com/api/v2' ECOMMERCE_API_URL = 'https://ecommerce.example.com/api/v2'
ENGLISH_LANGUAGE_TAG = LanguageTag(code='en-us', name='English - United States')
JSON = 'application/json' JSON = 'application/json'
MARKETING_API_URL = 'https://example.com/api/catalog/v2/'
ORGANIZATIONS_API_URL = 'https://lms.example.com/api/organizations/v0'
class AbstractDataLoaderTest(TestCase): class AbstractDataLoaderTest(TestCase):
...@@ -681,7 +682,8 @@ class DrupalApiDataLoaderTests(DataLoaderTestMixin, TestCase): ...@@ -681,7 +682,8 @@ class DrupalApiDataLoaderTests(DataLoaderTestMixin, TestCase):
@ddt.data( @ddt.data(
({'current_language': ''}, None), ({'current_language': ''}, None),
({'current_language': 'not-real'}, None), ({'current_language': 'not-real'}, None),
({'current_language': 'en-us'}, LanguageTag(code='en-us', name='English - United States')), ({'current_language': 'en-us'}, ENGLISH_LANGUAGE_TAG),
({'current_language': 'en'}, ENGLISH_LANGUAGE_TAG),
({'current_language': None}, None), ({'current_language': None}, None),
) )
@ddt.unpack @ddt.unpack
......
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