Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
course-discovery
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
course-discovery
Commits
fab8ab61
Commit
fab8ab61
authored
May 24, 2016
by
Clinton Blackburn
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #114 from edx/clintonb/data-loader-language-fix
Resolved language warnings
parents
0d9df68e
340567d9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
3 deletions
+11
-3
course_discovery/apps/course_metadata/data_loaders.py
+6
-0
course_discovery/apps/course_metadata/tests/test_data_loaders.py
+5
-3
No files found.
course_discovery/apps/course_metadata/data_loaders.py
View file @
fab8ab61
...
@@ -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
:
...
...
course_discovery/apps/course_metadata/tests/test_data_loaders.py
View file @
fab8ab61
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment