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
81ecf0c5
Commit
81ecf0c5
authored
May 07, 2013
by
Chris Dodge
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add unit test to verify forum seeding occurs when creating new courses
parent
5ba22ec8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
2 deletions
+39
-2
cms/djangoapps/contentstore/tests/test_contentstore.py
+10
-0
common/djangoapps/django_comment_common/utils.py
+29
-2
No files found.
cms/djangoapps/contentstore/tests/test_contentstore.py
View file @
81ecf0c5
...
...
@@ -34,6 +34,8 @@ from xmodule.course_module import CourseDescriptor
from
xmodule.seq_module
import
SequenceDescriptor
from
xmodule.modulestore.exceptions
import
ItemNotFoundError
from
django_comment_common.utils
import
are_permissions_roles_seeded
TEST_DATA_MODULESTORE
=
copy
.
deepcopy
(
settings
.
MODULESTORE
)
TEST_DATA_MODULESTORE
[
'default'
][
'OPTIONS'
][
'fs_root'
]
=
path
(
'common/test/data'
)
TEST_DATA_MODULESTORE
[
'direct'
][
'OPTIONS'
][
'fs_root'
]
=
path
(
'common/test/data'
)
...
...
@@ -598,6 +600,14 @@ class ContentStoreTest(ModuleStoreTestCase):
data
=
parse_json
(
resp
)
self
.
assertEqual
(
data
[
'id'
],
'i4x://MITx/999/course/Robot_Super_Course'
)
def
test_create_course_check_forum_seeding
(
self
):
"""Test new course creation and verify forum seeding """
resp
=
self
.
client
.
post
(
reverse
(
'create_new_course'
),
self
.
course_data
)
self
.
assertEqual
(
resp
.
status_code
,
200
)
data
=
parse_json
(
resp
)
self
.
assertEqual
(
data
[
'id'
],
'i4x://MITx/999/course/Robot_Super_Course'
)
self
.
assertTrue
(
are_permissions_roles_seeded
(
'MITx/999/Robot_Super_Course'
))
def
test_create_course_duplicate_course
(
self
):
"""Test new course creation - error path"""
resp
=
self
.
client
.
post
(
reverse
(
'create_new_course'
),
self
.
course_data
)
...
...
common/djangoapps/django_comment_common/utils.py
View file @
81ecf0c5
...
...
@@ -24,4 +24,31 @@ def seed_permissions_roles(course_id):
# For now, Community TA == Moderator, except for the styling.
community_ta_role
.
inherit_permissions
(
moderator_role
)
administrator_role
.
inherit_permissions
(
moderator_role
)
\ No newline at end of file
administrator_role
.
inherit_permissions
(
moderator_role
)
def
are_permissions_roles_seeded
(
course_id
):
try
:
administrator_role
=
Role
.
objects
.
get
(
name
=
"Administrator"
,
course_id
=
course_id
)
moderator_role
=
Role
.
objects
.
get
(
name
=
"Moderator"
,
course_id
=
course_id
)
student_role
=
Role
.
objects
.
get
(
name
=
"Student"
,
course_id
=
course_id
)
except
:
return
False
for
per
in
[
"vote"
,
"update_thread"
,
"follow_thread"
,
"unfollow_thread"
,
"update_comment"
,
"create_sub_comment"
,
"unvote"
,
"create_thread"
,
"follow_commentable"
,
"unfollow_commentable"
,
"create_comment"
,
]:
if
not
student_role
.
has_permission
(
per
):
return
False
for
per
in
[
"edit_content"
,
"delete_thread"
,
"openclose_thread"
,
"endorse_comment"
,
"delete_comment"
,
"see_all_cohorts"
]:
if
not
moderator_role
.
has_permission
(
per
):
return
False
for
per
in
[
"manage_moderator"
]:
if
not
administrator_role
.
has_permission
(
per
):
return
False
return
True
\ 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