Commit 363f89f7 authored by Bryan  BRANCOTTE's avatar Bryan BRANCOTTE
Browse files

distinguishing for each models to prevent false-positive test passing when mixing up models

parent 612f2eba
...@@ -10,6 +10,7 @@ from django.core.files.uploadedfile import SimpleUploadedFile ...@@ -10,6 +10,7 @@ from django.core.files.uploadedfile import SimpleUploadedFile
from django.db.models import Count, Q from django.db.models import Count, Q
from django.test import TestCase from django.test import TestCase
from django.urls import reverse from django.urls import reverse
from django.utils import timezone
from viralhostrangedb import models, business_process from viralhostrangedb import models, business_process
...@@ -72,6 +73,18 @@ class ViewTestCase(TestCase): ...@@ -72,6 +73,18 @@ class ViewTestCase(TestCase):
self.no_lysis = models.GlobalViralHostResponseValue.objects_mappable().get(name="No infection") self.no_lysis = models.GlobalViralHostResponseValue.objects_mappable().get(name="No infection")
self.not_mapped_yet = models.GlobalViralHostResponseValue.get_not_mapped_yet() 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( self.private_data_source_of_user = models.DataSource.objects.create(
owner=self.user, owner=self.user,
......
...@@ -245,7 +245,7 @@ class CompleteResponseTestCase(ViewTestCase): ...@@ -245,7 +245,7 @@ class CompleteResponseTestCase(ViewTestCase):
no_lysis = models.GlobalViralHostResponseValue.objects_mappable().get(name="No infection").value no_lysis = models.GlobalViralHostResponseValue.objects_mappable().get(name="No infection").value
pk_ds = str(self.public_data_source_of_user_mapped.pk) 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) 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) response = self.client.get(url)
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
self.assertJSONEqual(str(response.content, encoding='utf8'), { self.assertJSONEqual(str(response.content, encoding='utf8'), {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment