Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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
edx-platform
Commits
7d8fb739
Commit
7d8fb739
authored
Jul 27, 2015
by
jsa
Committed by
Clinton Blackburn
Jul 28, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commerce/api: pass expiration_datetime when updating modes
parent
c2fdf8cb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
2 deletions
+17
-2
lms/djangoapps/commerce/api/v1/models.py
+1
-0
lms/djangoapps/commerce/api/v1/tests/test_views.py
+16
-2
No files found.
lms/djangoapps/commerce/api/v1/models.py
View file @
7d8fb739
...
...
@@ -66,6 +66,7 @@ class Course(object):
merged_mode
.
min_price
=
posted_mode
.
min_price
merged_mode
.
currency
=
posted_mode
.
currency
merged_mode
.
sku
=
posted_mode
.
sku
merged_mode
.
expiration_datetime
=
posted_mode
.
expiration_datetime
merged_modes
.
add
(
merged_mode
)
merged_mode_keys
.
add
(
merged_mode
.
mode_slug
)
...
...
lms/djangoapps/commerce/api/v1/tests/test_views.py
View file @
7d8fb739
""" Commerce API v1 view tests. """
from
datetime
import
datetime
import
json
import
ddt
...
...
@@ -6,6 +7,7 @@ from django.conf import settings
from
django.contrib.auth.models
import
Permission
from
django.core.urlresolvers
import
reverse
from
django.test.utils
import
override_settings
from
rest_framework.utils.encoders
import
JSONEncoder
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
...
...
@@ -31,12 +33,17 @@ class CourseApiViewTestMixin(object):
@staticmethod
def
_serialize_course_mode
(
course_mode
):
""" Serialize a CourseMode to a dict. """
# encode the datetime (if nonempty) using DRF's encoder, simplifying
# equality assertions.
expires
=
course_mode
.
expiration_datetime
if
expires
is
not
None
:
expires
=
JSONEncoder
()
.
default
(
expires
)
return
{
u'name'
:
course_mode
.
mode_slug
,
u'currency'
:
course_mode
.
currency
.
lower
(),
u'price'
:
course_mode
.
min_price
,
u'sku'
:
course_mode
.
sku
,
u'expires'
:
course_mode
.
expiration_datetime
,
u'expires'
:
expires
,
}
...
...
@@ -112,7 +119,14 @@ class CourseRetrieveUpdateViewTests(CourseApiViewTestMixin, ModuleStoreTestCase)
""" Verify the view supports updating a course. """
permission
=
Permission
.
objects
.
get
(
name
=
'Can change course mode'
)
self
.
user
.
user_permissions
.
add
(
permission
)
expected_course_mode
=
CourseMode
(
mode_slug
=
u'verified'
,
min_price
=
200
,
currency
=
u'USD'
,
sku
=
u'ABC123'
)
expiration_datetime
=
datetime
.
now
()
expected_course_mode
=
CourseMode
(
mode_slug
=
u'verified'
,
min_price
=
200
,
currency
=
u'USD'
,
sku
=
u'ABC123'
,
expiration_datetime
=
expiration_datetime
)
expected
=
{
u'id'
:
unicode
(
self
.
course
.
id
),
u'modes'
:
[
self
.
_serialize_course_mode
(
expected_course_mode
)]
...
...
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