forked from s_ranjbar/city_retrofit
63 lines
2.3 KiB
Python
63 lines
2.3 KiB
Python
"""
|
|
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
|
|
Contributors Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
|
"""
|
|
|
|
from pathlib import Path
|
|
from unittest import TestCase
|
|
import pandas as pd
|
|
from imports.geometry_factory import GeometryFactory
|
|
from imports.physics_factory import PhysicsFactory
|
|
from imports.schedules_factory import SchedulesFactory
|
|
from imports.usage_factory import UsageFactory
|
|
from exports.exports_factory import ExportsFactory
|
|
|
|
|
|
class TestExports(TestCase):
|
|
"""
|
|
TestExports class contains the unittest for export functionality
|
|
"""
|
|
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:
|
|
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()
|
|
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'
|
|
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]})
|
|
return self._city_gml
|
|
|
|
def _export(self, export_type):
|
|
self._city_gml = self._get_city()
|
|
ExportsFactory(export_type, self._city_gml, self._output_path).export()
|
|
|
|
def test_obj_export(self):
|
|
self._export('obj')
|
|
|
|
def test_stl_export(self):
|
|
self._export('stl')
|
|
|
|
def test_energy_ade_export(self):
|
|
self._export('energy_ade')
|
|
|
|
def test_sra_export(self):
|
|
self._export('sra')
|