improve unit-tests
This commit is contained in:
parent
8fa500d4c6
commit
1052478ace
|
@ -98,6 +98,7 @@ class Cost:
|
|||
global_capital_costs['D5020_lighting_and_branch_wiring'] +
|
||||
global_capital_costs['D301010_photovoltaic_system']
|
||||
)
|
||||
|
||||
df_end_of_life_costs = global_end_of_life_costs['End_of_life_costs']
|
||||
df_operational_costs = (
|
||||
global_operational_costs['Fixed_costs_electricity_peak'] +
|
||||
|
|
|
@ -18,9 +18,14 @@ from costs.cost import Cost
|
|||
from costs.constants import SKIN_RETROFIT, SKIN_RETROFIT_AND_SYSTEM_RETROFIT_AND_PV, SYSTEM_RETROFIT_AND_PV
|
||||
|
||||
|
||||
class UnitTests(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
class Initialize:
|
||||
def __init__(self):
|
||||
self._city = None
|
||||
|
||||
@property
|
||||
def city(self):
|
||||
if self._city is None:
|
||||
print('init tests')
|
||||
city_file = (Path(__file__).parent / 'data/test.geojson').resolve()
|
||||
output_path = (Path(__file__).parent / 'output').resolve()
|
||||
city = GeometryFactory('geojson',
|
||||
|
@ -33,7 +38,7 @@ class UnitTests(unittest.TestCase):
|
|||
UsageFactory('nrcan', city).enrich()
|
||||
ExportsFactory('sra', city, output_path).export()
|
||||
sra_file = str((output_path / f'{city.name}_sra.xml').resolve())
|
||||
subprocess.run(['sra', sra_file])
|
||||
subprocess.run(['sra', sra_file], stdout=subprocess.DEVNULL)
|
||||
ResultFactory('sra', city, output_path).enrich()
|
||||
|
||||
for building in city.buildings:
|
||||
|
@ -45,26 +50,32 @@ class UnitTests(unittest.TestCase):
|
|||
subprocess.run(['insel', str(insel_file)], stdout=subprocess.DEVNULL)
|
||||
ResultFactory('insel_monthly_energy_balance', city, output_path).enrich()
|
||||
self._city = city
|
||||
print('init completed')
|
||||
return self._city
|
||||
|
||||
|
||||
class UnitTests(unittest.TestCase):
|
||||
init = Initialize()
|
||||
|
||||
def test_current_status(self):
|
||||
for building in self._city.buildings:
|
||||
for building in self.init.city.buildings:
|
||||
result = Cost(building).life_cycle
|
||||
self.assertIsNotNone(result)
|
||||
self.assertEqual(0, result.values[0])
|
||||
|
||||
def test_scenario_1(self):
|
||||
for building in self._city.buildings:
|
||||
for building in self.init.city.buildings:
|
||||
result = Cost(building, retrofit_scenario=SKIN_RETROFIT).life_cycle
|
||||
self.assertIsNotNone(result)
|
||||
|
||||
def test_scenario_2(self):
|
||||
for building in self._city.buildings:
|
||||
for building in self.init.city.buildings:
|
||||
result = Cost(building, retrofit_scenario=SYSTEM_RETROFIT_AND_PV).life_cycle
|
||||
self.assertIsNotNone(result)
|
||||
self.assertEqual(0, result.values[0])
|
||||
|
||||
def test_scenario_3(self):
|
||||
for building in self._city.buildings:
|
||||
for building in self.init.city.buildings:
|
||||
result = Cost(building, retrofit_scenario=SKIN_RETROFIT_AND_SYSTEM_RETROFIT_AND_PV).life_cycle
|
||||
self.assertIsNotNone(result)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user