2023-04-28 14:07:07 -04:00
|
|
|
"""
|
|
|
|
TestSystemsCatalog
|
|
|
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
|
|
|
Copyright © 2022 Concordia CERC group
|
|
|
|
Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
|
|
|
"""
|
|
|
|
|
|
|
|
from unittest import TestCase
|
|
|
|
from hub.catalog_factories.energy_systems_catalog_factory import EnergySystemsCatalogFactory
|
|
|
|
|
|
|
|
|
|
|
|
class TestSystemsCatalog(TestCase):
|
|
|
|
|
|
|
|
def test_montreal_custom_catalog(self):
|
|
|
|
catalog = EnergySystemsCatalogFactory('montreal_custom').catalog
|
2023-08-29 13:02:28 -04:00
|
|
|
|
2023-04-28 14:07:07 -04:00
|
|
|
catalog_categories = catalog.names()
|
|
|
|
archetypes = catalog.names('archetypes')
|
2023-06-08 09:58:57 -04:00
|
|
|
self.assertEqual(23, len(archetypes['archetypes']))
|
2023-05-29 11:56:56 -04:00
|
|
|
systems = catalog.names('systems')
|
2023-06-07 12:55:03 -04:00
|
|
|
self.assertEqual(18, len(systems['systems']))
|
2023-05-29 11:56:56 -04:00
|
|
|
generation_equipments = catalog.names('generation_equipments')
|
2023-06-07 12:55:03 -04:00
|
|
|
self.assertEqual(7, len(generation_equipments['generation_equipments']))
|
2023-05-29 11:56:56 -04:00
|
|
|
distribution_equipments = catalog.names('distribution_equipments')
|
|
|
|
self.assertEqual(8, len(distribution_equipments['distribution_equipments']))
|
|
|
|
emission_equipments = catalog.names('emission_equipments')
|
|
|
|
self.assertEqual(3, len(emission_equipments['emission_equipments']))
|
2023-04-28 14:07:07 -04:00
|
|
|
with self.assertRaises(ValueError):
|
|
|
|
catalog.names('unknown')
|
|
|
|
|
|
|
|
# retrieving all the entries should not raise any exceptions
|
|
|
|
for category in catalog_categories:
|
|
|
|
for value in catalog_categories[category]:
|
|
|
|
catalog.get_entry(value)
|
|
|
|
|
2023-08-29 13:02:28 -04:00
|
|
|
print(catalog.entries())
|
|
|
|
|
2023-04-28 14:07:07 -04:00
|
|
|
with self.assertRaises(IndexError):
|
|
|
|
catalog.get_entry('unknown')
|
2023-08-09 12:02:16 -04:00
|
|
|
|
2023-08-28 10:18:18 -04:00
|
|
|
def test_north_america_systems_catalog(self):
|
|
|
|
catalog = EnergySystemsCatalogFactory('north_america').catalog
|
2023-10-10 14:05:53 -04:00
|
|
|
catalog_categories = catalog.names()
|
|
|
|
archetypes = catalog.names('archetypes')
|
|
|
|
self.assertEqual(6, len(archetypes['archetypes']))
|
|
|
|
systems = catalog.names('systems')
|
|
|
|
self.assertEqual(7, len(systems['systems']))
|
|
|
|
generation_equipments = catalog.names('generation_equipments')
|
|
|
|
self.assertEqual(21, len(generation_equipments['generation_equipments']))
|
|
|
|
storage_equipments = catalog.names('storage_equipments')
|
|
|
|
self.assertEqual(6, len(storage_equipments['storage_equipments']))
|
|
|
|
with self.assertRaises(ValueError):
|
|
|
|
catalog.names('unknown')
|
|
|
|
|
|
|
|
# retrieving all the entries should not raise any exceptions
|
|
|
|
for category in catalog_categories:
|
|
|
|
for value in catalog_categories[category]:
|
|
|
|
catalog.get_entry(value)
|
|
|
|
|
2023-08-29 13:02:28 -04:00
|
|
|
print(catalog.entries())
|
2023-10-10 14:05:53 -04:00
|
|
|
|
|
|
|
with self.assertRaises(IndexError):
|
|
|
|
catalog.get_entry('unknown')
|