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
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
cc7bb4df
Unverified
Commit
cc7bb4df
authored
5 years ago
by
Zainab Amir
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #20234 from edx/zamir/PROD_190_fix_SendVerificationExpiryEmail_flaky_tests
Fix Flaky test in TestSendVerificationExpiryEmail
parents
32edefb4
d39b150d
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lms/djangoapps/verify_student/management/commands/tests/test_send_verification_expiry_email.py
+15
-15
15 additions, 15 deletions
...ent/commands/tests/test_send_verification_expiry_email.py
with
15 additions
and
15 deletions
lms/djangoapps/verify_student/management/commands/tests/test_send_verification_expiry_email.py
+
15
−
15
View file @
cc7bb4df
...
...
@@ -2,7 +2,7 @@
Tests for django admin command `send_verification_expiry_email` in the verify_student module
"""
from
datetime
import
datetime
,
timedelta
from
datetime
import
timedelta
import
boto
from
django.conf
import
settings
...
...
@@ -10,8 +10,8 @@ from django.contrib.sites.models import Site
from
django.core
import
mail
from
django.core.management
import
call_command
from
django.test
import
TestCase
from
django.utils.timezone
import
now
from
mock
import
patch
from
pytz
import
UTC
from
student.tests.factories
import
UserFactory
from
testfixtures
import
LogCapture
...
...
@@ -54,13 +54,13 @@ class TestSendVerificationExpiryEmail(MockS3Mixin, TestCase):
user
=
UserFactory
.
create
()
verification_in_range
=
self
.
create_and_submit
(
user
)
verification_in_range
.
status
=
'
approved
'
verification_in_range
.
expiry_date
=
datetime
.
now
(
UTC
)
-
timedelta
(
days
=
1
)
verification_in_range
.
expiry_date
=
now
()
-
timedelta
(
days
=
1
)
verification_in_range
.
save
()
user
=
UserFactory
.
create
()
verification
=
self
.
create_and_submit
(
user
)
verification
.
status
=
'
approved
'
verification
.
expiry_date
=
datetime
.
now
(
UTC
)
-
timedelta
(
days
=
5
)
verification
.
expiry_date
=
now
()
-
timedelta
(
days
=
5
)
verification
.
save
()
call_command
(
'
send_verification_expiry_email
'
,
'
--days-range=2
'
)
...
...
@@ -80,8 +80,8 @@ class TestSendVerificationExpiryEmail(MockS3Mixin, TestCase):
user
=
UserFactory
.
create
()
verification_in_range
=
self
.
create_and_submit
(
user
)
verification_in_range
.
status
=
'
approved
'
verification_in_range
.
expiry_date
=
datetime
.
now
(
UTC
)
-
timedelta
(
days
=
30
)
verification_in_range
.
expiry_email_date
=
datetime
.
now
(
UTC
)
-
timedelta
(
days
=
3
)
verification_in_range
.
expiry_date
=
now
()
-
timedelta
(
days
=
30
)
verification_in_range
.
expiry_email_date
=
now
()
-
timedelta
(
days
=
3
)
verification_in_range
.
save
()
command_args
=
'
--days-range={} --resend-days={}
'
# pylint: disable=unicode-format-string
...
...
@@ -113,12 +113,12 @@ class TestSendVerificationExpiryEmail(MockS3Mixin, TestCase):
user
=
UserFactory
.
create
()
verification
=
self
.
create_and_submit
(
user
)
verification
.
status
=
'
approved
'
verification
.
expiry_date
=
datetime
.
now
(
UTC
)
-
timedelta
(
days
=
1
)
verification
.
expiry_date
=
now
()
-
timedelta
(
days
=
1
)
verification
.
save
()
call_command
(
'
send_verification_expiry_email
'
)
expected_date
=
datetime
.
now
(
UTC
)
expected_date
=
now
()
attempt
=
SoftwareSecurePhotoVerification
.
objects
.
get
(
user_id
=
verification
.
user_id
)
self
.
assertEquals
(
attempt
.
expiry_email_date
.
date
(),
expected_date
.
date
())
self
.
assertEqual
(
len
(
mail
.
outbox
),
1
)
...
...
@@ -131,8 +131,8 @@ class TestSendVerificationExpiryEmail(MockS3Mixin, TestCase):
user
=
UserFactory
.
create
()
verification
=
self
.
create_and_submit
(
user
)
verification
.
status
=
'
approved
'
verification
.
expiry_date
=
datetime
.
now
(
UTC
)
-
timedelta
(
days
=
1
)
verification
.
expiry_email_date
=
datetime
.
now
()
verification
.
expiry_date
=
now
()
-
timedelta
(
days
=
1
)
verification
.
expiry_email_date
=
now
()
verification
.
save
()
call_command
(
'
send_verification_expiry_email
'
)
...
...
@@ -143,13 +143,13 @@ class TestSendVerificationExpiryEmail(MockS3Mixin, TestCase):
"""
Test that if no approved and expired verifications are found the management command terminates gracefully
"""
start_date
=
datetime
.
now
(
UTC
)
-
timedelta
(
days
=
1
)
# using default days
start_date
=
now
()
-
timedelta
(
days
=
1
)
# using default days
with
LogCapture
(
LOGGER_NAME
)
as
logger
:
call_command
(
'
send_verification_expiry_email
'
)
logger
.
check
(
(
LOGGER_NAME
,
'
INFO
'
,
u
"
No approved expired entries found in SoftwareSecurePhotoVerification for the
"
u
"
date range {} - {}
"
.
format
(
start_date
.
date
(),
datetime
.
now
(
UTC
).
date
()))
u
"
date range {} - {}
"
.
format
(
start_date
.
date
(),
now
().
date
()))
)
def
test_dry_run_flag
(
self
):
...
...
@@ -159,10 +159,10 @@ class TestSendVerificationExpiryEmail(MockS3Mixin, TestCase):
user
=
UserFactory
.
create
()
verification
=
self
.
create_and_submit
(
user
)
verification
.
status
=
'
approved
'
verification
.
expiry_date
=
datetime
.
now
(
UTC
)
-
timedelta
(
days
=
1
)
verification
.
expiry_date
=
now
()
-
timedelta
(
days
=
1
)
verification
.
save
()
start_date
=
datetime
.
now
(
UTC
)
-
timedelta
(
days
=
1
)
# using default days
start_date
=
now
()
-
timedelta
(
days
=
1
)
# using default days
count
=
1
with
LogCapture
(
LOGGER_NAME
)
as
logger
:
...
...
@@ -171,7 +171,7 @@ class TestSendVerificationExpiryEmail(MockS3Mixin, TestCase):
(
LOGGER_NAME
,
'
INFO
'
,
u
"
For the date range {} - {}, total Software Secure Photo verification filtered are {}
"
.
format
(
start_date
.
date
(),
datetime
.
now
(
UTC
).
date
(),
count
)
.
format
(
start_date
.
date
(),
now
().
date
(),
count
)
),
(
LOGGER_NAME
,
'
INFO
'
,
...
...
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