Skip to content
Snippets Groups Projects
Commit 520ee4f4 authored by Hervé  MENAGER's avatar Hervé MENAGER
Browse files

reset DB properly in CI tests module

- use TransactionTestCase and reset_sequences when relevant
- a few minor style and docs improvements
parent 23df1de0
No related branches found
No related tags found
2 merge requests!43K8S deployments of release branche, and other updates,!35migrate iPPI-DB to Django 4.0
Pipeline #72509 failed
...@@ -7,7 +7,7 @@ from requests.exceptions import SSLError ...@@ -7,7 +7,7 @@ from requests.exceptions import SSLError
from django.contrib.auth import get_user_model from django.contrib.auth import get_user_model
from django.core.management import call_command from django.core.management import call_command
from django.test import TestCase from django.test import TestCase, TransactionTestCase
from django.urls import reverse from django.urls import reverse
import requests import requests
...@@ -36,6 +36,7 @@ from ippidb.models import ( ...@@ -36,6 +36,7 @@ from ippidb.models import (
LeLleBiplotData, LeLleBiplotData,
PcaBiplotData, PcaBiplotData,
Protein, Protein,
Symmetry,
) )
from .utils import create_dummy_compound from .utils import create_dummy_compound
...@@ -94,7 +95,9 @@ class MolSmiTestCase(TestCase): ...@@ -94,7 +95,9 @@ class MolSmiTestCase(TestCase):
self.assertEqual(response.status_code, 400) self.assertEqual(response.status_code, 400)
class CompoundTanimotoTestCase(TestCase): class CompoundTanimotoTestCase(TransactionTestCase):
reset_sequences = True
def setUp(self): def setUp(self):
self.smiles_dict = {1: "CC", 2: "CCC"} self.smiles_dict = {1: "CC", 2: "CCC"}
self.query = "CC" self.query = "CC"
...@@ -109,7 +112,9 @@ class CompoundTanimotoTestCase(TestCase): ...@@ -109,7 +112,9 @@ class CompoundTanimotoTestCase(TestCase):
self.assertEqual(ct.tanimoto, 0.5) self.assertEqual(ct.tanimoto, 0.5)
class CompoundTanimotoTestCaseCompound1ECFP4(TestCase): class CompoundTanimotoTestCaseCompound1ECFP4(TransactionTestCase):
reset_sequences = True
def setUp(self): def setUp(self):
self.smiles_dict = { self.smiles_dict = {
1: "CC(C)C(=O)c1cc(C(=O)c2ccc(Oc3ccccc3)cc2)c(O)c(O)c1O", 1: "CC(C)C(=O)c1cc(C(=O)c2ccc(Oc3ccccc3)cc2)c(O)c(O)c1O",
...@@ -128,7 +133,9 @@ class CompoundTanimotoTestCaseCompound1ECFP4(TestCase): ...@@ -128,7 +133,9 @@ class CompoundTanimotoTestCaseCompound1ECFP4(TestCase):
self.assertEqual(float(ct2.tanimoto), 0.0971) self.assertEqual(float(ct2.tanimoto), 0.0971)
class CompoundAnnotationsTestCase(TestCase): class CompoundAnnotationsTestCase(TransactionTestCase):
reset_sequences = True
def test_lipinsky_ok(self): def test_lipinsky_ok(self):
# c is ok for Lipinsky # c is ok for Lipinsky
c = create_dummy_compound(1, "CC") c = create_dummy_compound(1, "CC")
...@@ -234,7 +241,9 @@ class CompoundAnnotationsTestCase(TestCase): ...@@ -234,7 +241,9 @@ class CompoundAnnotationsTestCase(TestCase):
self.assertFalse(c.pfizer) self.assertFalse(c.pfizer)
class QueryCompoundViewsTestCase(TestCase): class QueryCompoundViewsTestCase(TransactionTestCase):
reset_sequences = True
@classmethod @classmethod
def setUpTestData(cls): def setUpTestData(cls):
create_dummy_compound(1, "CC") create_dummy_compound(1, "CC")
...@@ -325,7 +334,7 @@ def set_dummy_lelle_pca_props(c): ...@@ -325,7 +334,7 @@ def set_dummy_lelle_pca_props(c):
c.save() c.save()
class QueryCompoundViewsAccessTestCase(TestCase): class QueryCompoundViewsAccessTestCase(TransactionTestCase):
""" """
Test the visibility of compounds belonging to Test the visibility of compounds belonging to
validated or unvalidated contributions validated or unvalidated contributions
...@@ -337,6 +346,8 @@ class QueryCompoundViewsAccessTestCase(TestCase): ...@@ -337,6 +346,8 @@ class QueryCompoundViewsAccessTestCase(TestCase):
============================================================================ ============================================================================
""" """
reset_sequences = True
@classmethod @classmethod
def setUpTestData(cls): def setUpTestData(cls):
""" """
...@@ -348,7 +359,7 @@ class QueryCompoundViewsAccessTestCase(TestCase): ...@@ -348,7 +359,7 @@ class QueryCompoundViewsAccessTestCase(TestCase):
- one validated contribution - one validated contribution
- 20 other compounds, so that a PCA can actually be computed on the data - 20 other compounds, so that a PCA can actually be computed on the data
""" """
symmetry = models.Symmetry() symmetry = Symmetry()
symmetry.code = "AS" symmetry.code = "AS"
symmetry.description = "asymmetric" symmetry.description = "asymmetric"
symmetry.save() symmetry.save()
...@@ -778,6 +789,10 @@ class TestConvertSMILESToIUPAC(TestCase): ...@@ -778,6 +789,10 @@ class TestConvertSMILESToIUPAC(TestCase):
class DuplicateGeneNameTestCase(TestCase): class DuplicateGeneNameTestCase(TestCase):
"""
Allow to have two proteins with the same gene_name and distinct uniprot_id
"""
def test_works(self): def test_works(self):
models.Protein.objects.get_or_create(uniprot_id="P12497") Protein.objects.get_or_create(uniprot_id="P12497")
models.Protein.objects.get_or_create(uniprot_id="P0C6F2") Protein.objects.get_or_create(uniprot_id="P0C6F2")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment