From 62e561824bc6388e62f7f71e42267d562d0bf1b8 Mon Sep 17 00:00:00 2001 From: pilar Date: Fri, 6 Nov 2020 05:40:17 -0500 Subject: [PATCH] added usage unittest --- tests/test_physics_factory.py | 2 +- tests/test_usage_factory.py | 58 +++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 tests/test_usage_factory.py diff --git a/tests/test_physics_factory.py b/tests/test_physics_factory.py index 5654c957..024223ef 100644 --- a/tests/test_physics_factory.py +++ b/tests/test_physics_factory.py @@ -38,7 +38,7 @@ class TestPhysicsFactory(TestCase): def test_city_with_physics(self): """ - Enrich the city with the physic information and verify ot + Enrich the city with the physic information and verify it :return: None """ city = self._get_city_with_physics() diff --git a/tests/test_usage_factory.py b/tests/test_usage_factory.py new file mode 100644 index 00000000..bb9b582c --- /dev/null +++ b/tests/test_usage_factory.py @@ -0,0 +1,58 @@ +""" +TestUsageFactory test and validate the city model structure usage parameters +SPDX - License - Identifier: LGPL - 3.0 - or -later +Copyright © 2020 Project Author Pilar Monsalvete pilar_monsalvete@yahoo.es +""" +from pathlib import Path +from unittest import TestCase + +from factories.geometry_factory import GeometryFactory +from factories.usage_factory import UsageFactory + + +class TestUsageFactory(TestCase): + """ + TestUsageFactory TestCase + """ + def setUp(self) -> None: + """ + Configure test environment + :return: + """ + self._city_gml = None + self._nyc_with_usage = None + self._example_path = (Path(__file__).parent.parent / 'tests_data').resolve() + + def _get_citygml(self): + if self._city_gml is None: + file_path = (self._example_path / '20buildings.gml').resolve() + self._city_gml = GeometryFactory('citygml', file_path).city + self.assertIsNotNone(self._city_gml, 'city is none') + return self._city_gml + + def _get_city_with_usage(self): + if self._nyc_with_usage is None: + self._nyc_with_usage = self._get_citygml() + UsageFactory('us_new_york', self._nyc_with_usage) + return self._nyc_with_usage + + def test_city_with_usage(self): + """ + Enrich the city with the usage information and verify it + :return: None + """ + city = self._get_city_with_usage() + for building in city.buildings: + for usage_zone in building.usage_zones: + self.assertIsNotNone(usage_zone.usage, 'usage is none') + self.assertIsNotNone(usage_zone.internal_gains, 'usage is none') + self.assertIsNotNone(usage_zone.cooling_setpoint, 'usage is none') + self.assertIsNotNone(usage_zone.heating_setback, 'usage is none') + self.assertIsNotNone(usage_zone.heating_setpoint, 'usage is none') + self.assertIsNotNone(usage_zone.occupancy_density, 'usage is none') + self.assertIsNotNone(usage_zone.hours_day, 'usage is none') + self.assertIsNotNone(usage_zone.days_year, 'usage is none') + self.assertIsNotNone(usage_zone.dhw_average_volume_pers_day, 'usage is none') + self.assertIsNotNone(usage_zone.dhw_preparation_temperature, 'usage is none') + self.assertIsNotNone(usage_zone.electrical_app_average_consumption_sqm_year, 'usage is none') + # todo: missing occupancy, schedules and heating schedule