diff --git a/README.md b/README.md index 7795efc..18bac42 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,8 @@ The second option is to use the helper functions in `dots_infrastructure.Calcula 1. Create a new python virtual environment 2. Install dependencies `pip install -r requirements.txt` 3. Install package `pip install -e .` -4. Run `python -m unittest discover -s ./test -p 'Test*.py'` +4. Run `cd test` +5. Run `python -m unittest discover -s ./ -p 'Test*.py'` ## Building a docker image such that it can be used diff --git a/test/TestTemplate.py b/test/TestTemplate.py index 432ef35..b7fae8f 100644 --- a/test/TestTemplate.py +++ b/test/TestTemplate.py @@ -3,6 +3,7 @@ from ExampleCalculationService.EConnection import CalculationServiceEConnection from dots_infrastructure.DataClasses import SimulatorConfiguration, SimulaitonDataPoint, TimeStepInformation from dots_infrastructure.test_infra.InfluxDBMock import InfluxDBMock +from esdl.esdl_handler import EnergySystemHandler import helics as h from dots_infrastructure import CalculationServiceHelperFunctions @@ -18,6 +19,9 @@ class Test(unittest.TestCase): def setUp(self): CalculationServiceHelperFunctions.get_simulator_configuration_from_environment = simulator_environment_e_connection + esh = EnergySystemHandler() + esh.load_file("test.esdl") + self.energy_system = esh.get_energy_system() def test_example(self): # Arrange @@ -25,10 +29,10 @@ def test_example(self): service.influx_connector = InfluxDBMock() pv_dispatch_params = {} pv_dispatch_params["PV_Dispatch"] = [1.0, 2.0] - service.init_calculation_service(None) + service.init_calculation_service(self.energy_system) # Execute - ret_val = service.e_connection_dispatch(pv_dispatch_params, datetime(2024,1,1), TimeStepInformation(1,2), "test-id", None) + ret_val = service.e_connection_dispatch(pv_dispatch_params, datetime(2024,1,1), TimeStepInformation(1,2), "test-id", self.energy_system) # Implement self.assertEqual(ret_val["EConnectionDispatch"], 3.0) diff --git a/test/test.esdl b/test/test.esdl new file mode 100644 index 0000000..a18b5e8 --- /dev/null +++ b/test/test.esdl @@ -0,0 +1,130 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +