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
b8f70ff1
Commit
b8f70ff1
authored
Apr 20, 2014
by
Chris Dodge
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix some merge conflicts and remove some extra print statements picked up in rebase
parent
f191692a
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
3 additions
and
33 deletions
+3
-33
lms/djangoapps/api_manager/courses_views.py
+1
-4
lms/djangoapps/api_manager/groups_views.py
+2
-6
lms/djangoapps/api_manager/tests/test_courses_views.py
+0
-19
lms/djangoapps/api_manager/tests/test_groups_views.py
+0
-1
lms/djangoapps/api_manager/tests/test_users_views.py
+0
-3
No files found.
lms/djangoapps/api_manager/courses_views.py
View file @
b8f70ff1
...
@@ -225,7 +225,6 @@ def courses_detail(request, course_id):
...
@@ -225,7 +225,6 @@ def courses_detail(request, course_id):
return
Response
(
response_data
,
status
=
status_code
)
return
Response
(
response_data
,
status
=
status_code
)
<<<<<<<
HEAD
@api_view
([
'POST'
])
@api_view
([
'POST'
])
@permission_classes
((
ApiKeyHeaderPermission
,))
@permission_classes
((
ApiKeyHeaderPermission
,))
def
courses_groups_list
(
request
,
course_id
):
def
courses_groups_list
(
request
,
course_id
):
...
@@ -306,8 +305,6 @@ def courses_groups_detail(request, course_id, group_id):
...
@@ -306,8 +305,6 @@ def courses_groups_detail(request, course_id, group_id):
return
Response
({},
status
=
status
.
HTTP_204_NO_CONTENT
)
return
Response
({},
status
=
status
.
HTTP_204_NO_CONTENT
)
def
_parse_about_html
(
html
):
=======
def
_inner_content
(
tag
):
def
_inner_content
(
tag
):
"""
"""
Helper method
Helper method
...
@@ -320,8 +317,8 @@ def _inner_content(tag):
...
@@ -320,8 +317,8 @@ def _inner_content(tag):
return
inner_content
return
inner_content
def
_parse_overview_html
(
html
):
def
_parse_overview_html
(
html
):
>>>>>>>
initial
implementation
"""
"""
Helper method to break up the course about HTML into components
Helper method to break up the course about HTML into components
"""
"""
...
...
lms/djangoapps/api_manager/groups_views.py
View file @
b8f70ff1
...
@@ -285,7 +285,6 @@ def group_courses_list(request, group_id):
...
@@ -285,7 +285,6 @@ def group_courses_list(request, group_id):
base_uri
=
_generate_base_uri
(
request
)
base_uri
=
_generate_base_uri
(
request
)
response_data
[
'uri'
]
=
'{}/{}'
.
format
(
base_uri
,
course_id
)
response_data
[
'uri'
]
=
'{}/{}'
.
format
(
base_uri
,
course_id
)
store
=
modulestore
()
store
=
modulestore
()
print
"GROUP COURSES LIST"
try
:
try
:
existing_group
=
Group
.
objects
.
get
(
id
=
group_id
)
existing_group
=
Group
.
objects
.
get
(
id
=
group_id
)
except
ObjectDoesNotExist
:
except
ObjectDoesNotExist
:
...
@@ -294,17 +293,15 @@ def group_courses_list(request, group_id):
...
@@ -294,17 +293,15 @@ def group_courses_list(request, group_id):
existing_course
=
store
.
get_course
(
course_id
)
existing_course
=
store
.
get_course
(
course_id
)
except
ValueError
:
except
ValueError
:
existing_course
=
None
existing_course
=
None
print
existing_group
print
existing_course
if
existing_group
and
existing_course
:
if
existing_group
and
existing_course
:
try
:
try
:
existing_relationship
=
CourseGroupRelationship
.
objects
.
get
(
course_id
=
course_id
,
group
=
existing_group
)
existing_relationship
=
CourseGroupRelationship
.
objects
.
get
(
course_id
=
course_id
,
group
=
existing_group
)
except
ObjectDoesNotExist
:
except
ObjectDoesNotExist
:
existing_relationship
=
None
existing_relationship
=
None
print
existing_relationship
if
existing_relationship
is
None
:
if
existing_relationship
is
None
:
new_relationship
=
CourseGroupRelationship
.
objects
.
create
(
course_id
=
course_id
,
group
=
existing_group
)
new_relationship
=
CourseGroupRelationship
.
objects
.
create
(
course_id
=
course_id
,
group
=
existing_group
)
print
new_relationship
.
__dict__
response_data
[
'group_id'
]
=
str
(
new_relationship
.
group_id
)
response_data
[
'group_id'
]
=
str
(
new_relationship
.
group_id
)
response_data
[
'course_id'
]
=
str
(
new_relationship
.
course_id
)
response_data
[
'course_id'
]
=
str
(
new_relationship
.
course_id
)
response_status
=
status
.
HTTP_201_CREATED
response_status
=
status
.
HTTP_201_CREATED
...
@@ -312,7 +309,6 @@ def group_courses_list(request, group_id):
...
@@ -312,7 +309,6 @@ def group_courses_list(request, group_id):
response_data
[
'message'
]
=
"Relationship already exists."
response_data
[
'message'
]
=
"Relationship already exists."
response_status
=
status
.
HTTP_409_CONFLICT
response_status
=
status
.
HTTP_409_CONFLICT
else
:
else
:
print
request
.
DATA
response_status
=
status
.
HTTP_404_NOT_FOUND
response_status
=
status
.
HTTP_404_NOT_FOUND
return
Response
(
response_data
,
status
=
response_status
)
return
Response
(
response_data
,
status
=
response_status
)
...
...
lms/djangoapps/api_manager/tests/test_courses_views.py
View file @
b8f70ff1
...
@@ -4,11 +4,8 @@
...
@@ -4,11 +4,8 @@
Run these tests @ Devstack:
Run these tests @ Devstack:
rake fasttest_lms[common/djangoapps/api_manager/tests/test_group_views.py]
rake fasttest_lms[common/djangoapps/api_manager/tests/test_group_views.py]
"""
"""
<<<<<<<
HEAD
import
simplejson
as
json
import
simplejson
as
json
import
unittest
import
unittest
=======
>>>>>>>
initial
implementation
import
uuid
import
uuid
from
django.core.cache
import
cache
from
django.core.cache
import
cache
...
@@ -116,20 +113,15 @@ class CoursesApiTests(TestCase):
...
@@ -116,20 +113,15 @@ class CoursesApiTests(TestCase):
'Content-Type'
:
'application/json'
,
'Content-Type'
:
'application/json'
,
'X-Edx-Api-Key'
:
str
(
TEST_API_KEY
),
'X-Edx-Api-Key'
:
str
(
TEST_API_KEY
),
}
}
print
"GET: "
+
uri
response
=
self
.
client
.
get
(
uri
,
headers
=
headers
)
response
=
self
.
client
.
get
(
uri
,
headers
=
headers
)
return
response
return
response
<<<<<<<
HEAD
def
do_post
(
self
,
uri
,
data
):
def
do_post
(
self
,
uri
,
data
):
"""Submit an HTTP POST request"""
"""Submit an HTTP POST request"""
headers
=
{
headers
=
{
'X-Edx-Api-Key'
:
str
(
TEST_API_KEY
),
'X-Edx-Api-Key'
:
str
(
TEST_API_KEY
),
}
}
json_data
=
json
.
dumps
(
data
)
json_data
=
json
.
dumps
(
data
)
print
"POST: "
+
uri
print
json_data
print
""
response
=
self
.
client
.
post
(
uri
,
headers
=
headers
,
content_type
=
'application/json'
,
data
=
json_data
)
response
=
self
.
client
.
post
(
uri
,
headers
=
headers
,
content_type
=
'application/json'
,
data
=
json_data
)
return
response
return
response
...
@@ -143,9 +135,6 @@ class CoursesApiTests(TestCase):
...
@@ -143,9 +135,6 @@ class CoursesApiTests(TestCase):
response
=
self
.
client
.
delete
(
uri
,
headers
=
headers
)
response
=
self
.
client
.
delete
(
uri
,
headers
=
headers
)
return
response
return
response
@unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
=======
>>>>>>>
initial
implementation
def
test_course_list_get
(
self
):
def
test_course_list_get
(
self
):
test_uri
=
self
.
base_courses_uri
test_uri
=
self
.
base_courses_uri
response
=
self
.
do_get
(
test_uri
)
response
=
self
.
do_get
(
test_uri
)
...
@@ -253,7 +242,6 @@ class CoursesApiTests(TestCase):
...
@@ -253,7 +242,6 @@ class CoursesApiTests(TestCase):
response
=
self
.
do_get
(
test_uri
)
response
=
self
.
do_get
(
test_uri
)
self
.
assertEqual
(
response
.
status_code
,
404
)
self
.
assertEqual
(
response
.
status_code
,
404
)
@unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
def
test_course_groups_list_post
(
self
):
def
test_course_groups_list_post
(
self
):
data
=
{
'name'
:
self
.
test_group_name
}
data
=
{
'name'
:
self
.
test_group_name
}
response
=
self
.
do_post
(
self
.
base_groups_uri
,
data
)
response
=
self
.
do_post
(
self
.
base_groups_uri
,
data
)
...
@@ -269,7 +257,6 @@ class CoursesApiTests(TestCase):
...
@@ -269,7 +257,6 @@ class CoursesApiTests(TestCase):
self
.
assertEqual
(
response
.
data
[
'course_id'
],
str
(
self
.
test_course_id
))
self
.
assertEqual
(
response
.
data
[
'course_id'
],
str
(
self
.
test_course_id
))
self
.
assertEqual
(
response
.
data
[
'group_id'
],
str
(
group_id
))
self
.
assertEqual
(
response
.
data
[
'group_id'
],
str
(
group_id
))
@unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
def
test_course_groups_list_post_duplicate
(
self
):
def
test_course_groups_list_post_duplicate
(
self
):
data
=
{
'name'
:
self
.
test_group_name
}
data
=
{
'name'
:
self
.
test_group_name
}
response
=
self
.
do_post
(
self
.
base_groups_uri
,
data
)
response
=
self
.
do_post
(
self
.
base_groups_uri
,
data
)
...
@@ -281,14 +268,12 @@ class CoursesApiTests(TestCase):
...
@@ -281,14 +268,12 @@ class CoursesApiTests(TestCase):
response
=
self
.
do_post
(
test_uri
,
data
)
response
=
self
.
do_post
(
test_uri
,
data
)
self
.
assertEqual
(
response
.
status_code
,
409
)
self
.
assertEqual
(
response
.
status_code
,
409
)
@unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
def
test_group_courses_list_post_invalid_resources
(
self
):
def
test_group_courses_list_post_invalid_resources
(
self
):
test_uri
=
self
.
base_courses_uri
+
'/1239878976/groups'
test_uri
=
self
.
base_courses_uri
+
'/1239878976/groups'
data
=
{
'group_id'
:
"98723896"
}
data
=
{
'group_id'
:
"98723896"
}
response
=
self
.
do_post
(
test_uri
,
data
)
response
=
self
.
do_post
(
test_uri
,
data
)
self
.
assertEqual
(
response
.
status_code
,
404
)
self
.
assertEqual
(
response
.
status_code
,
404
)
@unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
def
test_course_groups_detail_get
(
self
):
def
test_course_groups_detail_get
(
self
):
data
=
{
'name'
:
self
.
test_group_name
}
data
=
{
'name'
:
self
.
test_group_name
}
response
=
self
.
do_post
(
self
.
base_groups_uri
,
data
)
response
=
self
.
do_post
(
self
.
base_groups_uri
,
data
)
...
@@ -303,7 +288,6 @@ class CoursesApiTests(TestCase):
...
@@ -303,7 +288,6 @@ class CoursesApiTests(TestCase):
self
.
assertEqual
(
response
.
data
[
'course_id'
],
self
.
test_course_id
)
self
.
assertEqual
(
response
.
data
[
'course_id'
],
self
.
test_course_id
)
self
.
assertEqual
(
response
.
data
[
'group_id'
],
str
(
group_id
))
self
.
assertEqual
(
response
.
data
[
'group_id'
],
str
(
group_id
))
@unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
def
test_course_groups_detail_delete
(
self
):
def
test_course_groups_detail_delete
(
self
):
data
=
{
'name'
:
self
.
test_group_name
}
data
=
{
'name'
:
self
.
test_group_name
}
response
=
self
.
do_post
(
self
.
base_groups_uri
,
data
)
response
=
self
.
do_post
(
self
.
base_groups_uri
,
data
)
...
@@ -318,19 +302,16 @@ class CoursesApiTests(TestCase):
...
@@ -318,19 +302,16 @@ class CoursesApiTests(TestCase):
response
=
self
.
do_get
(
test_uri
)
response
=
self
.
do_get
(
test_uri
)
self
.
assertEqual
(
response
.
status_code
,
404
)
self
.
assertEqual
(
response
.
status_code
,
404
)
@unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
def
test_course_groups_detail_delete_invalid_course
(
self
):
def
test_course_groups_detail_delete_invalid_course
(
self
):
test_uri
=
'{}/123987102/groups/123124'
.
format
(
self
.
base_courses_uri
)
test_uri
=
'{}/123987102/groups/123124'
.
format
(
self
.
base_courses_uri
)
response
=
self
.
do_delete
(
test_uri
)
response
=
self
.
do_delete
(
test_uri
)
self
.
assertEqual
(
response
.
status_code
,
204
)
self
.
assertEqual
(
response
.
status_code
,
204
)
@unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
def
test_course_groups_detail_delete_invalid_group
(
self
):
def
test_course_groups_detail_delete_invalid_group
(
self
):
test_uri
=
'{}/{}/groups/123124'
.
format
(
self
.
base_courses_uri
,
self
.
test_course_id
)
test_uri
=
'{}/{}/groups/123124'
.
format
(
self
.
base_courses_uri
,
self
.
test_course_id
)
response
=
self
.
do_delete
(
test_uri
)
response
=
self
.
do_delete
(
test_uri
)
self
.
assertEqual
(
response
.
status_code
,
204
)
self
.
assertEqual
(
response
.
status_code
,
204
)
@unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
def
test_course_groups_detail_get_undefined
(
self
):
def
test_course_groups_detail_get_undefined
(
self
):
data
=
{
'name'
:
self
.
test_group_name
}
data
=
{
'name'
:
self
.
test_group_name
}
response
=
self
.
do_post
(
self
.
base_groups_uri
,
data
)
response
=
self
.
do_post
(
self
.
base_groups_uri
,
data
)
...
...
lms/djangoapps/api_manager/tests/test_groups_views.py
View file @
b8f70ff1
...
@@ -564,7 +564,6 @@ class GroupsApiTests(TestCase):
...
@@ -564,7 +564,6 @@ class GroupsApiTests(TestCase):
response
=
self
.
do_post
(
test_uri
,
data
)
response
=
self
.
do_post
(
test_uri
,
data
)
self
.
assertEqual
(
response
.
status_code
,
201
)
self
.
assertEqual
(
response
.
status_code
,
201
)
test_uri
=
'{}/{}/courses/{}'
.
format
(
self
.
base_groups_uri
,
group_id
,
self
.
test_course_id
)
test_uri
=
'{}/{}/courses/{}'
.
format
(
self
.
base_groups_uri
,
group_id
,
self
.
test_course_id
)
print
test_uri
response
=
self
.
do_get
(
test_uri
)
response
=
self
.
do_get
(
test_uri
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
response
.
status_code
,
200
)
confirm_uri
=
'{}{}/{}/courses/{}'
.
format
(
confirm_uri
=
'{}{}/{}/courses/{}'
.
format
(
...
...
lms/djangoapps/api_manager/tests/test_users_views.py
View file @
b8f70ff1
...
@@ -51,9 +51,6 @@ class UsersApiTests(TestCase):
...
@@ -51,9 +51,6 @@ class UsersApiTests(TestCase):
'X-Edx-Api-Key'
:
str
(
TEST_API_KEY
),
'X-Edx-Api-Key'
:
str
(
TEST_API_KEY
),
}
}
json_data
=
json
.
dumps
(
data
)
json_data
=
json
.
dumps
(
data
)
print
"POST: "
+
uri
print
json_data
print
""
response
=
self
.
client
.
post
(
uri
,
headers
=
headers
,
content_type
=
'application/json'
,
data
=
json_data
)
response
=
self
.
client
.
post
(
uri
,
headers
=
headers
,
content_type
=
'application/json'
,
data
=
json_data
)
return
response
return
response
...
...
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