Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
ecommerce
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
ecommerce
Commits
bbba590c
Commit
bbba590c
authored
Jul 31, 2015
by
Renzo Lucioni
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #237 from edx/renzo/avoid-ghost-skus
Never save seats if LMS publication is not able to complete
parents
3c8846f7
026a5cea
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
13 deletions
+15
-13
ecommerce/extensions/api/serializers.py
+9
-4
ecommerce/extensions/api/v2/tests/views/test_publication.py
+6
-9
No files found.
ecommerce/extensions/api/serializers.py
View file @
bbba590c
...
@@ -226,19 +226,24 @@ class AtomicPublicationSerializer(serializers.Serializer): # pylint: disable=ab
...
@@ -226,19 +226,24 @@ class AtomicPublicationSerializer(serializers.Serializer): # pylint: disable=ab
u'An error occurred while publishing [{course_id}] to LMS. '
u'An error occurred while publishing [{course_id}] to LMS. '
u'No data has been saved or published.'
u'No data has been saved or published.'
)
.
format
(
course_id
=
course_id
)
)
.
format
(
course_id
=
course_id
)
raise
Exception
(
message
)
raise
Exception
(
message
)
else
:
else
:
message
=
(
message
=
(
u'Course [{course_id}] was not published to LMS '
u'Course [{course_id}] was not published to LMS '
u'because the switch [publish_course_modes_to_lms] is disabled. '
u'because the switch [publish_course_modes_to_lms] is disabled. '
u'
Data has been saved, but not publish
ed.'
u'
To avoid ghost SKUs, data has not been sav
ed.'
)
.
format
(
course_id
=
course_id
)
)
.
format
(
course_id
=
course_id
)
logger
.
info
(
message
)
r
eturn
created
,
None
,
message
r
aise
Exception
(
message
)
except
Exception
as
e
:
# pylint: disable=broad-except
except
Exception
as
e
:
# pylint: disable=broad-except
logger
.
exception
(
u'Failed to save and publish [
%
s]: [
%
s]'
,
course_id
,
e
.
message
)
logger
.
exception
(
u'Failed to save and publish [
%
s]: [
%
s]'
,
course_id
,
e
.
message
)
return
False
,
e
,
e
.
message
user_message
=
(
u'Publication of course data to the LMS failed. '
u'To avoid checkout failures, this data has NOT been saved.'
)
return
False
,
e
,
user_message
def
_flatten
(
self
,
attrs
):
def
_flatten
(
self
,
attrs
):
"""Transform a list of attribute names and values into a dictionary keyed on the names."""
"""Transform a list of attribute names and values into a dictionary keyed on the names."""
...
...
ecommerce/extensions/api/v2/tests/views/test_publication.py
View file @
bbba590c
...
@@ -155,12 +155,11 @@ class AtomicPublicationTests(CourseCatalogTestMixin, UserMixin, TestCase):
...
@@ -155,12 +155,11 @@ class AtomicPublicationTests(CourseCatalogTestMixin, UserMixin, TestCase):
def
test_create
(
self
):
def
test_create
(
self
):
"""Verify that a Course and associated products can be created and published."""
"""Verify that a Course and associated products can be created and published."""
# If LMS publication is disabled, the view should return a
201 and data should
be saved.
# If LMS publication is disabled, the view should return a
500 and data should NOT
be saved.
response
=
self
.
client
.
post
(
self
.
create_path
,
json
.
dumps
(
self
.
data
),
JSON_CONTENT_TYPE
)
response
=
self
.
client
.
post
(
self
.
create_path
,
json
.
dumps
(
self
.
data
),
JSON_CONTENT_TYPE
)
self
.
assertEqual
(
response
.
status_code
,
201
)
self
.
assertEqual
(
response
.
status_code
,
500
)
self
.
_assert_course_saved
(
self
.
course_id
,
expected
=
self
.
data
)
self
.
_assert_course_saved
(
self
.
course_id
)
self
.
_purge_courses
()
self
.
_toggle_publication
(
True
)
self
.
_toggle_publication
(
True
)
with
mock
.
patch
.
object
(
LMSPublisher
,
'publish'
)
as
mock_publish
:
with
mock
.
patch
.
object
(
LMSPublisher
,
'publish'
)
as
mock_publish
:
...
@@ -181,13 +180,11 @@ class AtomicPublicationTests(CourseCatalogTestMixin, UserMixin, TestCase):
...
@@ -181,13 +180,11 @@ class AtomicPublicationTests(CourseCatalogTestMixin, UserMixin, TestCase):
self
.
_purge_courses
(
recreate
=
True
)
self
.
_purge_courses
(
recreate
=
True
)
updated_data
=
self
.
_update_data
()
updated_data
=
self
.
_update_data
()
# If LMS publication is disabled, the view should return a
200 and data should
be saved.
# If LMS publication is disabled, the view should return a
500 and data should NOT
be saved.
response
=
self
.
client
.
put
(
self
.
update_path
,
json
.
dumps
(
updated_data
),
JSON_CONTENT_TYPE
)
response
=
self
.
client
.
put
(
self
.
update_path
,
json
.
dumps
(
updated_data
),
JSON_CONTENT_TYPE
)
self
.
assertEqual
(
response
.
status_code
,
2
00
)
self
.
assertEqual
(
response
.
status_code
,
5
00
)
self
.
_assert_course_saved
(
self
.
course_id
,
expected
=
updated_
data
)
self
.
_assert_course_saved
(
self
.
course_id
,
expected
=
self
.
data
)
self
.
_purge_courses
(
recreate
=
True
)
updated_data
=
self
.
_update_data
()
self
.
_toggle_publication
(
True
)
self
.
_toggle_publication
(
True
)
with
mock
.
patch
.
object
(
LMSPublisher
,
'publish'
)
as
mock_publish
:
with
mock
.
patch
.
object
(
LMSPublisher
,
'publish'
)
as
mock_publish
:
...
...
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