Saeed Ranjbar
ebaec9bb7c
A new XML file named montreal_future_systems.xml is created where the elements of the file are the same as attributes of various classes. Therefore, the catalogue importer and energy system importer should have been updated accordingly. The catalog importer is organized in a general method so whenever someone wants to create a new catalogue they can use the created code as the blueprint.
80 lines
3.0 KiB
Python
80 lines
3.0 KiB
Python
"""
|
|
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
|
|
|
|
catalog_categories = catalog.names()
|
|
archetypes = catalog.names('archetypes')
|
|
self.assertEqual(23, len(archetypes['archetypes']))
|
|
systems = catalog.names('systems')
|
|
self.assertEqual(18, len(systems['systems']))
|
|
generation_equipments = catalog.names('generation_equipments')
|
|
self.assertEqual(7, len(generation_equipments['generation_equipments']))
|
|
distribution_equipments = catalog.names('distribution_equipments')
|
|
self.assertEqual(13, len(distribution_equipments['distribution_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')
|
|
|
|
def test_north_america_systems_catalog(self):
|
|
catalog = EnergySystemsCatalogFactory('north_america').catalog
|
|
|
|
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(26, 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')
|
|
print(catalog.entries())
|
|
|
|
def test_montreal_future_catalog(self):
|
|
catalog = EnergySystemsCatalogFactory('montreal_future').catalog
|
|
|
|
catalog_categories = catalog.names()
|
|
archetypes = catalog.names('archetypes')
|
|
self.assertEqual(12, len(archetypes['archetypes']))
|
|
systems = catalog.names('systems')
|
|
self.assertEqual(7, len(systems['systems']))
|
|
generation_equipments = catalog.names('generation_equipments')
|
|
self.assertEqual(26, 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')
|
|
print(catalog.entries())
|