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')
|
2024-12-13 06:19:24 -05:00
|
|
|
self.assertEqual(24, len(archetypes['archetypes']))
|
2023-05-29 11:56:56 -04:00
|
|
|
systems = catalog.names('systems')
|
2024-12-13 06:19:24 -05:00
|
|
|
self.assertEqual(20, len(systems['systems']))
|
2023-05-29 11:56:56 -04:00
|
|
|
generation_equipments = catalog.names('generation_equipments')
|
2024-12-13 06:19:24 -05:00
|
|
|
self.assertEqual(10, len(generation_equipments['generation_equipments']))
|
2023-05-29 11:56:56 -04:00
|
|
|
distribution_equipments = catalog.names('distribution_equipments')
|
2023-10-12 11:59:52 -04:00
|
|
|
self.assertEqual(13, len(distribution_equipments['distribution_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)
|
|
|
|
|
|
|
|
with self.assertRaises(IndexError):
|
|
|
|
catalog.get_entry('unknown')
|
2023-08-09 12:02:16 -04:00
|
|
|
|
2024-02-07 18:54:09 -05:00
|
|
|
def test_montreal_future_catalog(self):
|
|
|
|
catalog = EnergySystemsCatalogFactory('montreal_future').catalog
|
|
|
|
|
|
|
|
catalog_categories = catalog.names()
|
2024-06-27 16:32:44 -04:00
|
|
|
archetypes = catalog.names()
|
2024-11-17 09:29:19 -05:00
|
|
|
self.assertEqual(34, len(archetypes['archetypes']))
|
2024-02-07 18:54:09 -05:00
|
|
|
systems = catalog.names('systems')
|
2024-11-17 09:29:19 -05:00
|
|
|
self.assertEqual(39, len(systems['systems']))
|
2024-02-07 18:54:09 -05:00
|
|
|
generation_equipments = catalog.names('generation_equipments')
|
2024-11-17 09:29:19 -05:00
|
|
|
self.assertEqual(49, len(generation_equipments['generation_equipments']))
|
2024-02-07 18:54:09 -05: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)
|
|
|
|
|
|
|
|
with self.assertRaises(IndexError):
|
|
|
|
catalog.get_entry('unknown')
|
2024-10-29 06:36:47 -04:00
|
|
|
|
|
|
|
def test_palma_catalog(self):
|
|
|
|
catalog = EnergySystemsCatalogFactory('palma').catalog
|
|
|
|
catalog_categories = catalog.names()
|
|
|
|
archetypes = catalog.names()
|
|
|
|
self.assertEqual(15, len(archetypes['archetypes']))
|
|
|
|
systems = catalog.names('systems')
|
|
|
|
self.assertEqual(13, len(systems['systems']))
|
|
|
|
generation_equipments = catalog.names('generation_equipments')
|
|
|
|
self.assertEqual(16, len(generation_equipments['generation_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)
|
|
|
|
|
|
|
|
with self.assertRaises(IndexError):
|
|
|
|
catalog.get_entry('unknown')
|