Compare commits

...

4 Commits

Author SHA1 Message Date
b949e4e4cf Cleaning my mess 2024-03-28 16:06:03 -04:00
3b3c8ea952 test commit majid 2024-03-28 13:34:07 -04:00
a69a58d8d8 testing 2024-03-28 13:30:57 -04:00
3cbc13d302 New Cost Catalogue
The xml file and catalogue importer are changed and tested
2024-03-27 19:56:35 -04:00
33 changed files with 556 additions and 0 deletions

View File

@ -0,0 +1,196 @@
"""
Cost catalog
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2023 Concordia CERC group
Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
"""
import xmltodict
from hub.catalog_factories.catalog import Catalog
from hub.catalog_factories.data_models.cost.archetype import Archetype
from hub.catalog_factories.data_models.cost.content import Content
from hub.catalog_factories.data_models.cost.capital_cost import CapitalCost
from hub.catalog_factories.data_models.cost.chapter import Chapter
from hub.catalog_factories.data_models.cost.item_description import ItemDescription
from hub.catalog_factories.data_models.cost.operational_cost import OperationalCost
from hub.catalog_factories.data_models.cost.fuel import Fuel
from hub.catalog_factories.data_models.cost.income import Income
class MontrealNewCatalog(Catalog):
"""
Montreal custom catalog class
"""
def __init__(self, path):
path = (path / 'montreal_costs_completed.xml').resolve()
with open(path, 'r', encoding='utf-8') as xml:
self._archetypes = xmltodict.parse(xml.read(), force_list='archetype')
# store the full catalog data model in self._content
self._content = Content(self._load_archetypes())
def _load_archetypes(self):
_catalog_archetypes = []
archetypes = self._archetypes['archetypes']['archetype']
for archetype in archetypes:
lod = float(archetype['@lod'])
function = archetype['@function']
municipality = archetype['@municipality']
country = archetype['@country']
currency = archetype['currency']
capital_cost = self.load_capital_costs(archetype)
operational_cost = self._get_operational_costs(archetype['operational_cost'])
end_of_life_cost = float(archetype['end_of_life_cost']['#text'])
construction = float(archetype['incomes']['subsidies']['construction']['#text'])
hvac = float(archetype['incomes']['subsidies']['hvac']['#text'])
photovoltaic_system = float(archetype['incomes']['subsidies']['photovoltaic']['#text'])
electricity_exports = float(archetype['incomes']['electricity_export']['#text']) / 1000 / 3600
reduction_tax = float(archetype['incomes']['tax_reduction']['#text']) / 100
income = Income(construction_subsidy=construction,
hvac_subsidy=hvac,
photovoltaic_subsidy=photovoltaic_system,
electricity_export=electricity_exports,
reductions_tax=reduction_tax)
_catalog_archetypes.append(Archetype(lod,
function,
municipality,
country,
currency,
capital_cost,
operational_cost,
end_of_life_cost,
income))
return _catalog_archetypes
@staticmethod
def item_description(item_type, item):
if 'refurbishment_cost' in item.keys():
_refurbishment = float(item['refurbishment_cost']['#text'])
_refurbishment_unit = item['refurbishment_cost']['@cost_unit']
_item_description = ItemDescription(item_type,
initial_investment=None,
initial_investment_unit=None,
refurbishment=_refurbishment,
refurbishment_unit=_refurbishment_unit,
reposition=None,
reposition_unit=None,
lifetime=None)
else:
_reposition = float(item['reposition']['#text'])
_reposition_unit = item['reposition']['@cost_unit']
_investment = float(item['investment_cost']['#text'])
_investment_unit = item['investment_cost']['@cost_unit']
_lifetime = float(item['lifetime_equipment']['#text'])
_item_description = ItemDescription(item_type,
initial_investment=_investment,
initial_investment_unit=_investment_unit,
refurbishment=None,
refurbishment_unit=None,
reposition=_reposition,
reposition_unit=_reposition_unit,
lifetime=_lifetime)
return _item_description
def load_capital_costs(self, archetype):
archetype_capital_costs = archetype['capital_cost']
design_allowance = float(
archetype_capital_costs['Z_allowances_overhead_profit']['Z10_design_allowance']['#text']) / 100
overhead_and_profit = float(
archetype_capital_costs['Z_allowances_overhead_profit']['Z20_overhead_profit']['#text']) / 100
general_chapters = []
shell_items = []
service_items = []
for category in archetype_capital_costs:
if category == 'B_shell':
items = archetype_capital_costs[category]
for item in items:
components = items[item]
for component in components:
building_item = components[component]
shell_items.append(self.item_description(component, building_item))
general_chapters.append(Chapter(chapter_type=category, items=shell_items))
elif category == 'D_services':
services = archetype_capital_costs[category]
for service in services:
components = services[service]
if len(components.keys()) == 1:
for component in components:
service_item = components[component]
service_items.append(self.item_description(component, service_item))
else:
for component in components:
items = components[component]
if 'investment_cost' in items.keys():
service_item = components[component]
service_items.append(self.item_description(component, service_item))
else:
for item in items:
service_item = items[item]
service_items.append(self.item_description(item, service_item))
general_chapters.append(Chapter(chapter_type=category, items=service_items))
capital_costs = CapitalCost(general_chapters=general_chapters,
design_allowance=design_allowance,
overhead_and_profit=overhead_and_profit)
return capital_costs
@staticmethod
def _get_operational_costs(entry):
fuels = []
for item in entry['fuels']['fuel']:
fuel_type = item['@fuel_type']
fuel_variable = float(item['variable']['#text'])
fuel_variable_units = item['variable']['@cost_unit']
fuel_fixed_monthly = None
fuel_fixed_peak = None
if fuel_type == 'electricity':
fuel_fixed_monthly = float(item['fixed_monthly']['#text'])
fuel_fixed_peak = float(item['fixed_power']['#text']) / 1000
elif fuel_type == 'gas':
fuel_fixed_monthly = float(item['fixed_monthly']['#text'])
fuel = Fuel(fuel_type,
fixed_monthly=fuel_fixed_monthly,
fixed_power=fuel_fixed_peak,
variable=fuel_variable,
variable_units=fuel_variable_units)
fuels.append(fuel)
heating_equipment_maintenance = float(entry['maintenance']['heating_equipment']['#text']) / 1000
cooling_equipment_maintenance = float(entry['maintenance']['cooling_equipment']['#text']) / 1000
photovoltaic_system_maintenance = float(entry['maintenance']['photovoltaic_system']['#text'])
co2_emissions = float(entry['co2_cost']['#text'])
_operational_cost = OperationalCost(fuels,
heating_equipment_maintenance,
cooling_equipment_maintenance,
photovoltaic_system_maintenance,
co2_emissions)
return _operational_cost
def names(self, category=None):
"""
Get the catalog elements names
:parm: for costs catalog category filter does nothing as there is only one category (archetypes)
"""
_names = {'archetypes': []}
for archetype in self._content.archetypes:
_names['archetypes'].append(archetype.name)
return _names
def entries(self, category=None):
"""
Get the catalog elements
:parm: for costs catalog category filter does nothing as there is only one category (archetypes)
"""
return self._content
def get_entry(self, name):
"""
Get one catalog element by names
:parm: entry name
"""
for entry in self._content.archetypes:
if entry.name.lower() == name.lower():
return entry
raise IndexError(f"{name} doesn't exists in the catalog")

