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
c1916e45
Commit
c1916e45
authored
9 years ago
by
Martin Burchell
Browse files
Options
Downloads
Patches
Plain Diff
Refactored tests to use REST API
In this case for counting taxonomies
parent
63bf3d73
No related branches found
Branches containing commit
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/taxonomy_and_term_create_tests.py
+16
-2
16 additions, 2 deletions
.../website/rest_api/tests/taxonomy_and_term_create_tests.py
with
16 additions
and
2 deletions
django/website/rest_api/tests/taxonomy_and_term_create_tests.py
+
16
−
2
View file @
c1916e45
...
...
@@ -25,17 +25,31 @@ def create_category(name):
return
view
(
request
,
pk
=
id
)
def
count_taxonomies
():
return
len
(
get_taxonomies
().
data
)
def
get_taxonomies
():
url
=
reverse
(
'
taxonomy-list
'
)
request
=
APIRequestFactory
().
get
(
url
)
view
=
TaxonomyViewSet
.
as_view
(
actions
=
{
'
get
'
:
'
list
'
})
response
=
view
(
request
)
assert
status
.
is_success
(
response
.
status_code
),
response
.
data
return
response
@pytest.mark.django_db
def
test_create_a_category
():
category
=
"
Test Ebola Questions
"
old_count
=
Taxonomy
.
objects
.
count
()
old_count
=
count_taxonomies
()
assert
not
Taxonomy
.
objects
.
filter
(
name
=
category
).
exists
()
response
=
create_category
(
category
)
assert
status
.
is_success
(
response
.
status_code
),
response
.
data
new_count
=
Taxonomy
.
objects
.
count
()
new_count
=
count_taxonomies
()
assert
new_count
-
old_count
==
1
assert
Taxonomy
.
objects
.
filter
(
name
=
category
).
exists
()
...
...
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