diff --git a/ModulectorBackend/settings.py b/ModulectorBackend/settings.py index ab5d1f7..1cd60b3 100644 --- a/ModulectorBackend/settings.py +++ b/ModulectorBackend/settings.py @@ -163,6 +163,9 @@ MEDIA_ROOT = os.getenv('MEDIA_ROOT', os.path.join(BASE_DIR, '')) MEDIA_URL = os.getenv('MEDIA_URL', '/media/') +# Test runner +TEST_RUNNER = 'modulector.tests.runner.DjangoTestSuiteRunner' + # Email Server EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' # This email configuration is what postfix uses, for production, use your own diff --git a/modulector/tests/data_init.py b/modulector/tests/data_init.py deleted file mode 100644 index d4d11ac..0000000 --- a/modulector/tests/data_init.py +++ /dev/null @@ -1,72 +0,0 @@ -from datetime import datetime -from django.utils import timezone -from modulector.models import MirbaseIdMirna, UrlTemplate, Mirna, OldRefSeqMapping, GeneSymbolMapping, MirnaSource, \ - MirnaColumns, MirnaXGene, MirnaDisease, MirnaDrug - - -def load_test_data(cls): - MirbaseIdMirna.objects.create( - mirbase_accession_id='MIRBASETEST', - mature_mirna='hsa-test-1' - ) - UrlTemplate.objects.create( - name='mirdb', - url='test/url/com' - ) - mirna = Mirna.objects.create( - mirna_code='ASDAS_SDA@_SDASD' - ) - OldRefSeqMapping.objects.create( - old_value='NM_ASDAS', - new_value='NMAS@!DS' - ) - GeneSymbolMapping.objects.create( - refseq='REFSEQEXAMPLE', - symbol='SYMBOLTEST' - ) - source = MirnaSource.objects.create( - name='source', - site_url='this_site_url', - min_score=0, - max_score=70, - score_interpretation='this is a score interpretation', - description='this is a description', - synchronization_date=datetime.now(tz=timezone.utc), - file_separator='t' - ) - - MirnaColumns.objects.create( - mirna_source=source, - position=1, - column_name='column_name', - field_to_map='field_to_map' - - ) - - MirnaXGene.objects.create( - mirna=mirna, - gene='GEN_1', - score=80, - mirna_source=source - ) - - MirnaDisease.objects.create( - category='CAT', - mirna='MIRNA', - disease='DIS', - pubmed_id='12312312', - description='this is a description' - ) - - MirnaDrug.objects.create( - mature_mirna='ASSSDWA', - mirbase_accession_id='NMAEASDE', - small_molecule='SOME TEST', - fda_approved=True, - detection_method='detect method', - condition='condition this', - pubmed_id=2312, - reference='reference ', - support='suppport', - expression_pattern='pattern' - ) diff --git a/modulector/tests/runner.py b/modulector/tests/runner.py new file mode 100644 index 0000000..8e1aec6 --- /dev/null +++ b/modulector/tests/runner.py @@ -0,0 +1,13 @@ +from django.test.runner import DiscoverRunner + + +class DjangoTestSuiteRunner(DiscoverRunner): + """ + This runner prevents Django from creating and destroying the test database. This is useful as Modulector has + read-only preloaded data in the database. + """ + def setup_databases(self, **kwargs): + pass + + def teardown_databases(self, old_config, **kwargs): + pass diff --git a/modulector/tests/test_views.py b/modulector/tests/test_views.py index d604285..4c6865e 100644 --- a/modulector/tests/test_views.py +++ b/modulector/tests/test_views.py @@ -1,14 +1,9 @@ from django.test import Client, TestCase -from modulector.tests.data_init import load_test_data client = Client() class ViewTests(TestCase): - @classmethod - def setUpTestData(cls): - load_test_data(cls) - def __check_empty_pagination(self, response): """Checks if fields of response are valid for an empty pagination response""" self.assertEqual(response.data['count'], 0)