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
2ffcbadd
Commit
2ffcbadd
authored
May 02, 2014
by
Matt Drayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Name is now required during group creation
parent
bab76c29
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
10 deletions
+23
-10
lms/djangoapps/api_manager/groups/tests.py
+17
-6
lms/djangoapps/api_manager/groups/views.py
+6
-4
lms/djangoapps/api_manager/tests/__init__.py
+0
-0
No files found.
lms/djangoapps/api_manager/groups/tests.py
View file @
2ffcbadd
...
...
@@ -153,14 +153,22 @@ class GroupsApiTests(TestCase):
self
.
assertEqual
(
response
.
data
[
0
][
'name'
],
self
.
test_group_name
)
self
.
assertEqual
(
response
.
data
[
0
][
'data'
][
'display_name'
],
'My updated series'
)
def
test_group_list_
get_uses_base_group
_name
(
self
):
def
test_group_list_
post_invalid
_name
(
self
):
data
=
{
'name'
:
''
}
response
=
self
.
do_post
(
self
.
base_groups_uri
,
data
)
self
.
assertEqual
(
response
.
status_code
,
400
)
def
test_group_list_get_uses_base_group_name
(
self
):
data
=
{
'name'
:
self
.
test_group_name
}
response
=
self
.
do_post
(
self
.
base_groups_uri
,
data
)
self
.
assertEqual
(
response
.
status_code
,
201
)
group_id
=
response
.
data
[
'id'
]
profile
=
GroupProfile
.
objects
.
get
(
group_id
=
group_id
)
profile
.
name
=
''
profile
.
save
()
response
=
self
.
do_get
(
self
.
base_groups_uri
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
response
.
data
[
0
][
'name'
],
'{:04d}:
'
.
format
(
group_id
))
self
.
assertEqual
(
response
.
data
[
0
][
'name'
],
'{:04d}:
{}'
.
format
(
group_id
,
self
.
test_group_name
))
def
test_group_detail_get
(
self
):
data
=
{
'name'
:
self
.
test_group_name
}
...
...
@@ -177,21 +185,24 @@ class GroupsApiTests(TestCase):
self
.
assertEqual
(
response
.
data
[
'name'
],
self
.
test_group_name
)
def
test_group_detail_get_uses_base_group_name
(
self
):
data
=
{
'name'
:
''
}
data
=
{
'name'
:
self
.
test_group_name
}
response
=
self
.
do_post
(
self
.
base_groups_uri
,
data
)
self
.
assertEqual
(
response
.
status_code
,
201
)
self
.
assertGreater
(
response
.
data
[
'id'
],
0
)
group_id
=
response
.
data
[
'id'
]
profile
=
GroupProfile
.
objects
.
get
(
group_id
=
group_id
)
profile
.
name
=
''
profile
.
save
()
test_uri
=
self
.
base_groups_uri
+
'/'
+
str
(
group_id
)
response
=
self
.
do_get
(
test_uri
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
response
.
data
[
'id'
],
group_id
)
confirm_uri
=
self
.
test_server_prefix
+
test_uri
self
.
assertEqual
(
response
.
data
[
'uri'
],
confirm_uri
)
self
.
assertEqual
(
response
.
data
[
'name'
],
'{:04d}:
'
.
format
(
group_id
))
self
.
assertEqual
(
response
.
data
[
'name'
],
'{:04d}:
{}'
.
format
(
group_id
,
self
.
test_group_name
))
def
test_group_detail_get_with_missing_profile
(
self
):
data
=
{
'name'
:
''
}
data
=
{
'name'
:
self
.
test_group_name
}
response
=
self
.
do_post
(
self
.
base_groups_uri
,
data
)
self
.
assertEqual
(
response
.
status_code
,
201
)
self
.
assertGreater
(
response
.
data
[
'id'
],
0
)
...
...
@@ -203,7 +214,7 @@ class GroupsApiTests(TestCase):
self
.
assertEqual
(
response
.
data
[
'id'
],
group_id
)
confirm_uri
=
self
.
test_server_prefix
+
test_uri
self
.
assertEqual
(
response
.
data
[
'uri'
],
confirm_uri
)
self
.
assertEqual
(
response
.
data
[
'name'
],
'{:04d}:
'
.
format
(
group_id
))
self
.
assertEqual
(
response
.
data
[
'name'
],
'{:04d}:
{}'
.
format
(
group_id
,
self
.
test_group_name
))
def
test_group_detail_get_undefined
(
self
):
test_uri
=
self
.
base_groups_uri
+
'/123456789'
...
...
lms/djangoapps/api_manager/groups/views.py
View file @
2ffcbadd
...
...
@@ -46,8 +46,10 @@ class GroupsList(APIView):
base_uri
=
_generate_base_uri
(
request
)
# Group name must be unique, but we need to support dupes
group
=
Group
.
objects
.
create
(
name
=
str
(
uuid
.
uuid4
()))
original_group_name
=
request
.
DATA
[
'name'
]
if
request
.
DATA
.
get
(
'name'
):
original_group_name
=
request
.
DATA
.
get
(
'name'
)
else
:
return
Response
(
response_data
,
status
=
status
.
HTTP_400_BAD_REQUEST
)
group
.
name
=
'{:04d}: {}'
.
format
(
group
.
id
,
original_group_name
)
group
.
record_active
=
True
group
.
record_date_created
=
timezone
.
now
()
...
...
@@ -61,9 +63,9 @@ class GroupsList(APIView):
group_type
=
request
.
DATA
.
get
(
'group_type'
,
None
)
data
=
json
.
dumps
(
request
.
DATA
.
get
(
'data'
))
if
request
.
DATA
.
get
(
'data'
)
else
{}
profile
,
_
=
GroupProfile
.
objects
.
get_or_create
(
group_id
=
group
.
id
,
group_type
=
group_type
,
name
=
original_group_name
,
data
=
data
)
response_data
=
{
'id'
:
group
.
id
,
'id'
:
group
.
id
,
'name'
:
original_group_name
,
'type'
:
group_type
,
}
...
...
lms/djangoapps/api_manager/tests/__init__.py
deleted
100644 → 0
View file @
bab76c29
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