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
97855bb4
Commit
97855bb4
authored
Apr 19, 2013
by
Vasyl Nakvasiuk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add test_good_ajax_request for WordCloud
parent
cb1d3a30
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
6 deletions
+29
-6
common/lib/xmodule/xmodule/tests/test_logic.py
+29
-6
No files found.
common/lib/xmodule/xmodule/tests/test_logic.py
View file @
97855bb4
...
...
@@ -8,6 +8,15 @@ from xmodule.conditional_module import ConditionalDescriptor
from
xmodule.word_cloud_module
import
WordCloudDescriptor
class
PostData
:
"""Class which emulate postdata."""
def
__init__
(
self
,
dict_data
):
self
.
dict_data
=
dict_data
def
getlist
(
self
,
key
):
return
self
.
dict_data
.
get
(
key
)
class
LogicTest
(
unittest
.
TestCase
):
"""Base class for testing xmodule logic."""
descriptor_class
=
None
...
...
@@ -75,19 +84,33 @@ class WordCloudModuleTest(LogicTest):
raw_model_data
=
{
'all_words'
:
{
'cat'
:
10
,
'dog'
:
5
,
'mom'
:
1
,
'dad'
:
2
},
'top_words'
:
{
'cat'
:
10
,
'dog'
:
5
,
'dad'
:
2
},
'submitted'
:
False
,
'student_words'
:
[
'mom'
,
'dad'
,
'cat'
]
'submitted'
:
False
}
def
test_bad_ajax_request
(
self
):
# TODO: move top global test.
# TODO: move top global test.
Formalize all Xmodule errors.
response
=
self
.
ajax_request
(
'bad_dispatch'
,
{})
self
.
assertDictEqual
(
response
,
{
'status'
:
'fail'
,
'error'
:
'Unknown Command!'
})
# TODO
# def test_good_ajax_request(self):
# response = self.ajax_request('submit', {})
def
test_good_ajax_request
(
self
):
post_data
=
PostData
({
'student_words[]'
:
[
'cat'
,
'cat'
,
'dog'
,
'sun'
]})
response
=
self
.
ajax_request
(
'submit'
,
post_data
)
self
.
assertEqual
(
response
[
'status'
],
'success'
)
self
.
assertEqual
(
response
[
'submitted'
],
True
)
self
.
assertEqual
(
response
[
'total_count'
],
22
)
self
.
assertDictEqual
(
response
[
'student_words'
],
{
'sun'
:
1
,
'dog'
:
6
,
'cat'
:
12
}
)
self
.
assertListEqual
(
response
[
'top_words'
],
[{
'text'
:
'dad'
,
'size'
:
2
},
{
'text'
:
'sun'
,
'size'
:
1
},
{
'text'
:
'dog'
,
'size'
:
6
},
{
'text'
:
'mom'
,
'size'
:
1
},
{
'text'
:
'cat'
,
'size'
:
12
}]
)
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