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
109d3c3d
Commit
109d3c3d
authored
Aug 21, 2013
by
Will Daly
Committed by
Will Daly
Aug 21, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored to remove test#XXX methods from ModuleStoreTestCase
parent
151782ac
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
50 additions
and
50 deletions
+50
-50
cms/djangoapps/contentstore/tests/test_assets.py
+2
-2
cms/djangoapps/contentstore/tests/test_contentstore.py
+15
-15
cms/djangoapps/contentstore/tests/test_course_settings.py
+3
-3
cms/djangoapps/contentstore/tests/test_item.py
+1
-1
cms/djangoapps/contentstore/tests/test_textbooks.py
+11
-11
cms/djangoapps/contentstore/tests/test_users.py
+17
-17
common/lib/xmodule/xmodule/modulestore/tests/django_utils.py
+1
-1
No files found.
cms/djangoapps/contentstore/tests/test_assets.py
View file @
109d3c3d
...
@@ -60,11 +60,11 @@ class UploadTestCase(CourseTestCase):
...
@@ -60,11 +60,11 @@ class UploadTestCase(CourseTestCase):
f
=
BytesIO
(
"sample content"
)
f
=
BytesIO
(
"sample content"
)
f
.
name
=
"sample.txt"
f
.
name
=
"sample.txt"
resp
=
self
.
client
.
post
(
self
.
url
,
{
"name"
:
"my-name"
,
"file"
:
f
})
resp
=
self
.
client
.
post
(
self
.
url
,
{
"name"
:
"my-name"
,
"file"
:
f
})
self
.
assert
2XX
(
resp
.
status_code
)
self
.
assert
Equals
(
resp
.
status_code
,
200
)
def
test_no_file
(
self
):
def
test_no_file
(
self
):
resp
=
self
.
client
.
post
(
self
.
url
,
{
"name"
:
"file.txt"
})
resp
=
self
.
client
.
post
(
self
.
url
,
{
"name"
:
"file.txt"
})
self
.
assert
4XX
(
resp
.
status_code
)
self
.
assert
Equals
(
resp
.
status_code
,
400
)
def
test_get
(
self
):
def
test_get
(
self
):
resp
=
self
.
client
.
get
(
self
.
url
)
resp
=
self
.
client
.
get
(
self
.
url
)
...
...
cms/djangoapps/contentstore/tests/test_contentstore.py
View file @
109d3c3d
...
@@ -1367,7 +1367,7 @@ class ContentStoreTest(ModuleStoreTestCase):
...
@@ -1367,7 +1367,7 @@ class ContentStoreTest(ModuleStoreTestCase):
'course'
:
loc
.
course
,
'course'
:
loc
.
course
,
'name'
:
loc
.
name
}))
'name'
:
loc
.
name
}))
self
.
assert
2XX
(
resp
.
status_code
)
self
.
assert
Equal
(
resp
.
status_code
,
200
)
self
.
assertContains
(
resp
,
'Chapter 2'
)
self
.
assertContains
(
resp
,
'Chapter 2'
)
# go to various pages
# go to various pages
...
@@ -1377,92 +1377,92 @@ class ContentStoreTest(ModuleStoreTestCase):
...
@@ -1377,92 +1377,92 @@ class ContentStoreTest(ModuleStoreTestCase):
kwargs
=
{
'org'
:
loc
.
org
,
kwargs
=
{
'org'
:
loc
.
org
,
'course'
:
loc
.
course
,
'course'
:
loc
.
course
,
'name'
:
loc
.
name
}))
'name'
:
loc
.
name
}))
self
.
assert
2XX
(
resp
.
status_code
)
self
.
assert
Equal
(
resp
.
status_code
,
200
)
# export page
# export page
resp
=
self
.
client
.
get
(
reverse
(
'export_course'
,
resp
=
self
.
client
.
get
(
reverse
(
'export_course'
,
kwargs
=
{
'org'
:
loc
.
org
,
kwargs
=
{
'org'
:
loc
.
org
,
'course'
:
loc
.
course
,
'course'
:
loc
.
course
,
'name'
:
loc
.
name
}))
'name'
:
loc
.
name
}))
self
.
assert
2XX
(
resp
.
status_code
)
self
.
assert
Equal
(
resp
.
status_code
,
200
)
# manage users
# manage users
resp
=
self
.
client
.
get
(
reverse
(
'manage_users'
,
resp
=
self
.
client
.
get
(
reverse
(
'manage_users'
,
kwargs
=
{
'org'
:
loc
.
org
,
kwargs
=
{
'org'
:
loc
.
org
,
'course'
:
loc
.
course
,
'course'
:
loc
.
course
,
'name'
:
loc
.
name
}))
'name'
:
loc
.
name
}))
self
.
assert
2XX
(
resp
.
status_code
)
self
.
assert
Equal
(
resp
.
status_code
,
200
)
# course info
# course info
resp
=
self
.
client
.
get
(
reverse
(
'course_info'
,
resp
=
self
.
client
.
get
(
reverse
(
'course_info'
,
kwargs
=
{
'org'
:
loc
.
org
,
kwargs
=
{
'org'
:
loc
.
org
,
'course'
:
loc
.
course
,
'course'
:
loc
.
course
,
'name'
:
loc
.
name
}))
'name'
:
loc
.
name
}))
self
.
assert
2XX
(
resp
.
status_code
)
self
.
assert
Equal
(
resp
.
status_code
,
200
)
# settings_details
# settings_details
resp
=
self
.
client
.
get
(
reverse
(
'settings_details'
,
resp
=
self
.
client
.
get
(
reverse
(
'settings_details'
,
kwargs
=
{
'org'
:
loc
.
org
,
kwargs
=
{
'org'
:
loc
.
org
,
'course'
:
loc
.
course
,
'course'
:
loc
.
course
,
'name'
:
loc
.
name
}))
'name'
:
loc
.
name
}))
self
.
assert
2XX
(
resp
.
status_code
)
self
.
assert
Equal
(
resp
.
status_code
,
200
)
# settings_details
# settings_details
resp
=
self
.
client
.
get
(
reverse
(
'settings_grading'
,
resp
=
self
.
client
.
get
(
reverse
(
'settings_grading'
,
kwargs
=
{
'org'
:
loc
.
org
,
kwargs
=
{
'org'
:
loc
.
org
,
'course'
:
loc
.
course
,
'course'
:
loc
.
course
,
'name'
:
loc
.
name
}))
'name'
:
loc
.
name
}))
self
.
assert
2XX
(
resp
.
status_code
)
self
.
assert
Equal
(
resp
.
status_code
,
200
)
# static_pages
# static_pages
resp
=
self
.
client
.
get
(
reverse
(
'static_pages'
,
resp
=
self
.
client
.
get
(
reverse
(
'static_pages'
,
kwargs
=
{
'org'
:
loc
.
org
,
kwargs
=
{
'org'
:
loc
.
org
,
'course'
:
loc
.
course
,
'course'
:
loc
.
course
,
'coursename'
:
loc
.
name
}))
'coursename'
:
loc
.
name
}))
self
.
assert
2XX
(
resp
.
status_code
)
self
.
assert
Equal
(
resp
.
status_code
,
200
)
# static_pages
# static_pages
resp
=
self
.
client
.
get
(
reverse
(
'asset_index'
,
resp
=
self
.
client
.
get
(
reverse
(
'asset_index'
,
kwargs
=
{
'org'
:
loc
.
org
,
kwargs
=
{
'org'
:
loc
.
org
,
'course'
:
loc
.
course
,
'course'
:
loc
.
course
,
'name'
:
loc
.
name
}))
'name'
:
loc
.
name
}))
self
.
assert
2XX
(
resp
.
status_code
)
self
.
assert
Equal
(
resp
.
status_code
,
200
)
# go look at a subsection page
# go look at a subsection page
subsection_location
=
loc
.
replace
(
category
=
'sequential'
,
name
=
'test_sequence'
)
subsection_location
=
loc
.
replace
(
category
=
'sequential'
,
name
=
'test_sequence'
)
resp
=
self
.
client
.
get
(
reverse
(
'edit_subsection'
,
resp
=
self
.
client
.
get
(
reverse
(
'edit_subsection'
,
kwargs
=
{
'location'
:
subsection_location
.
url
()}))
kwargs
=
{
'location'
:
subsection_location
.
url
()}))
self
.
assert
2XX
(
resp
.
status_code
)
self
.
assert
Equal
(
resp
.
status_code
,
200
)
# go look at the Edit page
# go look at the Edit page
unit_location
=
loc
.
replace
(
category
=
'vertical'
,
name
=
'test_vertical'
)
unit_location
=
loc
.
replace
(
category
=
'vertical'
,
name
=
'test_vertical'
)
resp
=
self
.
client
.
get
(
reverse
(
'edit_unit'
,
resp
=
self
.
client
.
get
(
reverse
(
'edit_unit'
,
kwargs
=
{
'location'
:
unit_location
.
url
()}))
kwargs
=
{
'location'
:
unit_location
.
url
()}))
self
.
assert
2XX
(
resp
.
status_code
)
self
.
assert
Equal
(
resp
.
status_code
,
200
)
# delete a component
# delete a component
del_loc
=
loc
.
replace
(
category
=
'html'
,
name
=
'test_html'
)
del_loc
=
loc
.
replace
(
category
=
'html'
,
name
=
'test_html'
)
resp
=
self
.
client
.
post
(
reverse
(
'delete_item'
),
resp
=
self
.
client
.
post
(
reverse
(
'delete_item'
),
json
.
dumps
({
'id'
:
del_loc
.
url
()}),
"application/json"
)
json
.
dumps
({
'id'
:
del_loc
.
url
()}),
"application/json"
)
self
.
assert
2XX
(
resp
.
status_code
)
self
.
assert
Equal
(
resp
.
status_code
,
204
)
# delete a unit
# delete a unit
del_loc
=
loc
.
replace
(
category
=
'vertical'
,
name
=
'test_vertical'
)
del_loc
=
loc
.
replace
(
category
=
'vertical'
,
name
=
'test_vertical'
)
resp
=
self
.
client
.
post
(
reverse
(
'delete_item'
),
resp
=
self
.
client
.
post
(
reverse
(
'delete_item'
),
json
.
dumps
({
'id'
:
del_loc
.
url
()}),
"application/json"
)
json
.
dumps
({
'id'
:
del_loc
.
url
()}),
"application/json"
)
self
.
assert
2XX
(
resp
.
status_code
)
self
.
assert
Equal
(
resp
.
status_code
,
204
)
# delete a unit
# delete a unit
del_loc
=
loc
.
replace
(
category
=
'sequential'
,
name
=
'test_sequence'
)
del_loc
=
loc
.
replace
(
category
=
'sequential'
,
name
=
'test_sequence'
)
resp
=
self
.
client
.
post
(
reverse
(
'delete_item'
),
resp
=
self
.
client
.
post
(
reverse
(
'delete_item'
),
json
.
dumps
({
'id'
:
del_loc
.
url
()}),
"application/json"
)
json
.
dumps
({
'id'
:
del_loc
.
url
()}),
"application/json"
)
self
.
assert
2XX
(
resp
.
status_code
)
self
.
assert
Equal
(
resp
.
status_code
,
204
)
# delete a chapter
# delete a chapter
del_loc
=
loc
.
replace
(
category
=
'chapter'
,
name
=
'chapter_2'
)
del_loc
=
loc
.
replace
(
category
=
'chapter'
,
name
=
'chapter_2'
)
resp
=
self
.
client
.
post
(
reverse
(
'delete_item'
),
resp
=
self
.
client
.
post
(
reverse
(
'delete_item'
),
json
.
dumps
({
'id'
:
del_loc
.
url
()}),
"application/json"
)
json
.
dumps
({
'id'
:
del_loc
.
url
()}),
"application/json"
)
self
.
assert
2XX
(
resp
.
status_code
)
self
.
assert
Equal
(
resp
.
status_code
,
204
)
def
test_import_into_new_course_id
(
self
):
def
test_import_into_new_course_id
(
self
):
module_store
=
modulestore
(
'direct'
)
module_store
=
modulestore
(
'direct'
)
...
...
cms/djangoapps/contentstore/tests/test_course_settings.py
View file @
109d3c3d
...
@@ -430,12 +430,12 @@ class CourseGraderUpdatesTest(CourseTestCase):
...
@@ -430,12 +430,12 @@ class CourseGraderUpdatesTest(CourseTestCase):
def
test_get
(
self
):
def
test_get
(
self
):
resp
=
self
.
client
.
get
(
self
.
url
)
resp
=
self
.
client
.
get
(
self
.
url
)
self
.
assert
2XX
(
resp
.
status_code
)
self
.
assert
Equal
(
resp
.
status_code
,
200
)
obj
=
json
.
loads
(
resp
.
content
)
obj
=
json
.
loads
(
resp
.
content
)
def
test_delete
(
self
):
def
test_delete
(
self
):
resp
=
self
.
client
.
delete
(
self
.
url
)
resp
=
self
.
client
.
delete
(
self
.
url
)
self
.
assert
2XX
(
resp
.
status_code
)
self
.
assert
Equal
(
resp
.
status_code
,
204
)
def
test_post
(
self
):
def
test_post
(
self
):
grader
=
{
grader
=
{
...
@@ -446,5 +446,5 @@ class CourseGraderUpdatesTest(CourseTestCase):
...
@@ -446,5 +446,5 @@ class CourseGraderUpdatesTest(CourseTestCase):
"weight"
:
17.3
,
"weight"
:
17.3
,
}
}
resp
=
self
.
client
.
post
(
self
.
url
,
grader
)
resp
=
self
.
client
.
post
(
self
.
url
,
grader
)
self
.
assert
2XX
(
resp
.
status_code
)
self
.
assert
Equal
(
resp
.
status_code
,
200
)
obj
=
json
.
loads
(
resp
.
content
)
obj
=
json
.
loads
(
resp
.
content
)
cms/djangoapps/contentstore/tests/test_item.py
View file @
109d3c3d
...
@@ -34,7 +34,7 @@ class DeleteItem(CourseTestCase):
...
@@ -34,7 +34,7 @@ class DeleteItem(CourseTestCase):
resp
.
content
,
resp
.
content
,
"application/json"
"application/json"
)
)
self
.
assert
2XX
(
resp
.
status_code
)
self
.
assert
Equal
(
resp
.
status_code
,
204
)
class
TestCreateItem
(
CourseTestCase
):
class
TestCreateItem
(
CourseTestCase
):
...
...
cms/djangoapps/contentstore/tests/test_textbooks.py
View file @
109d3c3d
...
@@ -23,7 +23,7 @@ class TextbookIndexTestCase(CourseTestCase):
...
@@ -23,7 +23,7 @@ class TextbookIndexTestCase(CourseTestCase):
def
test_view_index
(
self
):
def
test_view_index
(
self
):
"Basic check that the textbook index page responds correctly"
"Basic check that the textbook index page responds correctly"
resp
=
self
.
client
.
get
(
self
.
url
)
resp
=
self
.
client
.
get
(
self
.
url
)
self
.
assert
2XX
(
resp
.
status_code
)
self
.
assert
Equal
(
resp
.
status_code
,
200
)
# we don't have resp.context right now,
# we don't have resp.context right now,
# due to bugs in our testing harness :(
# due to bugs in our testing harness :(
if
resp
.
context
:
if
resp
.
context
:
...
@@ -36,7 +36,7 @@ class TextbookIndexTestCase(CourseTestCase):
...
@@ -36,7 +36,7 @@ class TextbookIndexTestCase(CourseTestCase):
HTTP_ACCEPT
=
"application/json"
,
HTTP_ACCEPT
=
"application/json"
,
HTTP_X_REQUESTED_WITH
=
'XMLHttpRequest'
HTTP_X_REQUESTED_WITH
=
'XMLHttpRequest'
)
)
self
.
assert
2XX
(
resp
.
status_code
)
self
.
assert
Equal
(
resp
.
status_code
,
200
)
obj
=
json
.
loads
(
resp
.
content
)
obj
=
json
.
loads
(
resp
.
content
)
self
.
assertEqual
(
self
.
course
.
pdf_textbooks
,
obj
)
self
.
assertEqual
(
self
.
course
.
pdf_textbooks
,
obj
)
...
@@ -73,7 +73,7 @@ class TextbookIndexTestCase(CourseTestCase):
...
@@ -73,7 +73,7 @@ class TextbookIndexTestCase(CourseTestCase):
HTTP_ACCEPT
=
"application/json"
,
HTTP_ACCEPT
=
"application/json"
,
HTTP_X_REQUESTED_WITH
=
'XMLHttpRequest'
HTTP_X_REQUESTED_WITH
=
'XMLHttpRequest'
)
)
self
.
assert
2XX
(
resp
.
status_code
)
self
.
assert
Equal
(
resp
.
status_code
,
200
)
obj
=
json
.
loads
(
resp
.
content
)
obj
=
json
.
loads
(
resp
.
content
)
self
.
assertEqual
(
content
,
obj
)
self
.
assertEqual
(
content
,
obj
)
...
@@ -90,7 +90,7 @@ class TextbookIndexTestCase(CourseTestCase):
...
@@ -90,7 +90,7 @@ class TextbookIndexTestCase(CourseTestCase):
HTTP_ACCEPT
=
"application/json"
,
HTTP_ACCEPT
=
"application/json"
,
HTTP_X_REQUESTED_WITH
=
'XMLHttpRequest'
HTTP_X_REQUESTED_WITH
=
'XMLHttpRequest'
)
)
self
.
assert
2XX
(
resp
.
status_code
)
self
.
assert
Equal
(
resp
.
status_code
,
200
)
# reload course
# reload course
store
=
get_modulestore
(
self
.
course
.
location
)
store
=
get_modulestore
(
self
.
course
.
location
)
...
@@ -111,7 +111,7 @@ class TextbookIndexTestCase(CourseTestCase):
...
@@ -111,7 +111,7 @@ class TextbookIndexTestCase(CourseTestCase):
HTTP_ACCEPT
=
"application/json"
,
HTTP_ACCEPT
=
"application/json"
,
HTTP_X_REQUESTED_WITH
=
'XMLHttpRequest'
HTTP_X_REQUESTED_WITH
=
'XMLHttpRequest'
)
)
self
.
assert
4XX
(
resp
.
status_code
)
self
.
assert
Equal
(
resp
.
status_code
,
400
)
obj
=
json
.
loads
(
resp
.
content
)
obj
=
json
.
loads
(
resp
.
content
)
self
.
assertIn
(
"error"
,
obj
)
self
.
assertIn
(
"error"
,
obj
)
...
@@ -184,7 +184,7 @@ class TextbookCreateTestCase(CourseTestCase):
...
@@ -184,7 +184,7 @@ class TextbookCreateTestCase(CourseTestCase):
HTTP_ACCEPT
=
"application/json"
,
HTTP_ACCEPT
=
"application/json"
,
HTTP_X_REQUESTED_WITH
=
"XMLHttpRequest"
,
HTTP_X_REQUESTED_WITH
=
"XMLHttpRequest"
,
)
)
self
.
assert
4XX
(
resp
.
status_code
)
self
.
assert
Equal
(
resp
.
status_code
,
400
)
self
.
assertNotIn
(
"Location"
,
resp
)
self
.
assertNotIn
(
"Location"
,
resp
)
...
@@ -238,14 +238,14 @@ class TextbookByIdTestCase(CourseTestCase):
...
@@ -238,14 +238,14 @@ class TextbookByIdTestCase(CourseTestCase):
def
test_get_1
(
self
):
def
test_get_1
(
self
):
"Get the first textbook"
"Get the first textbook"
resp
=
self
.
client
.
get
(
self
.
url1
)
resp
=
self
.
client
.
get
(
self
.
url1
)
self
.
assert
2XX
(
resp
.
status_code
)
self
.
assert
Equal
(
resp
.
status_code
,
200
)
compare
=
json
.
loads
(
resp
.
content
)
compare
=
json
.
loads
(
resp
.
content
)
self
.
assertEqual
(
compare
,
self
.
textbook1
)
self
.
assertEqual
(
compare
,
self
.
textbook1
)
def
test_get_2
(
self
):
def
test_get_2
(
self
):
"Get the second textbook"
"Get the second textbook"
resp
=
self
.
client
.
get
(
self
.
url2
)
resp
=
self
.
client
.
get
(
self
.
url2
)
self
.
assert
2XX
(
resp
.
status_code
)
self
.
assert
Equal
(
resp
.
status_code
,
200
)
compare
=
json
.
loads
(
resp
.
content
)
compare
=
json
.
loads
(
resp
.
content
)
self
.
assertEqual
(
compare
,
self
.
textbook2
)
self
.
assertEqual
(
compare
,
self
.
textbook2
)
...
@@ -257,7 +257,7 @@ class TextbookByIdTestCase(CourseTestCase):
...
@@ -257,7 +257,7 @@ class TextbookByIdTestCase(CourseTestCase):
def
test_delete
(
self
):
def
test_delete
(
self
):
"Delete a textbook by ID"
"Delete a textbook by ID"
resp
=
self
.
client
.
delete
(
self
.
url1
)
resp
=
self
.
client
.
delete
(
self
.
url1
)
self
.
assert
2XX
(
resp
.
status_code
)
self
.
assert
Equal
(
resp
.
status_code
,
204
)
course
=
self
.
store
.
get_item
(
self
.
course
.
location
)
course
=
self
.
store
.
get_item
(
self
.
course
.
location
)
self
.
assertEqual
(
course
.
pdf_textbooks
,
[
self
.
textbook2
])
self
.
assertEqual
(
course
.
pdf_textbooks
,
[
self
.
textbook2
])
...
@@ -288,7 +288,7 @@ class TextbookByIdTestCase(CourseTestCase):
...
@@ -288,7 +288,7 @@ class TextbookByIdTestCase(CourseTestCase):
)
)
self
.
assertEqual
(
resp
.
status_code
,
201
)
self
.
assertEqual
(
resp
.
status_code
,
201
)
resp2
=
self
.
client
.
get
(
url
)
resp2
=
self
.
client
.
get
(
url
)
self
.
assert
2XX
(
resp2
.
status_code
)
self
.
assert
Equal
(
resp2
.
status_code
,
200
)
compare
=
json
.
loads
(
resp2
.
content
)
compare
=
json
.
loads
(
resp2
.
content
)
self
.
assertEqual
(
compare
,
textbook
)
self
.
assertEqual
(
compare
,
textbook
)
course
=
self
.
store
.
get_item
(
self
.
course
.
location
)
course
=
self
.
store
.
get_item
(
self
.
course
.
location
)
...
@@ -311,7 +311,7 @@ class TextbookByIdTestCase(CourseTestCase):
...
@@ -311,7 +311,7 @@ class TextbookByIdTestCase(CourseTestCase):
)
)
self
.
assertEqual
(
resp
.
status_code
,
201
)
self
.
assertEqual
(
resp
.
status_code
,
201
)
resp2
=
self
.
client
.
get
(
self
.
url2
)
resp2
=
self
.
client
.
get
(
self
.
url2
)
self
.
assert
2XX
(
resp2
.
status_code
)
self
.
assert
Equal
(
resp2
.
status_code
,
200
)
compare
=
json
.
loads
(
resp2
.
content
)
compare
=
json
.
loads
(
resp2
.
content
)
self
.
assertEqual
(
compare
,
replacement
)
self
.
assertEqual
(
compare
,
replacement
)
course
=
self
.
store
.
get_item
(
self
.
course
.
location
)
course
=
self
.
store
.
get_item
(
self
.
course
.
location
)
...
...
cms/djangoapps/contentstore/tests/test_users.py
View file @
109d3c3d
...
@@ -72,13 +72,13 @@ class UsersTestCase(CourseTestCase):
...
@@ -72,13 +72,13 @@ class UsersTestCase(CourseTestCase):
def
test_detail_inactive
(
self
):
def
test_detail_inactive
(
self
):
resp
=
self
.
client
.
get
(
self
.
inactive_detail_url
)
resp
=
self
.
client
.
get
(
self
.
inactive_detail_url
)
self
.
assert
2XX
(
resp
.
status_code
)
self
.
assert
Equal
(
resp
.
status_code
,
200
)
result
=
json
.
loads
(
resp
.
content
)
result
=
json
.
loads
(
resp
.
content
)
self
.
assertFalse
(
result
[
"active"
])
self
.
assertFalse
(
result
[
"active"
])
def
test_detail_invalid
(
self
):
def
test_detail_invalid
(
self
):
resp
=
self
.
client
.
get
(
self
.
invalid_detail_url
)
resp
=
self
.
client
.
get
(
self
.
invalid_detail_url
)
self
.
assert
4XX
(
resp
.
status_code
)
self
.
assert
Equal
(
resp
.
status_code
,
404
)
result
=
json
.
loads
(
resp
.
content
)
result
=
json
.
loads
(
resp
.
content
)
self
.
assertIn
(
"error"
,
result
)
self
.
assertIn
(
"error"
,
result
)
...
@@ -87,7 +87,7 @@ class UsersTestCase(CourseTestCase):
...
@@ -87,7 +87,7 @@ class UsersTestCase(CourseTestCase):
self
.
detail_url
,
self
.
detail_url
,
data
=
{
"role"
:
None
},
data
=
{
"role"
:
None
},
)
)
self
.
assert
2XX
(
resp
.
status_code
)
self
.
assert
Equal
(
resp
.
status_code
,
204
)
# reload user from DB
# reload user from DB
ext_user
=
User
.
objects
.
get
(
email
=
self
.
ext_user
.
email
)
ext_user
=
User
.
objects
.
get
(
email
=
self
.
ext_user
.
email
)
groups
=
[
g
.
name
for
g
in
ext_user
.
groups
.
all
()]
groups
=
[
g
.
name
for
g
in
ext_user
.
groups
.
all
()]
...
@@ -103,7 +103,7 @@ class UsersTestCase(CourseTestCase):
...
@@ -103,7 +103,7 @@ class UsersTestCase(CourseTestCase):
content_type
=
"application/json"
,
content_type
=
"application/json"
,
HTTP_ACCEPT
=
"application/json"
,
HTTP_ACCEPT
=
"application/json"
,
)
)
self
.
assert
2XX
(
resp
.
status_code
)
self
.
assert
Equal
(
resp
.
status_code
,
204
)
# reload user from DB
# reload user from DB
ext_user
=
User
.
objects
.
get
(
email
=
self
.
ext_user
.
email
)
ext_user
=
User
.
objects
.
get
(
email
=
self
.
ext_user
.
email
)
groups
=
[
g
.
name
for
g
in
ext_user
.
groups
.
all
()]
groups
=
[
g
.
name
for
g
in
ext_user
.
groups
.
all
()]
...
@@ -122,7 +122,7 @@ class UsersTestCase(CourseTestCase):
...
@@ -122,7 +122,7 @@ class UsersTestCase(CourseTestCase):
content_type
=
"application/json"
,
content_type
=
"application/json"
,
HTTP_ACCEPT
=
"application/json"
,
HTTP_ACCEPT
=
"application/json"
,
)
)
self
.
assert
2XX
(
resp
.
status_code
)
self
.
assert
Equal
(
resp
.
status_code
,
204
)
# reload user from DB
# reload user from DB
ext_user
=
User
.
objects
.
get
(
email
=
self
.
ext_user
.
email
)
ext_user
=
User
.
objects
.
get
(
email
=
self
.
ext_user
.
email
)
groups
=
[
g
.
name
for
g
in
ext_user
.
groups
.
all
()]
groups
=
[
g
.
name
for
g
in
ext_user
.
groups
.
all
()]
...
@@ -142,7 +142,7 @@ class UsersTestCase(CourseTestCase):
...
@@ -142,7 +142,7 @@ class UsersTestCase(CourseTestCase):
content_type
=
"application/json"
,
content_type
=
"application/json"
,
HTTP_ACCEPT
=
"application/json"
,
HTTP_ACCEPT
=
"application/json"
,
)
)
self
.
assert
2XX
(
resp
.
status_code
)
self
.
assert
Equal
(
resp
.
status_code
,
204
)
# reload user from DB
# reload user from DB
ext_user
=
User
.
objects
.
get
(
email
=
self
.
ext_user
.
email
)
ext_user
=
User
.
objects
.
get
(
email
=
self
.
ext_user
.
email
)
groups
=
[
g
.
name
for
g
in
ext_user
.
groups
.
all
()]
groups
=
[
g
.
name
for
g
in
ext_user
.
groups
.
all
()]
...
@@ -157,7 +157,7 @@ class UsersTestCase(CourseTestCase):
...
@@ -157,7 +157,7 @@ class UsersTestCase(CourseTestCase):
content_type
=
"application/json"
,
content_type
=
"application/json"
,
HTTP_ACCEPT
=
"application/json"
,
HTTP_ACCEPT
=
"application/json"
,
)
)
self
.
assert
4XX
(
resp
.
status_code
)
self
.
assert
Equal
(
resp
.
status_code
,
400
)
result
=
json
.
loads
(
resp
.
content
)
result
=
json
.
loads
(
resp
.
content
)
self
.
assertIn
(
"error"
,
result
)
self
.
assertIn
(
"error"
,
result
)
self
.
assert_not_enrolled
()
self
.
assert_not_enrolled
()
...
@@ -169,7 +169,7 @@ class UsersTestCase(CourseTestCase):
...
@@ -169,7 +169,7 @@ class UsersTestCase(CourseTestCase):
content_type
=
"application/json"
,
content_type
=
"application/json"
,
HTTP_ACCEPT
=
"application/json"
,
HTTP_ACCEPT
=
"application/json"
,
)
)
self
.
assert
4XX
(
resp
.
status_code
)
self
.
assert
Equal
(
resp
.
status_code
,
400
)
result
=
json
.
loads
(
resp
.
content
)
result
=
json
.
loads
(
resp
.
content
)
self
.
assertIn
(
"error"
,
result
)
self
.
assertIn
(
"error"
,
result
)
self
.
assert_not_enrolled
()
self
.
assert_not_enrolled
()
...
@@ -180,7 +180,7 @@ class UsersTestCase(CourseTestCase):
...
@@ -180,7 +180,7 @@ class UsersTestCase(CourseTestCase):
data
=
{
"role"
:
"staff"
},
data
=
{
"role"
:
"staff"
},
HTTP_ACCEPT
=
"application/json"
,
HTTP_ACCEPT
=
"application/json"
,
)
)
self
.
assert
2XX
(
resp
.
status_code
)
self
.
assert
Equal
(
resp
.
status_code
,
204
)
# reload user from DB
# reload user from DB
ext_user
=
User
.
objects
.
get
(
email
=
self
.
ext_user
.
email
)
ext_user
=
User
.
objects
.
get
(
email
=
self
.
ext_user
.
email
)
groups
=
[
g
.
name
for
g
in
ext_user
.
groups
.
all
()]
groups
=
[
g
.
name
for
g
in
ext_user
.
groups
.
all
()]
...
@@ -197,7 +197,7 @@ class UsersTestCase(CourseTestCase):
...
@@ -197,7 +197,7 @@ class UsersTestCase(CourseTestCase):
self
.
detail_url
,
self
.
detail_url
,
HTTP_ACCEPT
=
"application/json"
,
HTTP_ACCEPT
=
"application/json"
,
)
)
self
.
assert
2XX
(
resp
.
status_code
)
self
.
assert
Equal
(
resp
.
status_code
,
204
)
# reload user from DB
# reload user from DB
ext_user
=
User
.
objects
.
get
(
email
=
self
.
ext_user
.
email
)
ext_user
=
User
.
objects
.
get
(
email
=
self
.
ext_user
.
email
)
groups
=
[
g
.
name
for
g
in
ext_user
.
groups
.
all
()]
groups
=
[
g
.
name
for
g
in
ext_user
.
groups
.
all
()]
...
@@ -214,7 +214,7 @@ class UsersTestCase(CourseTestCase):
...
@@ -214,7 +214,7 @@ class UsersTestCase(CourseTestCase):
self
.
detail_url
,
self
.
detail_url
,
HTTP_ACCEPT
=
"application/json"
,
HTTP_ACCEPT
=
"application/json"
,
)
)
self
.
assert
2XX
(
resp
.
status_code
)
self
.
assert
Equal
(
resp
.
status_code
,
204
)
# reload user from DB
# reload user from DB
ext_user
=
User
.
objects
.
get
(
email
=
self
.
ext_user
.
email
)
ext_user
=
User
.
objects
.
get
(
email
=
self
.
ext_user
.
email
)
groups
=
[
g
.
name
for
g
in
ext_user
.
groups
.
all
()]
groups
=
[
g
.
name
for
g
in
ext_user
.
groups
.
all
()]
...
@@ -273,7 +273,7 @@ class UsersTestCase(CourseTestCase):
...
@@ -273,7 +273,7 @@ class UsersTestCase(CourseTestCase):
data
=
{
"role"
:
"instructor"
},
data
=
{
"role"
:
"instructor"
},
HTTP_ACCEPT
=
"application/json"
,
HTTP_ACCEPT
=
"application/json"
,
)
)
self
.
assert
4XX
(
resp
.
status_code
)
self
.
assert
Equal
(
resp
.
status_code
,
400
)
result
=
json
.
loads
(
resp
.
content
)
result
=
json
.
loads
(
resp
.
content
)
self
.
assertIn
(
"error"
,
result
)
self
.
assertIn
(
"error"
,
result
)
...
@@ -288,7 +288,7 @@ class UsersTestCase(CourseTestCase):
...
@@ -288,7 +288,7 @@ class UsersTestCase(CourseTestCase):
data
=
{
"role"
:
"instructor"
},
data
=
{
"role"
:
"instructor"
},
HTTP_ACCEPT
=
"application/json"
,
HTTP_ACCEPT
=
"application/json"
,
)
)
self
.
assert
4XX
(
resp
.
status_code
)
self
.
assert
Equal
(
resp
.
status_code
,
400
)
result
=
json
.
loads
(
resp
.
content
)
result
=
json
.
loads
(
resp
.
content
)
self
.
assertIn
(
"error"
,
result
)
self
.
assertIn
(
"error"
,
result
)
...
@@ -306,7 +306,7 @@ class UsersTestCase(CourseTestCase):
...
@@ -306,7 +306,7 @@ class UsersTestCase(CourseTestCase):
})
})
resp
=
self
.
client
.
delete
(
self_url
)
resp
=
self
.
client
.
delete
(
self_url
)
self
.
assert
2XX
(
resp
.
status_code
)
self
.
assert
Equal
(
resp
.
status_code
,
204
)
# reload user from DB
# reload user from DB
user
=
User
.
objects
.
get
(
email
=
self
.
user
.
email
)
user
=
User
.
objects
.
get
(
email
=
self
.
user
.
email
)
groups
=
[
g
.
name
for
g
in
user
.
groups
.
all
()]
groups
=
[
g
.
name
for
g
in
user
.
groups
.
all
()]
...
@@ -321,7 +321,7 @@ class UsersTestCase(CourseTestCase):
...
@@ -321,7 +321,7 @@ class UsersTestCase(CourseTestCase):
self
.
ext_user
.
save
()
self
.
ext_user
.
save
()
resp
=
self
.
client
.
delete
(
self
.
detail_url
)
resp
=
self
.
client
.
delete
(
self
.
detail_url
)
self
.
assert
4XX
(
resp
.
status_code
)
self
.
assert
Equal
(
resp
.
status_code
,
400
)
result
=
json
.
loads
(
resp
.
content
)
result
=
json
.
loads
(
resp
.
content
)
self
.
assertIn
(
"error"
,
result
)
self
.
assertIn
(
"error"
,
result
)
# reload user from DB
# reload user from DB
...
@@ -347,7 +347,7 @@ class UsersTestCase(CourseTestCase):
...
@@ -347,7 +347,7 @@ class UsersTestCase(CourseTestCase):
self
.
detail_url
,
self
.
detail_url
,
HTTP_ACCEPT
=
"application/json"
,
HTTP_ACCEPT
=
"application/json"
,
)
)
self
.
assert
2XX
(
resp
.
status_code
)
self
.
assert
Equal
(
resp
.
status_code
,
204
)
self
.
assert_enrolled
()
self
.
assert_enrolled
()
def
test_staff_to_instructor_still_enrolled
(
self
):
def
test_staff_to_instructor_still_enrolled
(
self
):
...
@@ -366,7 +366,7 @@ class UsersTestCase(CourseTestCase):
...
@@ -366,7 +366,7 @@ class UsersTestCase(CourseTestCase):
content_type
=
"application/json"
,
content_type
=
"application/json"
,
HTTP_ACCEPT
=
"application/json"
,
HTTP_ACCEPT
=
"application/json"
,
)
)
self
.
assert
2XX
(
resp
.
status_code
)
self
.
assert
Equal
(
resp
.
status_code
,
204
)
self
.
assert_enrolled
()
self
.
assert_enrolled
()
def
assert_not_enrolled
(
self
):
def
assert_not_enrolled
(
self
):
...
...
common/lib/xmodule/xmodule/modulestore/tests/django_utils.py
View file @
109d3c3d
"""
"""
eoduleS
tore configuration for test cases.
Modules
tore configuration for test cases.
"""
"""
from
uuid
import
uuid4
from
uuid
import
uuid4
...
...
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