Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
35324a73
Commit
35324a73
authored
7 years ago
by
Albert St. Aubin
Browse files
Options
Downloads
Patches
Plain Diff
Moved to a try catch block
parent
e8a3077b
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
common/djangoapps/entitlements/tests/test_utils.py
+16
-7
16 additions, 7 deletions
common/djangoapps/entitlements/tests/test_utils.py
common/djangoapps/entitlements/utils.py
+7
-3
7 additions, 3 deletions
common/djangoapps/entitlements/utils.py
with
23 additions
and
10 deletions
common/djangoapps/entitlements/tests/test_utils.py
+
16
−
7
View file @
35324a73
...
...
@@ -3,6 +3,7 @@ Test entitlements utilities
"""
from
datetime
import
timedelta
from
opaque_keys.edx.keys
import
CourseKey
from
django.conf
import
settings
from
django.utils.timezone
import
now
...
...
@@ -20,13 +21,13 @@ if settings.ROOT_URLCONF == 'lms.urls':
@skip_unless_lms
class
TestCourseRunFul
l
fillableForEntitlement
(
ModuleStoreTestCase
):
class
TestCourseRunFulfillableForEntitlement
(
ModuleStoreTestCase
):
"""
Tests for the utility function is_course_run_entitlement_fulfillable
"""
def
setUp
(
self
):
super
(
TestCourseRunFul
l
fillableForEntitlement
,
self
).
setUp
()
super
(
TestCourseRunFulfillableForEntitlement
,
self
).
setUp
()
self
.
user
=
UserFactory
(
is_staff
=
True
)
self
.
client
.
login
(
username
=
self
.
user
.
username
,
password
=
TEST_PASSWORD
)
...
...
@@ -54,7 +55,7 @@ class TestCourseRunFullfillableForEntitlement(ModuleStoreTestCase):
)
return
course_overview
def
test_course_run_ful
l
fillble
(
self
):
def
test_course_run_fulfill
a
ble
(
self
):
course_overview
=
self
.
create_course
(
start_from_now
=-
2
,
end_from_now
=
2
,
...
...
@@ -66,7 +67,15 @@ class TestCourseRunFullfillableForEntitlement(ModuleStoreTestCase):
assert
is_course_run_entitlement_fulfillable
(
course_overview
.
id
,
entitlement
)
def
test_course_run_not_fullfillable_run_ended
(
self
):
def
test_course_run_missing_overview_not_fulfillable
(
self
):
entitlement
=
CourseEntitlementFactory
.
create
(
mode
=
CourseMode
.
VERIFIED
)
assert
not
is_course_run_entitlement_fulfillable
(
CourseKey
.
from_string
(
'
course-v1:edx+FakeCourse+3T2017
'
),
entitlement
)
def
test_course_run_not_fulfillable_run_ended
(
self
):
course_overview
=
self
.
create_course
(
start_from_now
=-
3
,
end_from_now
=-
1
,
...
...
@@ -78,7 +87,7 @@ class TestCourseRunFullfillableForEntitlement(ModuleStoreTestCase):
assert
not
is_course_run_entitlement_fulfillable
(
course_overview
.
id
,
entitlement
)
def
test_course_run_not_ful
l
fillable_enroll_period_ended
(
self
):
def
test_course_run_not_fulfillable_enroll_period_ended
(
self
):
course_overview
=
self
.
create_course
(
start_from_now
=-
3
,
end_from_now
=
2
,
...
...
@@ -90,7 +99,7 @@ class TestCourseRunFullfillableForEntitlement(ModuleStoreTestCase):
assert
not
is_course_run_entitlement_fulfillable
(
course_overview
.
id
,
entitlement
)
def
test_course_run_ful
l
fillable_user_enrolled
(
self
):
def
test_course_run_fulfillable_user_enrolled
(
self
):
course_overview
=
self
.
create_course
(
start_from_now
=-
3
,
end_from_now
=
2
,
...
...
@@ -104,7 +113,7 @@ class TestCourseRunFullfillableForEntitlement(ModuleStoreTestCase):
assert
is_course_run_entitlement_fulfillable
(
course_overview
.
id
,
entitlement
)
def
test_course_run_not_ful
l
fillable_upgrade_ended
(
self
):
def
test_course_run_not_fulfillable_upgrade_ended
(
self
):
course_overview
=
self
.
create_course
(
start_from_now
=-
3
,
end_from_now
=
2
,
...
...
This diff is collapsed.
Click to expand it.
common/djangoapps/entitlements/utils.py
+
7
−
3
View file @
35324a73
"""
Utility methods for the entitlement application.
"""
import
logging
from
django.utils
import
timezone
...
...
@@ -24,9 +28,9 @@ def is_course_run_entitlement_fulfillable(course_run_key, entitlement, compare_d
Returns:
bool: True if the Course Run is fullfillable for the CourseEntitlement.
"""
course_overview
=
CourseOverview
.
get_from_id
(
course_run_key
)
if
no
t
c
ourse
_o
verview
:
try
:
course_overview
=
CourseOverview
.
get_from_id
(
course_run_key
)
excep
t
C
ourse
O
verview
.
DoesNotExist
:
log
.
error
((
'
There is no CourseOverview entry available for {course_run_id},
'
'
course run cannot be applied to entitlement
'
).
format
(
course_run_id
=
str
(
course_run_key
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment