Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
DoneXBlock
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
DoneXBlock
Commits
1971b9c3
Commit
1971b9c3
authored
Jun 07, 2017
by
Piotr Mitros
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tests
parent
857bf365
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
104 additions
and
2 deletions
+104
-2
done/tests/__init__.py
+0
-0
done/tests/test_done.py
+100
-0
setup.py
+4
-2
No files found.
done/tests/__init__.py
0 → 100644
View file @
1971b9c3
done/tests/test_done.py
0 → 100644
View file @
1971b9c3
'''
Tests for the DoneXBlock.
This is nice as a simple example of the edX XBlock test framework.
'''
from
openedx.tests.xblock_integration.xblock_testcase
import
XBlockTestCase
# pylint: disable=abstract-method
class
TestDone
(
XBlockTestCase
):
"""
Simple tests for the completion XBlock. We set up a page with two
of the block, make sure the page renders, toggle them a few times,
make sure they've toggled, and reconfirm the page renders.
"""
olx_scenarios
=
{
# Currently not used
"two_done_block_test_case"
:
"""<vertical>
<done urlname="done0"/>
<done urlname="done1"/>
</vertical>"""
}
# This is a stop-gap until we can load OLX and/or OLX from
# normal workbench scenarios
test_configuration
=
[
{
"urlname"
:
"two_done_block_test_case"
,
"olx"
:
olx_scenarios
[
0
],
"xblocks"
:
[
# Stopgap until we handle OLX
{
'blocktype'
:
'done'
,
'urlname'
:
'done_0'
},
{
'blocktype'
:
'done'
,
'urlname'
:
'done_1'
}
]
}
]
def
toggle_button
(
self
,
block
,
data
,
desired_state
):
"""
Make an AJAX call to the XBlock, and assert the state is as
desired.
"""
resp
=
self
.
ajax
(
'toggle_button'
,
block
,
data
)
self
.
assertEqual
(
resp
.
status_code
,
200
)
# pylint: disable=no-member
self
.
assertEqual
(
resp
.
data
,
{
"state"
:
desired_state
})
# pylint: disable=unused-argument
def
check_response
(
self
,
block_urlname
,
rendering
):
"""
Confirm that we have a 200 response code (no server error)
In the future, visual diff test the response.
"""
response
=
self
.
render_block
(
block_urlname
)
self
.
assertEqual
(
response
.
status_code
,
200
)
# To do: Below method needs to be implemented
#self.assertXBlockScreenshot(block_urlname, rendering)
def
test_done
(
self
):
"""
Walk through a few toggles. Make sure the blocks don't mix up
state between them, initial state is correct, and final state
is correct.
"""
# We confirm we don't have errors rendering the student view
self
.
check_response
(
'done_0'
,
'done-unmarked'
)
self
.
check_response
(
'done_1'
,
'done-unmarked'
)
# We confirm the block is initially false
self
.
toggle_button
(
'done_0'
,
{},
False
)
self
.
reset_published_events
()
self
.
toggle_button
(
'done_1'
,
{},
False
)
self
.
assert_no_events_published
(
"edx.done.toggled"
)
# We confirm we can toggle state both ways
self
.
reset_published_events
()
self
.
toggle_button
(
'done_0'
,
{
'done'
:
True
},
True
)
self
.
assert_event_published
(
'edx.done.toggled'
,
event_fields
=
{
"done"
:
True
})
self
.
reset_published_events
()
self
.
toggle_button
(
'done_1'
,
{
'done'
:
False
},
False
)
self
.
assert_event_published
(
'edx.done.toggled'
,
event_fields
=
{
"done"
:
False
})
self
.
toggle_button
(
'done_0'
,
{
'done'
:
False
},
False
)
self
.
assert_grade
(
0
)
self
.
toggle_button
(
'done_1'
,
{
'done'
:
True
},
True
)
self
.
assert_grade
(
1
)
# We confirm state sticks around
self
.
toggle_button
(
'done_0'
,
{},
False
)
self
.
toggle_button
(
'done_1'
,
{},
True
)
# And confirm we render correctly
self
.
check_response
(
'done_0'
,
'done-unmarked'
)
self
.
check_response
(
'done_1'
,
'done-marked'
)
setup.py
View file @
1971b9c3
...
@@ -27,7 +27,10 @@ setup(
...
@@ -27,7 +27,10 @@ setup(
entry_points
=
{
entry_points
=
{
'xblock.v1'
:
[
'xblock.v1'
:
[
'done = done:DoneXBlock'
,
'done = done:DoneXBlock'
,
],
'xblock.test.v0'
:
[
'done = done.tests:TestDone'
]
]
},
},
package_data
=
package_data
(
"done"
,
"static"
),
package_data
=
package_data
(
"done"
,
"static"
),
)
)
\ No newline at end of file
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