Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
code.vt.edu will be down for maintenance from 0530-0630 EDT Wednesday, March 26th
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
902f8646
Unverified
Commit
902f8646
authored
4 years ago
by
julianajlk
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Update FPD holdback function call order (#24074)
REV-1153
parent
9929b529
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
openedx/features/discounts/applicability.py
+6
-4
6 additions, 4 deletions
openedx/features/discounts/applicability.py
openedx/features/discounts/tests/test_applicability.py
+6
-4
6 additions, 4 deletions
openedx/features/discounts/tests/test_applicability.py
with
12 additions
and
8 deletions
openedx/features/discounts/applicability.py
+
6
−
4
View file @
902f8646
...
...
@@ -96,9 +96,6 @@ def can_receive_discount(user, course, discount_expiration_date=None):
return
False
# TODO: Add additional conditions to return False here
# Turn holdback on
if
_is_in_holdback
(
user
):
return
False
# Check if discount has expired
if
not
discount_expiration_date
:
...
...
@@ -139,12 +136,17 @@ def can_receive_discount(user, course, discount_expiration_date=None):
if
is_enterprise_learner
(
user
):
return
False
# Turn holdback on
if
_is_in_holdback_and_bucket
(
user
):
return
False
return
True
def
_is_in_holdback
(
user
):
def
_is_in_holdback
_and_bucket
(
user
):
"""
Return whether the specified user is in the first-purchase-discount holdback group.
This will also stable bucket the user.
"""
if
datetime
(
2020
,
8
,
1
,
tzinfo
=
pytz
.
UTC
)
<=
datetime
.
now
(
tz
=
pytz
.
UTC
):
return
False
...
...
This diff is collapsed.
Click to expand it.
openedx/features/discounts/tests/test_applicability.py
+
6
−
4
View file @
902f8646
...
...
@@ -23,7 +23,7 @@ from student.tests.factories import CourseEnrollmentFactory, UserFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
..applicability
import
DISCOUNT_APPLICABILITY_FLAG
,
_is_in_holdback
,
can_receive_discount
from
..applicability
import
DISCOUNT_APPLICABILITY_FLAG
,
_is_in_holdback
_and_bucket
,
can_receive_discount
@ddt.ddt
...
...
@@ -44,7 +44,9 @@ class TestApplicability(ModuleStoreTestCase):
user
=
self
.
user
,
experiment_id
=
REV1008_EXPERIMENT_ID
,
key
=
str
(
self
.
course
),
value
=
now_time
)
holdback_patcher
=
patch
(
'
openedx.features.discounts.applicability._is_in_holdback
'
,
return_value
=
False
)
holdback_patcher
=
patch
(
'
openedx.features.discounts.applicability._is_in_holdback_and_bucket
'
,
return_value
=
False
)
self
.
mock_holdback
=
holdback_patcher
.
start
()
self
.
addCleanup
(
holdback_patcher
.
stop
)
...
...
@@ -165,7 +167,7 @@ class TestApplicability(ModuleStoreTestCase):
@ddt.unpack
def
test_holdback_group_ids
(
self
,
group_number
,
in_holdback
):
with
patch
(
'
openedx.features.discounts.applicability.stable_bucketing_hash_group
'
,
return_value
=
group_number
):
assert
_is_in_holdback
(
self
.
user
)
==
in_holdback
assert
_is_in_holdback
_and_bucket
(
self
.
user
)
==
in_holdback
def
test_holdback_expiry
(
self
):
with
patch
(
'
openedx.features.discounts.applicability.stable_bucketing_hash_group
'
,
return_value
=
0
):
...
...
@@ -173,4 +175,4 @@ class TestApplicability(ModuleStoreTestCase):
'
openedx.features.discounts.applicability.datetime
'
,
Mock
(
now
=
Mock
(
return_value
=
datetime
(
2020
,
8
,
1
,
0
,
1
,
tzinfo
=
pytz
.
UTC
)),
wraps
=
datetime
),
):
assert
not
_is_in_holdback
(
self
.
user
)
assert
not
_is_in_holdback
_and_bucket
(
self
.
user
)
This diff is collapsed.
Click to expand it.
Preview
0%
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