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
4783aed9
Commit
4783aed9
authored
5 years ago
by
Emma Green
Browse files
Options
Downloads
Patches
Plain Diff
Enterprise users should not get the first purchase discount.
parent
e7a509fa
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
openedx/features/discounts/applicability.py
+6
-0
6 additions, 0 deletions
openedx/features/discounts/applicability.py
openedx/features/discounts/tests/test_applicability.py
+20
-0
20 additions, 0 deletions
openedx/features/discounts/tests/test_applicability.py
with
26 additions
and
0 deletions
openedx/features/discounts/applicability.py
+
6
−
0
View file @
4783aed9
...
...
@@ -78,6 +78,12 @@ def can_receive_discount(user, course): # pylint: disable=unused-argument
if
CourseEntitlement
.
objects
.
filter
(
user
=
user
).
exists
():
return
False
# We can't import this at Django load time within the openedx tests settings context
from
openedx.features.enterprise_support.utils
import
is_enterprise_learner
# Don't give discount to enterprise users
if
is_enterprise_learner
(
user
):
return
False
# Excute holdback
if
_is_in_holdback
(
user
):
return
False
...
...
This diff is collapsed.
Click to expand it.
openedx/features/discounts/tests/test_applicability.py
+
20
−
0
View file @
4783aed9
...
...
@@ -7,11 +7,13 @@ from datetime import datetime, timedelta
import
ddt
import
pytz
from
django.contrib.sites.models
import
Site
from
django.utils.timezone
import
now
from
mock
import
Mock
,
patch
from
course_modes.models
import
CourseMode
from
course_modes.tests.factories
import
CourseModeFactory
from
enterprise.models
import
EnterpriseCustomer
,
EnterpriseCustomerUser
from
entitlements.tests.factories
import
CourseEntitlementFactory
from
openedx.core.djangoapps.content.course_overviews.models
import
CourseOverview
from
openedx.core.djangoapps.waffle_utils.testutils
import
override_waffle_flag
...
...
@@ -32,6 +34,7 @@ class TestApplicability(ModuleStoreTestCase):
def
setUp
(
self
):
super
(
TestApplicability
,
self
).
setUp
()
self
.
site
,
_
=
Site
.
objects
.
get_or_create
(
domain
=
'
example.com
'
)
self
.
user
=
UserFactory
.
create
()
self
.
course
=
CourseFactory
.
create
(
run
=
'
test
'
,
display_name
=
'
test
'
)
CourseModeFactory
.
create
(
course_id
=
self
.
course
.
id
,
mode_slug
=
'
verified
'
)
...
...
@@ -105,6 +108,23 @@ class TestApplicability(ModuleStoreTestCase):
applicability
=
can_receive_discount
(
user
=
self
.
user
,
course
=
self
.
course
)
assert
applicability
==
(
entitlement_mode
is
None
)
@override_waffle_flag
(
DISCOUNT_APPLICABILITY_FLAG
,
active
=
True
)
def
test_can_receive_discount_false_enterprise
(
self
):
"""
Ensure that enterprise users do not receive the discount.
"""
enterprise_customer
=
EnterpriseCustomer
.
objects
.
create
(
name
=
'
Test EnterpriseCustomer
'
,
site
=
self
.
site
)
EnterpriseCustomerUser
.
objects
.
create
(
user_id
=
self
.
user
.
id
,
enterprise_customer
=
enterprise_customer
)
applicability
=
can_receive_discount
(
user
=
self
.
user
,
course
=
self
.
course
)
self
.
assertEqual
(
applicability
,
False
)
@override_waffle_flag
(
DISCOUNT_APPLICABILITY_FLAG
,
active
=
True
)
def
test_holdback_denies_discount
(
self
):
"""
...
...
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