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
9491edee
Commit
9491edee
authored
9 years ago
by
Mark Skipper
Browse files
Options
Downloads
Patches
Plain Diff
Test you can get stuff from the db via the api.
parent
5eae80d0
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
django/website/rest_api/tests/item_view_tests.py
+21
-7
21 additions, 7 deletions
django/website/rest_api/tests/item_view_tests.py
with
21 additions
and
7 deletions
django/website/rest_api/tests/item_view_tests.py
+
21
−
7
View file @
9491edee
from
__future__
import
unicode_literals
,
absolute_import
from
django.test
import
TestCase
from
rest_api.views
import
ItemList
from
rest_framework.test
import
APIRequestFactory
from
data_layer.tests.factories
import
ItemFactory
from
rest_api.views
import
ItemList
class
Handler
Tests
(
TestCase
):
class
ItemView
Tests
(
TestCase
):
factory
=
APIRequestFactory
()
def
get
(
self
,
view_class
,
url
):
view
=
view_class
.
as_view
()
request
=
APIRequestFactory
().
get
(
url
)
return
view
(
request
)
def
test_get_items_returns_empty_if_no_items
(
self
):
request
=
self
.
factory
.
get
(
'
/items/
'
)
view
=
ItemList
.
as_view
()
response
=
view
(
request
)
response
=
self
.
get
(
ItemList
,
'
/items/
'
)
self
.
assertEqual
(
response
.
data
,
[])
def
test_get_items_returns_all_items
(
self
):
item
=
ItemFactory
()
payload
=
self
.
get
(
ItemList
,
'
/items/
'
).
data
self
.
assertEqual
(
len
(
payload
),
1
)
self
.
assertEqual
(
payload
[
0
][
'
body
'
],
item
.
body
)
# I don't much care for this test.
# It's testing too much of the stack, and its messy because the payload
# isn't the same kind data strcture even as ItemSerializer(item).data
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