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
37df16bc
Commit
37df16bc
authored
May 17, 2016
by
Clinton Blackburn
Committed by
Peter Fogg
May 19, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ignoring invalid data from the Drupal API
ECOM-4414
parent
8307996b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
8 deletions
+21
-8
course_discovery/apps/course_metadata/data_loaders.py
+5
-0
course_discovery/apps/course_metadata/tests/test_data_loaders.py
+16
-8
No files found.
course_discovery/apps/course_metadata/data_loaders.py
View file @
37df16bc
...
@@ -271,6 +271,11 @@ class DrupalApiDataLoader(AbstractDataLoader):
...
@@ -271,6 +271,11 @@ class DrupalApiDataLoader(AbstractDataLoader):
logger
.
info
(
'Retrieved
%
d course runs...'
,
len
(
data
))
logger
.
info
(
'Retrieved
%
d course runs...'
,
len
(
data
))
for
body
in
data
:
for
body
in
data
:
# NOTE (CCB): Some of the entries are empty arrays. We will fix this on the Drupal side of things
# later (ECOM-4493). For now, ignore them.
if
not
body
:
continue
cleaned_body
=
self
.
clean_strings
(
body
)
cleaned_body
=
self
.
clean_strings
(
body
)
course
=
self
.
update_course
(
cleaned_body
)
course
=
self
.
update_course
(
cleaned_body
)
self
.
update_course_run
(
course
,
cleaned_body
)
self
.
update_course_run
(
course
,
cleaned_body
)
...
...
course_discovery/apps/course_metadata/tests/test_data_loaders.py
View file @
37df16bc
...
@@ -462,7 +462,8 @@ class DrupalApiDataLoaderTests(DataLoaderTestMixin, TestCase):
...
@@ -462,7 +462,8 @@ class DrupalApiDataLoaderTests(DataLoaderTestMixin, TestCase):
def
mock_api
(
self
):
def
mock_api
(
self
):
"""Mock out the Drupal API. Returns a list of mocked-out course runs."""
"""Mock out the Drupal API. Returns a list of mocked-out course runs."""
body
=
{
body
=
{
'items'
:
[{
'items'
:
[
{
'title'
:
self
.
EXISTING_COURSE_AND_RUN_DATA
[
0
][
'title'
],
'title'
:
self
.
EXISTING_COURSE_AND_RUN_DATA
[
0
][
'title'
],
'level'
:
{
'level'
:
{
'title'
:
'Introductory'
,
'title'
:
'Introductory'
,
...
@@ -474,7 +475,7 @@ class DrupalApiDataLoaderTests(DataLoaderTestMixin, TestCase):
...
@@ -474,7 +475,7 @@ class DrupalApiDataLoaderTests(DataLoaderTestMixin, TestCase):
}],
}],
'current_language'
:
self
.
EXISTING_COURSE_AND_RUN_DATA
[
0
][
'current_language'
],
'current_language'
:
self
.
EXISTING_COURSE_AND_RUN_DATA
[
0
][
'current_language'
],
'subtitle'
:
'Learn about Bread'
,
'subtitle'
:
'Learn about Bread'
,
'description'
:
'<p><b>Bread</b>
is a <a href="/wiki/Staple_food" title="Staple food">staple food</a>.'
,
'description'
:
'<p>Bread
is a <a href="/wiki/Staple_food" title="Staple food">staple food</a>.'
,
'sponsors'
:
[{
'sponsors'
:
[{
'uuid'
:
'abc123'
,
'uuid'
:
'abc123'
,
'title'
:
'Tatte'
,
'title'
:
'Tatte'
,
...
@@ -496,7 +497,8 @@ class DrupalApiDataLoaderTests(DataLoaderTestMixin, TestCase):
...
@@ -496,7 +497,8 @@ class DrupalApiDataLoaderTests(DataLoaderTestMixin, TestCase):
'title'
:
'King'
'title'
:
'King'
}
}
}]
}]
},
{
},
{
'title'
:
self
.
EXISTING_COURSE_AND_RUN_DATA
[
1
][
'title'
],
'title'
:
self
.
EXISTING_COURSE_AND_RUN_DATA
[
1
][
'title'
],
'level'
:
{
'level'
:
{
'title'
:
'Intermediate'
,
'title'
:
'Intermediate'
,
...
@@ -518,7 +520,8 @@ class DrupalApiDataLoaderTests(DataLoaderTestMixin, TestCase):
...
@@ -518,7 +520,8 @@ class DrupalApiDataLoaderTests(DataLoaderTestMixin, TestCase):
'title'
:
'Tester'
'title'
:
'Tester'
}
}
}]
}]
},
{
# Create a course which exists in LMS/Otto, but without course runs
},
{
# Create a course which exists in LMS/Otto, but without course runs
'title'
:
self
.
EXISTING_COURSE
[
'title'
],
'title'
:
self
.
EXISTING_COURSE
[
'title'
],
'level'
:
{
'level'
:
{
'title'
:
'Advanced'
,
'title'
:
'Advanced'
,
...
@@ -543,7 +546,8 @@ class DrupalApiDataLoaderTests(DataLoaderTestMixin, TestCase):
...
@@ -543,7 +546,8 @@ class DrupalApiDataLoaderTests(DataLoaderTestMixin, TestCase):
'uri'
:
'sponsor/faux'
'uri'
:
'sponsor/faux'
}],
}],
'staff'
:
[],
'staff'
:
[],
},
{
# Create a fake course run which doesn't exist in LMS/Otto
},
{
# Create a fake course run which doesn't exist in LMS/Otto
'title'
:
'A partial course'
,
'title'
:
'A partial course'
,
'level'
:
{
'level'
:
{
'title'
:
'Advanced'
,
'title'
:
'Advanced'
,
...
@@ -558,7 +562,10 @@ class DrupalApiDataLoaderTests(DataLoaderTestMixin, TestCase):
...
@@ -558,7 +562,10 @@ class DrupalApiDataLoaderTests(DataLoaderTestMixin, TestCase):
'description'
:
'what is real?'
,
'description'
:
'what is real?'
,
'sponsors'
:
[],
'sponsors'
:
[],
'staff'
:
[],
'staff'
:
[],
}]
},
# NOTE (CCB): Some of the entries are empty arrays. Remove this as part of ECOM-4493.
[],
]
}
}
responses
.
add
(
responses
.
add
(
...
@@ -633,8 +640,9 @@ class DrupalApiDataLoaderTests(DataLoaderTestMixin, TestCase):
...
@@ -633,8 +640,9 @@ class DrupalApiDataLoaderTests(DataLoaderTestMixin, TestCase):
def
test_ingest
(
self
):
def
test_ingest
(
self
):
"""Verify the data loader ingests data from Drupal."""
"""Verify the data loader ingests data from Drupal."""
data
=
self
.
mock_api
()
data
=
self
.
mock_api
()
# The faked course should not be loaded from Drupal
# Neither the faked course, nor the empty array, should not be loaded from Drupal.
loaded_data
=
data
[:
-
2
]
# Change this back to -2 as part of ECOM-4493.
loaded_data
=
data
[:
-
3
]
self
.
loader
.
ingest
()
self
.
loader
.
ingest
()
...
...
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