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
84f26e86
Commit
84f26e86
authored
Feb 28, 2018
by
Jeff LaJoie
Committed by
Jeff LaJoie
Feb 28, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
LEARNER-4337: Adds in a second seat to tests, and adds check to only compare non-audit course seats
parent
76d86911
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
16 deletions
+50
-16
course_discovery/apps/publisher/tests/test_views.py
+22
-3
course_discovery/apps/publisher/views.py
+28
-13
No files found.
course_discovery/apps/publisher/tests/test_views.py
View file @
84f26e86
...
...
@@ -3011,8 +3011,27 @@ class CourseEditViewTests(SiteMixin, TestCase):
factories
.
CourseRunStateFactory
(
course_run
=
course_run
,
name
=
CourseRunStateChoices
.
Published
)
factories
.
CourseUserRoleFactory
(
course
=
self
.
course
,
role
=
PublisherUserRole
.
Publisher
)
factories
.
CourseUserRoleFactory
(
course
=
self
.
course
,
role
=
PublisherUserRole
.
ProjectCoordinator
)
seat
=
factories
.
SeatFactory
.
create
(
course_run
=
course_run
,
type
=
Seat
.
VERIFIED
,
price
=
2
)
# Test that this saves without seats after resetting this to Seat version
self
.
course
.
version
=
Course
.
SEAT_VERSION
self
.
course
.
save
()
post_data
[
'mode'
]
=
Seat
.
PROFESSIONAL
post_data
[
'price'
]
=
1
response
=
self
.
client
.
post
(
self
.
edit_page_url
,
data
=
post_data
)
self
.
assertRedirects
(
response
,
expected_url
=
reverse
(
'publisher:publisher_course_detail'
,
kwargs
=
{
'pk'
:
self
.
course
.
id
}),
status_code
=
302
,
target_status_code
=
200
)
verified_seat
=
factories
.
SeatFactory
.
create
(
course_run
=
course_run
,
type
=
Seat
.
VERIFIED
,
price
=
2
)
factories
.
SeatFactory
(
course_run
=
course_run
,
type
=
Seat
.
AUDIT
,
price
=
0
)
# Create a seat, do not need to access
self
.
course
.
version
=
Course
.
SEAT_VERSION
self
.
course
.
save
()
post_data
[
'mode'
]
=
''
post_data
[
'price'
]
=
''
response
=
self
.
client
.
post
(
self
.
edit_page_url
,
data
=
post_data
)
# Assert that this saves for a SEAT_VERSION
self
.
assertRedirects
(
...
...
@@ -3037,8 +3056,8 @@ class CourseEditViewTests(SiteMixin, TestCase):
self
.
assertEqual
(
response
.
status_code
,
400
)
# Modify the Course to try and create CourseEntitlement the same as the Course Run and Seat type and price
post_data
[
'mode'
]
=
seat
.
type
post_data
[
'price'
]
=
seat
.
price
# just a number different than what is used in the SeatFactory constructor
post_data
[
'mode'
]
=
verified_
seat
.
type
post_data
[
'price'
]
=
verified_seat
.
price
response
=
self
.
client
.
post
(
self
.
edit_page_url
,
data
=
post_data
)
self
.
assertRedirects
(
response
,
...
...
course_discovery/apps/publisher/views.py
View file @
84f26e86
...
...
@@ -426,21 +426,36 @@ class CourseEditView(mixins.PublisherPermissionMixin, UpdateView):
return
render
(
request
,
self
.
template_name
,
context
)
def
_get_misconfigured_couse_runs
(
self
,
course
,
price
,
mode
):
def
_get_misconfigured_cou
r
se_runs
(
self
,
course
,
price
,
mode
):
misconfigured_seat_type_runs
=
set
()
misconfigured_price_runs
=
set
()
for
course_run
in
course
.
publisher_course_runs
.
filter
(
end__gt
=
datetime
.
now
()):
for
seat
in
course_run
.
seats
.
all
():
if
seat
.
type
!=
mode
:
misconfigured_seat_type_runs
.
add
(
'{type} - {start}'
.
format
(
type
=
seat
.
course_run
.
get_pacing_type_display
(),
start
=
seat
.
course_run
.
start
.
strftime
(
"
%
B
%
d,
%
Y"
)
))
if
seat
.
price
!=
price
:
misconfigured_price_runs
.
add
(
'{type} - {start}'
.
format
(
type
=
seat
.
course_run
.
get_pacing_type_display
(),
start
=
seat
.
course_run
.
start
.
strftime
(
"
%
B
%
d,
%
Y"
)
))
seats
=
course_run
.
seats
.
all
()
type_is_valid
=
True
price_is_valid
=
True
if
seats
:
if
mode
==
Seat
.
VERIFIED
:
# There should be exactly two seats, one verified and one audit
type_is_valid
=
{
Seat
.
AUDIT
,
Seat
.
VERIFIED
}
==
set
(
seat
.
type
for
seat
in
seats
)
verified_seat
=
seats
.
filter
(
type
=
Seat
.
VERIFIED
)
.
first
()
if
verified_seat
:
price_is_valid
=
verified_seat
.
price
==
price
else
:
# There should be exactly one matching seat with the same type/price
type_is_valid
=
len
(
seats
)
==
1
and
seats
[
0
]
.
type
==
mode
price_is_valid
=
seats
[
0
]
.
price
==
price
if
not
type_is_valid
:
misconfigured_seat_type_runs
.
add
(
'{type} - {start}'
.
format
(
type
=
course_run
.
get_pacing_type_display
(),
start
=
course_run
.
start
.
strftime
(
"
%
B
%
d,
%
Y"
)
))
if
not
price_is_valid
:
misconfigured_price_runs
.
add
(
'{type} - {start}'
.
format
(
type
=
course_run
.
get_pacing_type_display
(),
start
=
course_run
.
start
.
strftime
(
"
%
B
%
d,
%
Y"
)
))
return
misconfigured_price_runs
,
misconfigured_seat_type_runs
def
_create_or_update_course_entitlement
(
self
,
course
,
entitlement_form
):
...
...
@@ -485,7 +500,7 @@ class CourseEditView(mixins.PublisherPermissionMixin, UpdateView):
# using entitlements check that there are no misconfigured runs
if
self
.
object
.
version
==
Course
.
SEAT_VERSION
:
if
entitlement_mode
:
type_misconfigurations
,
seat_misconfigurations
=
self
.
_get_misconfigured_couse_runs
(
type_misconfigurations
,
seat_misconfigurations
=
self
.
_get_misconfigured_cou
r
se_runs
(
self
.
object
,
entitlement_price
,
entitlement_mode
)
if
type_misconfigurations
:
...
...
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