Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
hub
ViralHostRangeDB
Commits
363f89f7
Commit
363f89f7
authored
Oct 07, 2019
by
Bryan BRANCOTTE
Browse files
distinguishing for each models to prevent false-positive test passing when mixing up models
parent
612f2eba
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/viralhostrange/viralhostrangedb/tests/test_views.py
View file @
363f89f7
...
...
@@ -10,6 +10,7 @@ from django.core.files.uploadedfile import SimpleUploadedFile
from
django.db.models
import
Count
,
Q
from
django.test
import
TestCase
from
django.urls
import
reverse
from
django.utils
import
timezone
from
viralhostrangedb
import
models
,
business_process
...
...
@@ -72,6 +73,18 @@ class ViewTestCase(TestCase):
self
.
no_lysis
=
models
.
GlobalViralHostResponseValue
.
objects_mappable
().
get
(
name
=
"No infection"
)
self
.
not_mapped_yet
=
models
.
GlobalViralHostResponseValue
.
get_not_mapped_yet
()
################################################################################
# set the pk to different starting value for each model to avoid
models
.
Virus
.
objects
.
create
(
name
=
"won't last"
,
pk
=
0
).
delete
()
models
.
Host
.
objects
.
create
(
name
=
"won't last"
,
pk
=
100
).
delete
()
models
.
DataSource
.
objects
.
create
(
owner
=
self
.
toto
,
name
=
"won't last"
,
raw_name
=
"won't last"
,
pk
=
200
,
creation_date
=
timezone
.
now
(),
).
delete
()
################################################################################
self
.
private_data_source_of_user
=
models
.
DataSource
.
objects
.
create
(
owner
=
self
.
user
,
...
...
src/viralhostrange/viralhostrangedb/tests/test_views_api.py
View file @
363f89f7
...
...
@@ -245,7 +245,7 @@ class CompleteResponseTestCase(ViewTestCase):
no_lysis
=
models
.
GlobalViralHostResponseValue
.
objects_mappable
().
get
(
name
=
"No infection"
).
value
pk_ds
=
str
(
self
.
public_data_source_of_user_mapped
.
pk
)
pk_host
=
str
(
self
.
public_data_source_of_user_mapped
.
host_set
.
first
().
pk
)
url
=
reverse
(
'viralhostrangedb-api:responses'
)
+
"?format=json&ds=
3
&host=%s"
%
pk_host
url
=
reverse
(
'viralhostrangedb-api:responses'
)
+
"?format=json&ds=
%s
&host=%s"
%
(
pk_ds
,
pk_host
)
response
=
self
.
client
.
get
(
url
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertJSONEqual
(
str
(
response
.
content
,
encoding
=
'utf8'
),
{
...
...
Write
Preview
Supports
Markdown
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