2021-03-16 12:33:22 -04:00
|
|
|
"""
|
|
|
|
TestExports test and validate the city export formats
|
|
|
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
|
|
|
Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
|
2021-04-07 11:47:39 -04:00
|
|
|
Contributors Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
2021-03-16 12:33:22 -04:00
|
|
|
"""
|
|
|
|
|
|
|
|
from pathlib import Path
|
|
|
|
from unittest import TestCase
|
2021-04-07 11:46:44 -04:00
|
|
|
import pandas as pd
|
2021-03-25 09:11:30 -04:00
|
|
|
from imports.geometry_factory import GeometryFactory
|
2021-04-07 11:46:44 -04:00
|
|
|
from imports.physics_factory import PhysicsFactory
|
|
|
|
from imports.schedules_factory import SchedulesFactory
|
|
|
|
from imports.usage_factory import UsageFactory
|
2021-03-16 12:33:22 -04:00
|
|
|
from exports.exports_factory import ExportsFactory
|
2021-03-16 16:58:52 -04:00
|
|
|
|
2021-03-23 10:13:01 -04:00
|
|
|
|
2021-03-16 12:33:22 -04:00
|
|
|
class TestExports(TestCase):
|
|
|
|
"""
|
2021-04-07 11:46:44 -04:00
|
|
|
TestExports class contains the unittest for export functionality
|
2021-03-16 12:33:22 -04:00
|
|
|
"""
|
|
|
|
def setUp(self) -> None:
|
|
|
|
"""
|
|
|
|
Test setup
|
|
|
|
:return: None
|
|
|
|
"""
|
|
|
|
self._city_gml = None
|
|
|
|
self._example_path = (Path(__file__).parent / 'tests_data').resolve()
|
|
|
|
self._output_path = (Path(__file__).parent / 'tests_outputs').resolve()
|
|
|
|
|
|
|
|
def _get_city(self):
|
|
|
|
if self._city_gml is None:
|
2021-04-07 11:46:44 -04:00
|
|
|
file_path = (self._example_path / 'one_building_in_kelowna.gml').resolve()
|
|
|
|
self._city_gml = GeometryFactory('citygml', file_path).city
|
|
|
|
PhysicsFactory('ca', self._city_gml).enrich()
|
|
|
|
UsageFactory('ca', self._city_gml).enrich()
|
|
|
|
SchedulesFactory('comnet', self._city_gml).enrich()
|
2021-04-13 14:12:45 -04:00
|
|
|
cli = 'C:\\Users\\Pilar\\PycharmProjects\\monthlyenergybalance\\tests_data\\weather\\inseldb_Summerland.cli'
|
|
|
|
self._city_gml.climate_file = Path(cli)
|
|
|
|
self._city_gml.climate_reference_city = 'Summerland'
|
2021-04-07 11:46:44 -04:00
|
|
|
for building in self._city_gml.buildings:
|
|
|
|
building.heating['month'] = pd.DataFrame({'INSEL': [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]})
|
|
|
|
building.cooling['month'] = pd.DataFrame({'INSEL': [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]})
|
|
|
|
building.heating['year'] = pd.DataFrame({'INSEL': [0.0]})
|
|
|
|
building.cooling['year'] = pd.DataFrame({'INSEL': [0.0]})
|
2021-03-16 12:33:22 -04:00
|
|
|
return self._city_gml
|
|
|
|
|
|
|
|
def _export(self, export_type):
|
|
|
|
self._city_gml = self._get_city()
|
2021-04-07 11:52:39 -04:00
|
|
|
ExportsFactory(export_type, self._city_gml, self._output_path).export()
|
2021-03-16 12:33:22 -04:00
|
|
|
|
|
|
|
def test_obj_export(self):
|
|
|
|
self._export('obj')
|
|
|
|
|
|
|
|
def test_stl_export(self):
|
|
|
|
self._export('stl')
|
2021-03-16 20:14:40 -04:00
|
|
|
|
|
|
|
def test_energy_ade_export(self):
|
|
|
|
self._export('energy_ade')
|
2021-04-13 14:12:45 -04:00
|
|
|
|
|
|
|
def test_sra_export(self):
|
2021-04-13 19:00:28 -04:00
|
|
|
self._export('sra')
|