Improvement in the unit tests

This commit is contained in:
Guille Gutierrez 2021-08-27 13:28:49 -04:00
parent 62bca29a82
commit 624e9f3aa2
3 changed files with 6 additions and 71 deletions

View File

@ -1,59 +0,0 @@
"""
C40 test
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2020 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
"""
from pathlib import Path
from unittest import TestCase
from imports.geometry_factory import GeometryFactory
from imports.construction_factory import ConstructionFactory
from imports.weather_factory import WeatherFactory
from exports.exports_factory import ExportsFactory
class TestC40(TestCase):
"""
C40 TestCase 1
"""
def setUp(self) -> None:
"""
Test setup
:return: None
"""
self._city_gml = None
self._example_path = (Path(__file__).parent / 'tests_data').resolve()
def _get_citygml(self, file):
if self._city_gml is None:
file_path = (self._example_path / file).resolve()
self._city_gml = GeometryFactory('citygml', file_path).city
self.assertIsNotNone(self._city_gml, 'city is none')
return self._city_gml
def test_c40_enrichment(self):
"""
Enrich the C40 building
"""
file = 'C40_Final.gml'
base_path = (Path(__file__).parent.parent / 'data' / 'weather').resolve()
weather_file_name = 'CAN_PQ_Montreal.Intl.AP.716270_CWEC.epw'
city = self._get_citygml(file)
for building in city.buildings:
for thermal_zone in building.thermal_zones:
for thermal_boundary in thermal_zone.thermal_boundaries:
thermal_boundary.hi = 10
thermal_boundary.he = 25
for thermal_opening in thermal_boundary.thermal_openings:
thermal_opening.hi = 10
thermal_opening.he = 25
building.function = 'residential'
ConstructionFactory('nrel', city).enrich()
for building in city.buildings:
print(building.name, building.function, len(building.surfaces))
print(building.volume)
for thermal_zone in building.thermal_zones:
print(thermal_zone.volume)
print(thermal_zone.floor_area)
WeatherFactory('epw', city, base_path=base_path, file_name=weather_file_name).enrich()
ExportsFactory('idf', city, r'c:\Documents\idf').export()

View File

@ -23,7 +23,8 @@ class TestConstructionFactory(TestCase):
self._city = None self._city = None
self._example_path = (Path(__file__).parent / 'tests_data').resolve() self._example_path = (Path(__file__).parent / 'tests_data').resolve()
def _get_citygml(self, file): def _get_citygml(self):
file = 'pluto_building.gml'
file_path = (self._example_path / file).resolve() file_path = (self._example_path / file).resolve()
self._city = GeometryFactory('citygml', file_path).city self._city = GeometryFactory('citygml', file_path).city
self.assertIsNotNone(self._city, 'city is none') self.assertIsNotNone(self._city, 'city is none')
@ -35,18 +36,11 @@ class TestConstructionFactory(TestCase):
:return: None :return: None
""" """
# todo: file = 'pluto_building.gml' -> it has 0 surfaces!! city = self._get_citygml()
file = 'pluto_building.gml'
city = self._get_citygml(file)
for building in city.buildings: for building in city.buildings:
building.function = GeometryHelper.pluto_to_function[building.function] building.function = GeometryHelper.pluto_to_function[building.function]
for thermal_zone in building.thermal_zones: self.assertIsNotNone(building.surfaces, 'Building has no surfaces')
for thermal_boundary in thermal_zone.thermal_boundaries:
thermal_boundary.hi = 10
thermal_boundary.he = 25
for thermal_opening in thermal_boundary.thermal_openings:
thermal_opening.hi = 10
thermal_opening.he = 25
# case 1: NREL # case 1: NREL
ConstructionFactory('nrel', city).enrich() ConstructionFactory('nrel', city).enrich()
for building in city.buildings: for building in city.buildings:

View File

@ -142,7 +142,7 @@ class TestGeometryFactory(TestCase):
self.assertIsNotNone(thermal_boundary.type, 'thermal_boundary type is none') self.assertIsNotNone(thermal_boundary.type, 'thermal_boundary type is none')
self.assertIsNotNone(thermal_boundary.area, 'thermal_boundary area is none') self.assertIsNotNone(thermal_boundary.area, 'thermal_boundary area is none')
self.assertIsNotNone(thermal_boundary.azimuth, 'thermal_boundary azimuth is none') self.assertIsNotNone(thermal_boundary.azimuth, 'thermal_boundary azimuth is none')
self.assertIsNotNone(thermal_boundary.delimits, 'thermal_boundary delimits is none') self.assertIsNotNone(thermal_boundary.thermal_zones, 'thermal_boundary delimits is none')
self.assertIsNotNone(thermal_boundary.inclination, 'thermal_boundary inclination is none') self.assertIsNotNone(thermal_boundary.inclination, 'thermal_boundary inclination is none')
def test_citygml_thermal_opening(self): def test_citygml_thermal_opening(self):