Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
I
internewshid
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
aptivate
client-projects
internewshid
Commits
bce2e6c3
Commit
bce2e6c3
authored
9 years ago
by
Mark Skipper
Browse files
Options
Downloads
Patches
Plain Diff
Allow create items through api
parent
cbebe04f
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
django/website/rest_api/tests/item_create_view_tests.py
+19
-0
19 additions, 0 deletions
django/website/rest_api/tests/item_create_view_tests.py
django/website/rest_api/views.py
+1
-1
1 addition, 1 deletion
django/website/rest_api/views.py
with
20 additions
and
1 deletion
django/website/rest_api/tests/item_create_view_tests.py
0 → 100644
+
19
−
0
View file @
bce2e6c3
from
__future__
import
unicode_literals
,
absolute_import
import
pytest
from
rest_framework.test
import
APIRequestFactory
from
rest_api.views
import
ItemList
@pytest.mark.django_db
def
test_create_item
():
item
=
{
'
body
'
:
"
Text
"
}
request
=
APIRequestFactory
().
post
(
'
/items
'
,
item
)
view
=
ItemList
.
as_view
()
response
=
view
(
request
)
assert
response
.
status_code
==
201
assert
response
.
data
[
'
body
'
]
==
"
Text
"
This diff is collapsed.
Click to expand it.
django/website/rest_api/views.py
+
1
−
1
View file @
bce2e6c3
...
...
@@ -3,7 +3,7 @@ from data_layer.models import Item
from
.serializers
import
ItemSerializer
class
ItemList
(
generics
.
ListAPIView
):
class
ItemList
(
generics
.
List
Create
APIView
):
queryset
=
Item
.
objects
.
all
()
serializer_class
=
ItemSerializer
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment