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
ece64cf2
Commit
ece64cf2
authored
9 years ago
by
Awais Jibran
Browse files
Options
Downloads
Plain Diff
Merge pull request #9097 from edx/aj/plat-760-fix-flaky-test_import_timestamp
Fixed Flaky test
parents
f33b451e
bceb2ae3
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
common/test/acceptance/pages/studio/import_export.py
+13
-0
13 additions, 0 deletions
common/test/acceptance/pages/studio/import_export.py
common/test/acceptance/tests/studio/test_import_export.py
+24
-17
24 additions, 17 deletions
common/test/acceptance/tests/studio/test_import_export.py
with
37 additions
and
17 deletions
common/test/acceptance/pages/studio/import_export.py
+
13
−
0
View file @
ece64cf2
"""
Import/Export pages.
"""
import
time
from
datetime
import
datetime
from
bok_choy.promise
import
EmptyPromise
import
os
import
re
import
requests
from
.utils
import
click_css
from
.library
import
LibraryPage
from
.course_page
import
CoursePage
...
...
@@ -129,6 +133,15 @@ class ImportMixin(object):
return
re
.
match
(
r
'
\(([^ ]+).+?(\d{2}:\d{2})
'
,
string
).
groups
()
@property
def
parsed_timestamp
(
self
):
"""
Return python datetime object from the parsed timestamp tuple (date, time)
"""
timestamp
=
"
{0} {1}
"
.
format
(
*
self
.
timestamp
)
formatted_timestamp
=
time
.
strptime
(
timestamp
,
"
%m/%d/%Y %H:%M
"
)
return
datetime
.
fromtimestamp
(
time
.
mktime
(
formatted_timestamp
))
def
is_browser_on_page
(
self
):
"""
Verify this is the export page
...
...
This diff is collapsed.
Click to expand it.
common/test/acceptance/tests/studio/test_import_export.py
+
24
−
17
View file @
ece64cf2
"""
Acceptance tests for the Import and Export pages
"""
from
datetime
import
datetime
from
abc
import
abstractmethod
from
bok_choy.promise
import
EmptyPromise
from
datetime
import
datetime
from
flaky
import
flaky
from
.base_studio_test
import
StudioLibraryTest
,
StudioCourseTest
from
...fixtures.course
import
XBlockFixtureDesc
...
...
@@ -186,7 +186,6 @@ class ImportTestMixin(object):
self
.
import_page
.
upload_tarball
(
self
.
tarball_name
)
self
.
import_page
.
wait_for_upload
()
@flaky
# TODO make this not flaky. See TNL-2886.
def
test_import_timestamp
(
self
):
"""
Scenario: I perform a course / library import
...
...
@@ -194,25 +193,33 @@ class ImportTestMixin(object):
And if I refresh the page, the timestamp is still displayed
"""
self
.
assertFalse
(
self
.
import_page
.
is_timestamp_visible
())
# Get the time when the import has started.
# import_page timestamp is in (MM/DD/YYYY at HH:mm) so replacing (second, microsecond) to
# keep the comparison consistent
upload_start_time
=
datetime
.
utcnow
().
replace
(
microsecond
=
0
,
second
=
0
)
self
.
import_page
.
upload_tarball
(
self
.
tarball_name
)
self
.
import_page
.
wait_for_upload
()
utc_now
=
datetime
.
utcnow
()
import_date
,
import_time
=
self
.
import_page
.
timestamp
# Get the time when the import has finished.
# import_page timestamp is in (MM/DD/YYYY at HH:mm) so replacing (second, microsecond) to
# keep the comparison consistent
upload_finish_time
=
datetime
.
utcnow
().
replace
(
microsecond
=
0
,
second
=
0
)
import_timestamp
=
self
.
import_page
.
parsed_timestamp
self
.
import_page
.
wait_for_timestamp_visible
()
# Flaky pattern:
#
This test failed because the utc_now and import dat
e
# might be assigned at different times. The error message
#
was "'18:30' != u'18:29'", meaning it uploaded it at 18:29, then
,
#
when we assigned utc_now, the time had crossed the minute to
# 18:30.
# Possible fixes:
# * Mock utcnow somehow.
# * Check for the date and time within a certain range, rather than
#
doing a string comparison.
self
.
assertEqual
(
utc_now
.
strftime
(
'
%m/%d/%Y
'
),
import_date
)
self
.
assertEqual
(
utc_now
.
strftime
(
'
%H:%M
'
),
import_time
)
#
Verify that 'import_timestamp' is between start and finish upload tim
e
self
.
assertLessEqual
(
upload_start_time
,
import_timestamp
,
"
Course import timestamp should be upload_start_time <= import_timestamp <= upload_end_time
"
)
self
.
assertGreaterEqual
(
upload_finish_time
,
import_timestamp
,
"
Course import timestamp should be upload_start_time <= import_timestamp <= upload_end_time
"
)
self
.
import_page
.
visit
()
self
.
import_page
.
wait_for_tasks
(
completed
=
True
)
...
...
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