View File

@ -9,6 +9,7 @@ Code contributors: Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concord
from pathlib import Path
from typing import TypeVar
from hub.catalog_factories.cost.montreal_custom_catalog import MontrealCustomCatalog
from hub.catalog_factories.cost.montreal_complete_cost_catalog import MontrealNewCatalog
Catalog = TypeVar('Catalog')
@ -30,6 +31,13 @@ class CostsCatalogFactory:
"""
return MontrealCustomCatalog(self._path)
@property
def _montreal_new(self):
"""
Retrieve Montreal Custom catalog
"""
return MontrealNewCatalog(self._path)
@property
def catalog(self) -> Catalog:
"""
@ -37,3 +45,7 @@ class CostsCatalogFactory:
:return: CostCatalog
"""
return getattr(self, self._catalog_type, lambda: None)
@property
def catalog_debug(self):
return MontrealNewCatalog(self._path)

View File

@ -20,6 +20,7 @@ class OperationalCost:
self._maintenance_pv = maintenance_pv
self._co2 = co2
@property
def fuels(self) -> List[Fuel]:
"""

View File

@ -0,0 +1,328 @@
<archetypes>
<archetype function="residential" municipality="montreal" country="CA" lod="1">
<currency>CAD</currency>
<capital_cost>
<B_shell>
<B10_superstructures>
<B1010_superstructure>
<refurbishment_cost cost_unit="currency/m2"> 0 </refurbishment_cost>
</B1010_superstructure>
</B10_superstructures>
<B20_envelope>
<B2010_opaque_walls>
<refurbishment_cost cost_unit="currency/m2"> 304 </refurbishment_cost>
</B2010_opaque_walls>
<B2020_transparent>
<refurbishment_cost cost_unit="currency/m2"> 857.14 </refurbishment_cost>
</B2020_transparent>
</B20_envelope>
<B30_roofing>
<B3010_opaque_roof>
<refurbishment_cost cost_unit="currency/m2"> 118 </refurbishment_cost>
</B3010_opaque_roof>
</B30_roofing>
</B_shell>
<D_services>
<D20_onsite_generation>
<D2010_photovoltaic_system>
<investment_cost cost_unit="currency/m2"> 800 </investment_cost>
<reposition cost_unit="currency/m2"> 800 </reposition>
<lifetime_equipment lifetime="years"> 25 </lifetime_equipment>
</D2010_photovoltaic_system>
</D20_onsite_generation>
<D30_hvac>
<D3020_heat_and_cooling_generating_systems>
<D302010_template_heat>
<investment_cost cost_unit="currency/kW"> 622.86 </investment_cost>
<reposition cost_unit="currency/kW"> 622.86 </reposition>
<lifetime_equipment lifetime="years"> 25 </lifetime_equipment>
</D302010_template_heat>
<D302020_air_to_water_heat_pump>
<investment_cost cost_unit="currency/kW"> 47.62 </investment_cost>
<reposition cost_unit="currency/kW"> 47.62 </reposition>
<lifetime_equipment lifetime="years"> 15 </lifetime_equipment>
</D302020_air_to_water_heat_pump>
<D302030_ground_to_water_heat_pump>
<investment_cost cost_unit="currency/kW"> 47.62 </investment_cost>
<reposition cost_unit="currency/kW"> 47.62 </reposition>
<lifetime_equipment lifetime="years"> 15 </lifetime_equipment>
</D302030_ground_to_water_heat_pump>
<D302040_water_to_water_heat_pump>
<investment_cost cost_unit="currency/kW"> 47.62 </investment_cost>
<reposition cost_unit="currency/kW"> 47.62 </reposition>
<lifetime_equipment lifetime="years"> 15 </lifetime_equipment>
</D302040_water_to_water_heat_pump>
<D302050_air_to_air_heat_pump>
<investment_cost cost_unit="currency/kW"> 47.62 </investment_cost>
<reposition cost_unit="currency/kW"> 47.62 </reposition>
<lifetime_equipment lifetime="years"> 15 </lifetime_equipment>
</D302050_air_to_air_heat_pump>
<D302060_air_to_water_heat_pump>
<investment_cost cost_unit="currency/kW"> 47.62 </investment_cost>
<reposition cost_unit="currency/kW"> 47.62 </reposition>
<lifetime_equipment lifetime="years"> 15 </lifetime_equipment>
</D302060_air_to_water_heat_pump>
<D302070_natural_gas_boiler>
<investment_cost cost_unit="currency/kW"> 47.62 </investment_cost>
<reposition cost_unit="currency/kW"> 47.62 </reposition>
<lifetime_equipment lifetime="years"> 15 </lifetime_equipment>
</D302070_natural_gas_boiler>
<D302080_electrical_boiler>
<investment_cost cost_unit="currency/kW"> 47.62 </investment_cost>
<reposition cost_unit="currency/kW"> 47.62 </reposition>
<lifetime_equipment lifetime="years"> 15 </lifetime_equipment>
</D302080_electrical_boiler>
<D302090_template_cooling>
<investment_cost cost_unit="currency/kW"> 622.86 </investment_cost>
<reposition cost_unit="currency/kW"> 622.86 </reposition>
<lifetime_equipment lifetime="years"> 15 </lifetime_equipment>
</D302090_template_cooling>
</D3020_heat_and_cooling_generating_systems>
<D3040_distribution_systems>
<investment_cost cost_unit="currency/kW"> 0 </investment_cost>
<reposition cost_unit="currency/kW"> 0 </reposition>
<lifetime_equipment lifetime="years"> 15 </lifetime_equipment>
</D3040_distribution_systems>
<D3050_other_hvac_ahu>
<investment_cost cost_unit="currency/kW"> 47.62 </investment_cost>
<reposition cost_unit="currency/kW"> 47.62 </reposition>
<lifetime_equipment lifetime="years"> 15 </lifetime_equipment>
</D3050_other_hvac_ahu>
<D3060_storage_systems>
<D306010_storage_tank>
<investment_cost cost_unit="currency/kW"> 47.62 </investment_cost>
<reposition cost_unit="currency/kW"> 47.62 </reposition>
<lifetime_equipment lifetime="years"> 15 </lifetime_equipment>
</D306010_storage_tank>
<D306020_storage_tank_with_coil>
<investment_cost cost_unit="currency/kW"> 47.62 </investment_cost>
<reposition cost_unit="currency/kW"> 47.62 </reposition>
<lifetime_equipment lifetime="years"> 15 </lifetime_equipment>
</D306020_storage_tank_with_coil>
</D3060_storage_systems>
</D30_hvac>
<D40_dhw>
<D4010_hot_water_heat_pump>
<investment_cost cost_unit="currency/kW"> 47.62 </investment_cost>
<reposition cost_unit="currency/kW"> 47.62 </reposition>
<lifetime_equipment lifetime="years"> 15 </lifetime_equipment>
</D4010_hot_water_heat_pump>
<D4020_hot_water_storage_tank>
<investment_cost cost_unit="currency/kW"> 47.62 </investment_cost>
<reposition cost_unit="currency/kW"> 47.62 </reposition>
<lifetime_equipment lifetime="years"> 15 </lifetime_equipment>
</D4020_hot_water_storage_tank>
</D40_dhw>
<D50_electrical>
<D5020_lighting_and_branch_wiring>
<investment_cost cost_unit="currency/kW"> 139 </investment_cost>
<reposition cost_unit="currency/kW"> 139 </reposition>
<lifetime_equipment lifetime="years"> 20 </lifetime_equipment>
</D5020_lighting_and_branch_wiring>
</D50_electrical>
</D_services>
<Z_allowances_overhead_profit>
<Z10_design_allowance cost_unit="%"> 2.5 </Z10_design_allowance>
<Z20_overhead_profit cost_unit="%"> 14 </Z20_overhead_profit>
</Z_allowances_overhead_profit>
</capital_cost>
<operational_cost>
<fuels>
<fuel fuel_type="electricity">
<fixed_monthly cost_unit="currency/month"> 12.27 </fixed_monthly>
<fixed_power cost_unit="currency/month*kW"> 0 </fixed_power>
<variable cost_unit="currency/kWh"> 0.075 </variable>
</fuel>
<fuel fuel_type="gas">
<fixed_monthly cost_unit="currency/month"> 17.71 </fixed_monthly>
<variable cost_unit="currency/kWh"> 0.0640 </variable>
</fuel>
<fuel fuel_type="diesel">
<variable cost_unit="currency/l"> 1.2 </variable>
</fuel>
<fuel fuel_type="biomass">
<variable cost_unit="currency/kg"> 0.04 </variable>
</fuel>
</fuels>
<maintenance>
<heating_equipment cost_unit="currency/kW">40</heating_equipment>
<cooling_equipment cost_unit="currency/kW">40</cooling_equipment>
<photovoltaic_system cost_unit="currency/m2">1</photovoltaic_system>
</maintenance>
<co2_cost cost_unit="currency/kgCO2"> 30 </co2_cost>
</operational_cost>
<end_of_life_cost cost_unit="currency/m2"> 6.3 </end_of_life_cost>
<incomes>
<subsidies>
<construction cost_unit="%">20</construction>
<hvac cost_unit="%">1.5</hvac>
<photovoltaic cost_unit="%">3.6</photovoltaic>
</subsidies>
<electricity_export cost_unit="currency/kWh">0.07</electricity_export>
<tax_reduction cost_unit="%">5</tax_reduction>
</incomes>
</archetype>
<archetype function="non-residential" municipality="montreal" country="CA" lod="1">
<currency>CAD</currency>
<capital_cost>
<B_shell>
<B10_superstructures>
<B1010_superstructure>
<refurbishment_cost cost_unit="currency/m2"> 0 </refurbishment_cost>
</B1010_superstructure>
</B10_superstructures>
<B20_envelope>
<B2010_opaque_walls>
<refurbishment_cost cost_unit="currency/m2"> 304 </refurbishment_cost>
</B2010_opaque_walls>
<B2020_transparent>
<refurbishment_cost cost_unit="currency/m2"> 857.14 </refurbishment_cost>
</B2020_transparent>
</B20_envelope>
<B30_roofing>
<B3010_opaque_roof>
<refurbishment_cost cost_unit="currency/m2"> 118 </refurbishment_cost>
</B3010_opaque_roof>
</B30_roofing>
</B_shell>
<D_services>
<D20_onsite_generation>
<D2010_photovoltaic_system>
<investment_cost cost_unit="currency/m2"> 800 </investment_cost>
<reposition cost_unit="currency/m2"> 800 </reposition>
<lifetime_equipment lifetime="years"> 25 </lifetime_equipment>
</D2010_photovoltaic_system>
</D20_onsite_generation>
<D30_hvac>
<D3020_heat_and_cooling_generating_systems>
<D302010_template_heat>
<investment_cost cost_unit="currency/kW"> 622.86 </investment_cost>
<reposition cost_unit="currency/kW"> 622.86 </reposition>
<lifetime_equipment lifetime="years"> 25 </lifetime_equipment>
</D302010_template_heat>
<D302020_air_to_water_heat_pump>
<investment_cost cost_unit="currency/kW"> 47.62 </investment_cost>
<reposition cost_unit="currency/kW"> 47.62 </reposition>
<lifetime_equipment lifetime="years"> 15 </lifetime_equipment>
</D302020_air_to_water_heat_pump>
<D302030_ground_to_water_heat_pump>
<investment_cost cost_unit="currency/kW"> 47.62 </investment_cost>
<reposition cost_unit="currency/kW"> 47.62 </reposition>
<lifetime_equipment lifetime="years"> 15 </lifetime_equipment>
</D302030_ground_to_water_heat_pump>
<D302040_water_to_water_heat_pump>
<investment_cost cost_unit="currency/kW"> 47.62 </investment_cost>
<reposition cost_unit="currency/kW"> 47.62 </reposition>
<lifetime_equipment lifetime="years"> 15 </lifetime_equipment>
</D302040_water_to_water_heat_pump>
<D302050_air_to_air_heat_pump>
<investment_cost cost_unit="currency/kW"> 47.62 </investment_cost>
<reposition cost_unit="currency/kW"> 47.62 </reposition>
<lifetime_equipment lifetime="years"> 15 </lifetime_equipment>
</D302050_air_to_air_heat_pump>
<D302060_air_to_water_heat_pump>
<investment_cost cost_unit="currency/kW"> 47.62 </investment_cost>
<reposition cost_unit="currency/kW"> 47.62 </reposition>
<lifetime_equipment lifetime="years"> 15 </lifetime_equipment>
</D302060_air_to_water_heat_pump>
<D302070_natural_gas_boiler>
<investment_cost cost_unit="currency/kW"> 47.62 </investment_cost>
<reposition cost_unit="currency/kW"> 47.62 </reposition>
<lifetime_equipment lifetime="years"> 15 </lifetime_equipment>
</D302070_natural_gas_boiler>
<D302080_electrical_boiler>
<investment_cost cost_unit="currency/kW"> 47.62 </investment_cost>
<reposition cost_unit="currency/kW"> 47.62 </reposition>
<lifetime_equipment lifetime="years"> 15 </lifetime_equipment>
</D302080_electrical_boiler>
<D302020_template_cooling>
<investment_cost cost_unit="currency/kW"> 622.86 </investment_cost>
<reposition cost_unit="currency/kW"> 622.86 </reposition>
<lifetime_equipment lifetime="years"> 15 </lifetime_equipment>
</D302020_template_cooling>
</D3020_heat_and_cooling_generating_systems>
<D3040_distribution_systems>
<investment_cost cost_unit="currency/m2"> 0 </investment_cost>
<reposition cost_unit="currency/kW"> 0 </reposition>
<lifetime_equipment lifetime="years"> 15 </lifetime_equipment>
</D3040_distribution_systems>
<D3080_other_hvac_ahu>
<investment_cost cost_unit="currency/kW"> 47.62 </investment_cost>
<reposition cost_unit="currency/kW"> 47.62 </reposition>
<lifetime_equipment lifetime="years"> 15 </lifetime_equipment>
</D3080_other_hvac_ahu>
<D3060_storage_systems>
<D306010_storage_tank>
<investment_cost cost_unit="currency/kW"> 47.62 </investment_cost>
<reposition cost_unit="currency/kW"> 47.62 </reposition>
<lifetime_equipment lifetime="years"> 15 </lifetime_equipment>
</D306010_storage_tank>
<D306020_storage_tank_with_coil>
<investment_cost cost_unit="currency/kW"> 47.62 </investment_cost>
<reposition cost_unit="currency/kW"> 47.62 </reposition>
<lifetime_equipment lifetime="years"> 15 </lifetime_equipment>
</D306020_storage_tank_with_coil>
</D3060_storage_systems>
</D30_hvac>
<D40_dhw>
<D4010_hot_water_heat_pump>
<investment_cost cost_unit="currency/kW"> 47.62 </investment_cost>
<reposition cost_unit="currency/kW"> 47.62 </reposition>
<lifetime_equipment lifetime="years"> 15 </lifetime_equipment>
</D4010_hot_water_heat_pump>
<D4020_hot_water_storage_tank>
<investment_cost cost_unit="currency/kW"> 47.62 </investment_cost>
<reposition cost_unit="currency/kW"> 47.62 </reposition>
<lifetime_equipment lifetime="years"> 15 </lifetime_equipment>
</D4020_hot_water_storage_tank>
</D40_dhw>
<D50_electrical>
<D5020_lighting_and_branch_wiring>
<investment_cost cost_unit="currency/kW"> 139 </investment_cost>
<reposition cost_unit="currency/kW"> 139 </reposition>
<lifetime_equipment lifetime="years"> 20 </lifetime_equipment>
</D5020_lighting_and_branch_wiring>
</D50_electrical>
</D_services>
<Z_allowances_overhead_profit>
<Z10_design_allowance cost_unit="%"> 6 </Z10_design_allowance>
<Z20_overhead_profit cost_unit="%"> 14 </Z20_overhead_profit>
</Z_allowances_overhead_profit>
</capital_cost>
<operational_cost>
<fuels>
<fuel fuel_type="electricity">
<fixed_monthly cost_unit="currency/month"> 12.27 </fixed_monthly>
<fixed_power cost_unit="currency/(month*kW)"> 0 </fixed_power>
<variable cost_unit="currency/kWh"> 0.075 </variable>
</fuel>
<fuel fuel_type="gas">
<fixed_monthly cost_unit="currency/month"> 17.71 </fixed_monthly>
<variable cost_unit="currency/m3"> 0.0640 </variable>
</fuel>
<fuel fuel_type="diesel">
<variable cost_unit="currency/l"> 1.2 </variable>
</fuel>
<fuel fuel_type="biomass">
<variable cost_unit="currency/kg"> 0.04 </variable>
</fuel>
</fuels>
<maintenance>
<heating_equipment cost_unit="currency/kW">40</heating_equipment>
<cooling_equipment cost_unit="currency/kW">40</cooling_equipment>
<photovoltaic_system cost_unit="currency/m2">1</photovoltaic_system>
</maintenance>
<co2_cost cost_unit="currency/kgCO2"> 30 </co2_cost>
</operational_cost>
<end_of_life_cost cost_unit="currency/m2"> 6.3 </end_of_life_cost>
<incomes>
<subsidies>
<construction cost_unit="%">20</construction>
<hvac cost_unit="%">1.5</hvac>
<photovoltaic cost_unit="%">3.6</photovoltaic>
</subsidies>
<electricity_export cost_unit="currency/kWh">0.05</electricity_export>
<tax_reduction cost_unit="%">5</tax_reduction>
</incomes>
</archetype>
</archetypes>

View File

@ -26,3 +26,22 @@ class TestCostsCatalog(TestCase):
with self.assertRaises(IndexError):
catalog.get_entry('unknown')
print(catalog.entries())
def test_new_costs_catalog(self):
catalog = CostsCatalogFactory('montreal_complete').catalog_debug
catalog_categories = catalog.names()
self.assertIsNotNone(catalog, 'catalog is none')
content = catalog.entries()
self.assertTrue(len(content.archetypes) == 2)
# retrieving all the entries should not raise any exceptions
for category in catalog_categories:
for value in catalog_categories[category]:
catalog.get_entry(value)
with self.assertRaises(IndexError):
catalog.get_entry('unknown')
print(catalog.entries())