correct unit tests in ci/cd

This commit is contained in:
Guille Gutierrez 2023-11-03 07:21:50 +01:00
parent 0f0368c074
commit 452bfdf780
2 changed files with 15 additions and 13 deletions

View File

@ -31,8 +31,11 @@ class Glb:
self._export() self._export()
@property @property
def _obj2gtl(self): def _obj2gltf(self):
return shutil.which('obj2gltf') obj2gltf = shutil.which('obj2gltf')
if obj2gltf is None:
obj2gltf = 'obj2gltf'
return obj2gltf
def _export(self): def _export(self):
try: try:
@ -43,7 +46,7 @@ class Glb:
Obj(city, self._path) Obj(city, self._path)
glb = f'{self._path}/{building.name}.glb' glb = f'{self._path}/{building.name}.glb'
subprocess.run([ subprocess.run([
self._obj2gtl, self._obj2gltf,
'-i', f'{self._path}/{building.name}.obj', '-i', f'{self._path}/{building.name}.obj',
'-b', '-b',
'-o', f'{glb}' '-o', f'{glb}'

View File

@ -6,19 +6,19 @@ Project Coder Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
Code contributors: Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca Code contributors: Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
""" """
import json import json
import logging.handlers
import os import os
from pathlib import Path from pathlib import Path
from unittest import TestCase from unittest import TestCase
from hub.imports.geometry_factory import GeometryFactory
from hub.helpers.dictionaries import Dictionaries
from hub.imports.construction_factory import ConstructionFactory
from hub.imports.usage_factory import UsageFactory
from hub.imports.weather_factory import WeatherFactory
from hub.exports.exports_factory import ExportsFactory
from hub.exports.energy_building_exports_factory import EnergyBuildingsExportsFactory
import hub.helpers.constants as cte import hub.helpers.constants as cte
from hub.city_model_structure.city import City from hub.city_model_structure.city import City
from hub.exports.energy_building_exports_factory import EnergyBuildingsExportsFactory
from hub.exports.exports_factory import ExportsFactory
from hub.helpers.dictionaries import Dictionaries
from hub.imports.construction_factory import ConstructionFactory
from hub.imports.geometry_factory import GeometryFactory
from hub.imports.usage_factory import UsageFactory
from hub.imports.weather_factory import WeatherFactory
class TestExports(TestCase): class TestExports(TestCase):
@ -95,7 +95,7 @@ class TestExports(TestCase):
export to glb format export to glb format
""" """
self._export('glb', False) self._export('glb', False)
for building in self._city.buildings: for building in self._city.buildings:
glb_file = Path(self._output_path / f'{building.name}.glb') glb_file = Path(self._output_path / f'{building.name}.glb')
self.assertTrue(glb_file.exists(), f'{building.name} Building glb wasn\'t correctly generated') self.assertTrue(glb_file.exists(), f'{building.name} Building glb wasn\'t correctly generated')
@ -148,4 +148,3 @@ class TestExports(TestCase):
EnergyBuildingsExportsFactory('idf', city, self._output_path).export() EnergyBuildingsExportsFactory('idf', city, self._output_path).export()
except Exception: except Exception:
self.fail("Idf ExportsFactory raised ExceptionType unexpectedly!") self.fail("Idf ExportsFactory raised ExceptionType unexpectedly!")