diff --git a/python/lib/core/dmod/core/common/protocols.py b/python/lib/core/dmod/core/common/protocols.py index 0096d6a6d..4a39a57fc 100644 --- a/python/lib/core/dmod/core/common/protocols.py +++ b/python/lib/core/dmod/core/common/protocols.py @@ -67,7 +67,7 @@ class DescribableProtocol(typing.Protocol): # Strictly speaking, this should be a Sequence, but the type system does # not support fixed-length sequences. - DBAPIColumnDescription: typing.TypeAlias = tuple[ + DBAPIColumnDescription: typing.TypeAlias = typing.Tuple[ str, DBAPITypeCode, typing.Optional[int], diff --git a/python/lib/evaluations/dmod/evaluations/specification/base.py b/python/lib/evaluations/dmod/evaluations/specification/base.py index 15fbbd176..94474adda 100644 --- a/python/lib/evaluations/dmod/evaluations/specification/base.py +++ b/python/lib/evaluations/dmod/evaluations/specification/base.py @@ -23,8 +23,6 @@ from ..utilities import merge_dictionaries -from .template import TemplateManager - from .. import util from .helpers import is_a_value diff --git a/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/forms/json.py b/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/forms/json.py index 54ce5724c..9399d172f 100644 --- a/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/forms/json.py +++ b/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/forms/json.py @@ -107,13 +107,13 @@ class SpecificationTemplateForm(forms.ModelForm): """ A specialized form for SpecificationTemplate that allows its JSON data to be manipulated within a JSONArea """ - class Meta: - model = models.SpecificationTemplate - fields = [ - field.name - for field in models.SpecificationTemplate._meta.get_fields() - if field.name.lower() not in ("owner", "author") - ] + #class Meta: + # model = models.SpecificationTemplate + # fields = [ + # field.name + # for field in models.SpecificationTemplate._meta.get_fields() + # if field.name.lower() not in ("owner", "author") + # ] class Media: # Include a script to add functionality that will update the json area's diff --git a/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/specification.py b/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/specification.py index 7030af358..7a9090ad1 100644 --- a/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/specification.py +++ b/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/specification.py @@ -6,7 +6,6 @@ import os import typing import sqlite3 -from collections import defaultdict import re from dmod.core.common import DBAPIConnection @@ -28,7 +27,6 @@ class SpecificationTemplateManager(TemplateManager): """ Object manager used to provide details about available templates defined within the Django DB instance """ - def get_templates(self, specification_type: str) -> typing.Sequence[TemplateDetails]: def __init__(self, *args, **kwargs): pass diff --git a/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/tests/test_template_views.py b/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/tests/test_template_views.py index 9fae31310..7a4979217 100644 --- a/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/tests/test_template_views.py +++ b/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/tests/test_template_views.py @@ -45,7 +45,7 @@ def setUpTestData(cls): cls.token = Token.objects.create(user=cls.test_user) - cls.manager = FileTemplateManager(manifest_path=TEMPLATE_MANIFEST_PATH) + cls.manager = FileTemplateManager(path=TEMPLATE_MANIFEST_PATH) for template_details_group in cls.manager.get_all_templates().values(): for template_details in template_details_group: @@ -253,7 +253,6 @@ def test_search_templates(self): self.assertIsNotNone(matching_template) - def test_get_all_templates(self): get_response = self.client.get( "/evaluation_service/templates/" @@ -269,7 +268,7 @@ def test_get_all_templates(self): templates = get_data['templates'] self.assertTrue(isinstance(templates, typing.Mapping)) - self.assertEqual(len(templates), 9) + self.assertEqual(len(templates), 12) self.assertIn("BackendSpecification", templates) self.assertIn("FieldMappingSpecification", templates) @@ -280,6 +279,9 @@ def test_get_all_templates(self): self.assertIn("ThresholdDefinition", templates) self.assertIn("ThresholdApplicationRules", templates) self.assertIn("EvaluationSpecification", templates) + self.assertIn("CrosswalkSpecification", templates) + self.assertIn("DataSourceSpecification", templates) + self.assertIn("ThresholdSpecification", templates) self.assertEqual(len(templates['BackendSpecification']), 4) self.assertEqual(len(templates['FieldMappingSpecification']), 3) @@ -290,6 +292,9 @@ def test_get_all_templates(self): self.assertEqual(len(templates['ThresholdDefinition']), 3) self.assertEqual(len(templates['ThresholdApplicationRules']), 1) self.assertEqual(len(templates['EvaluationSpecification']), 5) + self.assertEqual(len(templates['CrosswalkSpecification']), 2) + self.assertEqual(len(templates["DataSourceSpecification"]), 4) + self.assertEqual(len(templates["ThresholdSpecification"]), 2) post_response = self.client.post( "/evaluation_service/templates/" diff --git a/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/tests/test_templatemanager.py b/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/tests/test_templatemanager.py new file mode 100644 index 000000000..1c919c92d --- /dev/null +++ b/python/services/evaluationservice/dmod/evaluationservice/evaluation_service/tests/test_templatemanager.py @@ -0,0 +1,66 @@ +from pathlib import Path + +from django.test import TestCase + +from dmod.evaluations.specification import TemplateManager +from evaluation_service import specification + + +# Create your tests here. +class SpecificationTemplateManager(TestCase): + """ + Tests to ensure that the SpecificationTemplateManager operates as expected, especially when it comes to exports + """ + control_manager: specification.SpecificationTemplateManager + export_directory: Path + + @classmethod + def setUpClass(cls) -> None: + """ + Set up the SpecificationTemplateManager that serves as a control for the tests and form the export path + """ + super().setUpClass() + cls.export_directory = Path(__file__).parent / 'data' / 'writing' / cls.__name__ + cls.export_directory.mkdir(parents=True, exist_ok=True) + + @classmethod + def tearDownClass(cls) -> None: + """ + Remove all artifacts generated by this test + """ + super().tearDownClass() + cls.export_directory.rmdir() + + def test_database_export(self): + """ + Test to ensure that `self.control_manager.export_database` works + """ + ... + + def test_inmemory_export(self): + """ + Test to ensure that the contents of the control_manager can be exported into an inmemory object and reloaded + into another manager + """ + ... + + def test_file_export(self): + """ + Test to ensure that the contents of the control manager can be correctly exported to files + """ + ... + + def test_file_imports(self): + """ + Test the control_manager to ensure that its contents are correct for the other tests + """ + self.verify_templatemanager_contents(self.control_manager) + + def verify_templatemanager_contents(self, manager: TemplateManager): + """ + Ensure that the passed in manager contain the correct contents + + Args: + manager: The manager whose contents to test + """ + ...