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
63bf3d73
Commit
63bf3d73
authored
9 years ago
by
Martin Burchell
Browse files
Options
Downloads
Patches
Plain Diff
Refactored tests to use the REST API
parent
97cdce9b
No related branches found
No related tags found
1 merge request
!9
Refactored REST API tests to use the API where possible
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
django/website/rest_api/tests/item_list_view_tests.py
+13
-5
13 additions, 5 deletions
django/website/rest_api/tests/item_list_view_tests.py
with
13 additions
and
5 deletions
django/website/rest_api/tests/item_list_view_tests.py
+
13
−
5
View file @
63bf3d73
...
...
@@ -6,6 +6,8 @@ from taxonomies.tests.factories import TermFactory
from
..views
import
ItemViewSet
from
.item_create_view_tests
import
create_item
def
get
(
data
=
None
):
view
=
ItemViewSet
.
as_view
(
actions
=
{
'
get
'
:
'
list
'
})
...
...
@@ -22,7 +24,7 @@ def test_get_items_returns_empty_if_no_items():
@pytest.mark.django_db
def
test_get_items_returns_all_items
():
item
=
ItemFactory
(
body
=
'
test
'
)
create_item
(
body
=
'
test
'
)
items
=
get
().
data
...
...
@@ -33,8 +35,8 @@ def test_get_items_returns_all_items():
@pytest.mark.django_db
def
test_filter_by_body
():
ItemFactory
(
body
=
"
one
"
)
ItemFactory
(
body
=
"
two
"
)
create_item
(
body
=
"
one
"
)
create_item
(
body
=
"
two
"
)
payload
=
get
(
data
=
{
'
body
'
:
'
one
'
}).
data
...
...
@@ -44,8 +46,12 @@ def test_filter_by_body():
@pytest.mark.django_db
def
test_filter_by_id_list
():
ItemFactory
()
item_ids
=
[
ItemFactory
().
id
for
i
in
range
(
10
)]
create_item
(
body
=
'
initial item
'
)
item_ids
=
[]
for
i
in
range
(
10
):
item
=
create_item
(
body
=
'
item %d
'
%
i
).
data
item_ids
.
append
(
item
[
'
id
'
])
payload
=
get
(
data
=
{
'
ids
'
:
item_ids
}).
data
...
...
@@ -54,6 +60,8 @@ def test_filter_by_id_list():
@pytest.mark.django_db
def
test_item_listed_with_associated_terms
():
# TODO: Refactor to use the REST API when we can add
# multiple terms to an item
item
=
ItemFactory
()
terms
=
[
TermFactory
()
for
i
in
range
(
3
)]
for
term
in
terms
:
...
...
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