diff --git a/ippisite/ippidb/tests/tests.py b/ippisite/ippidb/tests/tests.py index 3fcdf9fb443946b035d696ba8aab12458f8aa277..e61aa5d6db33e9000268bf842eb5fe299266caa5 100644 --- a/ippisite/ippidb/tests/tests.py +++ b/ippisite/ippidb/tests/tests.py @@ -7,7 +7,7 @@ from requests.exceptions import SSLError from django.contrib.auth import get_user_model from django.core.management import call_command -from django.test import TestCase +from django.test import TestCase, TransactionTestCase from django.urls import reverse import requests @@ -36,6 +36,7 @@ from ippidb.models import ( LeLleBiplotData, PcaBiplotData, Protein, + Symmetry, ) from .utils import create_dummy_compound @@ -94,7 +95,9 @@ class MolSmiTestCase(TestCase): self.assertEqual(response.status_code, 400) -class CompoundTanimotoTestCase(TestCase): +class CompoundTanimotoTestCase(TransactionTestCase): + reset_sequences = True + def setUp(self): self.smiles_dict = {1: "CC", 2: "CCC"} self.query = "CC" @@ -109,7 +112,9 @@ class CompoundTanimotoTestCase(TestCase): self.assertEqual(ct.tanimoto, 0.5) -class CompoundTanimotoTestCaseCompound1ECFP4(TestCase): +class CompoundTanimotoTestCaseCompound1ECFP4(TransactionTestCase): + reset_sequences = True + def setUp(self): self.smiles_dict = { 1: "CC(C)C(=O)c1cc(C(=O)c2ccc(Oc3ccccc3)cc2)c(O)c(O)c1O", @@ -128,7 +133,9 @@ class CompoundTanimotoTestCaseCompound1ECFP4(TestCase): self.assertEqual(float(ct2.tanimoto), 0.0971) -class CompoundAnnotationsTestCase(TestCase): +class CompoundAnnotationsTestCase(TransactionTestCase): + reset_sequences = True + def test_lipinsky_ok(self): # c is ok for Lipinsky c = create_dummy_compound(1, "CC") @@ -234,7 +241,9 @@ class CompoundAnnotationsTestCase(TestCase): self.assertFalse(c.pfizer) -class QueryCompoundViewsTestCase(TestCase): +class QueryCompoundViewsTestCase(TransactionTestCase): + reset_sequences = True + @classmethod def setUpTestData(cls): create_dummy_compound(1, "CC") @@ -325,7 +334,7 @@ def set_dummy_lelle_pca_props(c): c.save() -class QueryCompoundViewsAccessTestCase(TestCase): +class QueryCompoundViewsAccessTestCase(TransactionTestCase): """ Test the visibility of compounds belonging to validated or unvalidated contributions @@ -337,6 +346,8 @@ class QueryCompoundViewsAccessTestCase(TestCase): ============================================================================ """ + reset_sequences = True + @classmethod def setUpTestData(cls): """ @@ -348,7 +359,7 @@ class QueryCompoundViewsAccessTestCase(TestCase): - one validated contribution - 20 other compounds, so that a PCA can actually be computed on the data """ - symmetry = models.Symmetry() + symmetry = Symmetry() symmetry.code = "AS" symmetry.description = "asymmetric" symmetry.save() @@ -778,6 +789,10 @@ class TestConvertSMILESToIUPAC(TestCase): class DuplicateGeneNameTestCase(TestCase): + """ + Allow to have two proteins with the same gene_name and distinct uniprot_id + """ + def test_works(self): - models.Protein.objects.get_or_create(uniprot_id="P12497") - models.Protein.objects.get_or_create(uniprot_id="P0C6F2") + Protein.objects.get_or_create(uniprot_id="P12497") + Protein.objects.get_or_create(uniprot_id="P0C6F2")