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
e1481d93
Commit
e1481d93
authored
May 10, 2013
by
Jay Zoldak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Work on view test for comment client code.
parent
7e636114
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
17 deletions
+56
-17
lms/djangoapps/django_comment_client/base/tests.py
+55
-16
lms/envs/test.py
+1
-1
No files found.
lms/djangoapps/django_comment_client/base/tests.py
View file @
e1481d93
...
...
@@ -2,15 +2,16 @@ import logging
from
django.test.utils
import
override_settings
from
django.test.client
import
Client
from
student.tests.factories
import
UserFactory
,
CourseEnrollmentFactory
from
django.contrib.auth.models
import
User
from
student.tests.factories
import
CourseEnrollmentFactory
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
django.core.urlresolvers
import
reverse
from
django.core.management
import
call_command
from
courseware.tests.tests
import
TEST_DATA_MONGO_MODULESTORE
from
nose.tools
import
assert_true
,
assert_equal
from
mock
import
patch
log
=
logging
.
getLogger
(
__name__
)
...
...
@@ -22,29 +23,67 @@ class ViewsTestCase(ModuleStoreTestCase):
self
.
course
=
CourseFactory
.
create
(
org
=
'MITx'
,
course
=
'999'
,
display_name
=
'Robot Super Course'
)
self
.
course_id
=
self
.
course
.
id
# seed the forums permissions and roles
call_command
(
'seed_permissions_roles'
,
self
.
course_id
)
self
.
student
=
UserFactory
(
username
=
'student'
,
password
=
'test'
,
email
=
'student@edx.org'
)
self
.
enrollment
=
CourseEnrollmentFactory
(
user
=
self
.
student
,
course_id
=
self
.
course_id
)
# Patch the comment client user save method so it does not try
# to create a new cc user when creating a django user
with
patch
(
'student.models.cc.User.save'
):
uname
=
'student'
email
=
'student@edx.org'
password
=
'test'
# Create the user and make them active so we can log them in.
self
.
student
=
User
.
objects
.
create_user
(
uname
,
email
,
password
)
self
.
student
.
is_active
=
True
self
.
student
.
save
()
# Enroll the student in the course
CourseEnrollmentFactory
(
user
=
self
.
student
,
course_id
=
self
.
course_id
)
self
.
client
=
Client
()
assert_true
(
self
.
client
.
login
(
username
=
'student'
,
password
=
'test'
))
self
.
client
=
Client
()
assert_true
(
self
.
client
.
login
(
username
=
'student'
,
password
=
'test'
))
def
test_create_thread
(
self
):
@patch
(
'comment_client.utils.requests.request'
)
def
test_create_thread
(
self
,
mock_request
):
mock_request
.
return_value
.
status_code
=
200
mock_request
.
return_value
.
text
=
u'{"title":"Hello",
\
"body":"this is a post",
\
"course_id":"MITx/999/Robot_Super_Course",
\
"anonymous":false,
\
"anonymous_to_peers":false,
\
"commentable_id":"i4x-MITx-999-course-Robot_Super_Course",
\
"created_at":"2013-05-10T18:53:43Z",
\
"updated_at":"2013-05-10T18:53:43Z",
\
"at_position_list":[],
\
"closed":false,
\
"id":"518d4237b023791dca00000d",
\
"user_id":"1","username":"robot",
\
"votes":{"count":0,"up_count":0,
\
"down_count":0,"point":0},
\
"abuse_flaggers":[],"tags":[],
\
"type":"thread","group_id":null,
\
"pinned":false,
\
"endorsed":false,
\
"unread_comments_count":0,
\
"read":false,"comments_count":0}'
thread
=
{
"body"
:
[
"this is a post"
],
"anonymous_to_peers"
:
[
"false"
],
"auto_subscribe"
:
[
"
tru
e"
],
"auto_subscribe"
:
[
"
fals
e"
],
"anonymous"
:
[
"false"
],
"title"
:
[
"Hello"
]
}
url
=
reverse
(
'create_thread'
,
kwargs
=
{
'commentable_id'
:
'i4x-MITx-999-course-Robot_Super_Course'
,
'course_id'
:
self
.
course_id
})
# url = '/courses/MITx/999/Robot_Super_Course/discussion/i4x-MITx-999-course-Robot_Super_Course/threads/create'
# url = 'MITx/999/Robot_Super_Course/threads/create'
url
=
reverse
(
'create_thread'
,
kwargs
=
{
'commentable_id'
:
'i4x-MITx-999-course-Robot_Super_Course'
,
'course_id'
:
self
.
course_id
})
response
=
self
.
client
.
post
(
url
,
data
=
thread
)
assert_true
(
mock_request
.
called
)
mock_request
.
assert_called_with
(
'post'
,
'http://localhost:4567/api/v1/i4x-MITx-999-course-Robot_Super_Course/threads'
,
data
=
{
'body'
:
u'this is a post'
,
'anonymous_to_peers'
:
False
,
'user_id'
:
1
,
'title'
:
u'Hello'
,
'commentable_id'
:
u'i4x-MITx-999-course-Robot_Super_Course'
,
'anonymous'
:
False
,
'course_id'
:
u'MITx/999/Robot_Super_Course'
,
'api_key'
:
'PUT_YOUR_API_KEY_HERE'
},
timeout
=
5
)
assert_equal
(
response
.
status_code
,
200
)
lms/envs/test.py
View file @
e1481d93
...
...
@@ -16,7 +16,7 @@ from path import path
MITX_FEATURES
[
'DISABLE_START_DATES'
]
=
True
# Until we have discussion actually working in test mode, just turn it off
MITX_FEATURES
[
'ENABLE_DISCUSSION_SERVICE'
]
=
Fals
e
MITX_FEATURES
[
'ENABLE_DISCUSSION_SERVICE'
]
=
Tru
e
# Need wiki for courseware views to work. TODO (vshnayder): shouldn't need it.
WIKI_ENABLED
=
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