Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
bceb2ae3
Commit
bceb2ae3
authored
Jul 28, 2015
by
Awais Jibran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed Flaky test (TestLibraryImport.test_import_timestamp)
PLAT-760
parent
bee837be
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
17 deletions
+37
-17
common/test/acceptance/pages/studio/import_export.py
+13
-0
common/test/acceptance/tests/studio/test_import_export.py
+24
-17
No files found.
common/test/acceptance/pages/studio/import_export.py
View file @
bceb2ae3
"""
"""
Import/Export pages.
Import/Export pages.
"""
"""
import
time
from
datetime
import
datetime
from
bok_choy.promise
import
EmptyPromise
from
bok_choy.promise
import
EmptyPromise
import
os
import
os
import
re
import
re
import
requests
import
requests
from
.utils
import
click_css
from
.utils
import
click_css
from
.library
import
LibraryPage
from
.library
import
LibraryPage
from
.course_page
import
CoursePage
from
.course_page
import
CoursePage
...
@@ -129,6 +133,15 @@ class ImportMixin(object):
...
@@ -129,6 +133,15 @@ class ImportMixin(object):
return
re
.
match
(
r'\(([^ ]+).+?(\d{2}:\d{2})'
,
string
)
.
groups
()
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
):
def
is_browser_on_page
(
self
):
"""
"""
Verify this is the export page
Verify this is the export page
...
...
common/test/acceptance/tests/studio/test_import_export.py
View file @
bceb2ae3
"""
"""
Acceptance tests for the Import and Export pages
Acceptance tests for the Import and Export pages
"""
"""
from
datetime
import
datetime
from
abc
import
abstractmethod
from
abc
import
abstractmethod
from
bok_choy.promise
import
EmptyPromise
from
bok_choy.promise
import
EmptyPromise
from
datetime
import
datetime
from
flaky
import
flaky
from
.base_studio_test
import
StudioLibraryTest
,
StudioCourseTest
from
.base_studio_test
import
StudioLibraryTest
,
StudioCourseTest
from
...fixtures.course
import
XBlockFixtureDesc
from
...fixtures.course
import
XBlockFixtureDesc
...
@@ -186,7 +186,6 @@ class ImportTestMixin(object):
...
@@ -186,7 +186,6 @@ class ImportTestMixin(object):
self
.
import_page
.
upload_tarball
(
self
.
tarball_name
)
self
.
import_page
.
upload_tarball
(
self
.
tarball_name
)
self
.
import_page
.
wait_for_upload
()
self
.
import_page
.
wait_for_upload
()
@flaky
# TODO make this not flaky. See TNL-2886.
def
test_import_timestamp
(
self
):
def
test_import_timestamp
(
self
):
"""
"""
Scenario: I perform a course / library import
Scenario: I perform a course / library import
...
@@ -194,25 +193,33 @@ class ImportTestMixin(object):
...
@@ -194,25 +193,33 @@ class ImportTestMixin(object):
And if I refresh the page, the timestamp is still displayed
And if I refresh the page, the timestamp is still displayed
"""
"""
self
.
assertFalse
(
self
.
import_page
.
is_timestamp_visible
())
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
.
upload_tarball
(
self
.
tarball_name
)
self
.
import_page
.
wait_for_upload
()
self
.
import_page
.
wait_for_upload
()
utc_now
=
datetime
.
utcnow
()
# Get the time when the import has finished.
import_date
,
import_time
=
self
.
import_page
.
timestamp
# 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
()
self
.
import_page
.
wait_for_timestamp_visible
()
# Flaky pattern:
#
This test failed because the utc_now and import dat
e
#
Verify that 'import_timestamp' is between start and finish upload tim
e
# might be assigned at different times. The error message
self
.
assertLessEqual
(
# was "'18:30' != u'18:29'", meaning it uploaded it at 18:29, then
,
upload_start_time
,
# when we assigned utc_now, the time had crossed the minute to
import_timestamp
,
# 18:30.
"Course import timestamp should be upload_start_time <= import_timestamp <= upload_end_time"
# Possible fixes:
)
# * Mock utcnow somehow.
self
.
assertGreaterEqual
(
# * Check for the date and time within a certain range, rather than
upload_finish_time
,
# doing a string comparison.
import_timestamp
,
self
.
assertEqual
(
utc_now
.
strftime
(
'
%
m/
%
d/
%
Y'
),
import_date
)
"Course import timestamp should be upload_start_time <= import_timestamp <= upload_end_time"
self
.
assertEqual
(
utc_now
.
strftime
(
'
%
H:
%
M'
),
import_time
)
)
self
.
import_page
.
visit
()
self
.
import_page
.
visit
()
self
.
import_page
.
wait_for_tasks
(
completed
=
True
)
self
.
import_page
.
wait_for_tasks
(
completed
=
True
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment