Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
problem-builder
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
OpenEdx
problem-builder
Commits
7e4ab4bc
Commit
7e4ab4bc
authored
Jun 02, 2015
by
Sven Marnach
Committed by
Jonathan Piacenti
Jun 19, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add basic integration test for the data export view.
parent
5ad49d93
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
85 additions
and
1 deletions
+85
-1
problem_builder/data_export.py
+1
-1
problem_builder/tests/integration/test_data_export.py
+84
-0
No files found.
problem_builder/data_export.py
View file @
7e4ab4bc
...
@@ -106,7 +106,7 @@ class DataExportBlock(XBlock):
...
@@ -106,7 +106,7 @@ class DataExportBlock(XBlock):
return
None
return
None
from
instructor_task.models
import
ReportStore
from
instructor_task.models
import
ReportStore
report_store
=
ReportStore
.
from_config
(
config_name
=
'GRADES_DOWNLOAD'
)
report_store
=
ReportStore
.
from_config
(
config_name
=
'GRADES_DOWNLOAD'
)
course_key
=
self
.
scope_ids
.
usage_id
.
course_key
course_key
=
getattr
(
self
.
scope_ids
.
usage_id
,
'course_key'
,
None
)
return
dict
(
report_store
.
links_for
(
course_key
))
.
get
(
self
.
last_export_result
[
'report_filename'
])
return
dict
(
report_store
.
links_for
(
course_key
))
.
get
(
self
.
last_export_result
[
'report_filename'
])
def
_get_status
(
self
):
def
_get_status
(
self
):
...
...
problem_builder/tests/integration/test_data_export.py
0 → 100644
View file @
7e4ab4bc
# -*- coding: utf-8 -*-
import
time
import
pdb
import
sys
from
mock
import
patch
,
Mock
from
xblockutils.base_test
import
SeleniumXBlockTest
from
problem_builder.data_export
import
DataExportBlock
class
MockTasksModule
(
object
):
"""Mock for the tasks module, which can only be meaningfully import in the LMS."""
def
__init__
(
self
,
successful
=
True
):
self
.
export_data
=
Mock
()
async_result
=
self
.
export_data
.
async_result
async_result
.
ready
.
side_effect
=
[
False
,
False
,
True
,
True
]
async_result
.
id
=
"export_task_id"
async_result
.
successful
.
return_value
=
successful
if
successful
:
async_result
.
result
=
dict
(
error
=
None
,
report_filename
=
'/file/report.csv'
,
start_timestamp
=
time
.
time
(),
generation_time_s
=
23.4
,
)
else
:
async_result
.
result
=
'error'
self
.
export_data
.
AsyncResult
.
return_value
=
async_result
self
.
export_data
.
delay
.
return_value
=
async_result
class
MockInstructorTaskModelsModule
(
object
):
def
__init__
(
self
):
self
.
ReportStore
=
Mock
()
self
.
ReportStore
.
from_config
.
return_value
.
links_for
.
return_value
=
[
(
'/file/report.csv'
,
'/url/report.csv'
)
]
class
DataExportTest
(
SeleniumXBlockTest
):
def
setUp
(
self
):
super
(
DataExportTest
,
self
)
.
setUp
()
self
.
set_scenario_xml
(
"""
<vertical_demo>
<pb-data-export url_name="data_export"/>
</vertical_demo>
"""
)
def
test_students_dont_see_interface
(
self
):
data_export
=
self
.
go_to_view
()
self
.
assertIn
(
'This interface can only be used by course staff.'
,
data_export
.
text
)
@patch.dict
(
'sys.modules'
,
{
'problem_builder.tasks'
:
MockTasksModule
(
successful
=
True
),
'instructor_task'
:
True
,
'instructor_task.models'
:
MockInstructorTaskModelsModule
(),
})
@patch.object
(
DataExportBlock
,
'user_is_staff'
,
Mock
(
return_value
=
True
))
def
test_data_export
(
self
):
data_export
=
self
.
go_to_view
()
start_button
=
data_export
.
find_element_by_class_name
(
'data-export-start'
)
cancel_button
=
data_export
.
find_element_by_class_name
(
'data-export-cancel'
)
download_button
=
data_export
.
find_element_by_class_name
(
'data-export-download'
)
delete_button
=
data_export
.
find_element_by_class_name
(
'data-export-delete'
)
status_area
=
data_export
.
find_element_by_class_name
(
'data-export-status'
)
start_button
.
click
()
self
.
wait_until_hidden
(
start_button
)
self
.
wait_until_visible
(
cancel_button
)
self
.
wait_until_hidden
(
download_button
)
self
.
wait_until_hidden
(
delete_button
)
self
.
assertIn
(
'The report is currently being generated'
,
status_area
.
text
)
self
.
wait_until_visible
(
start_button
)
self
.
wait_until_hidden
(
cancel_button
)
self
.
wait_until_visible
(
download_button
)
self
.
wait_until_visible
(
delete_button
)
self
.
assertIn
(
'A report is available for download.'
,
status_area
.
text
)
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