hub/tests/test_construction_catalog.py

94 lines
3.4 KiB
Python
Raw Normal View History

"""
TestConstructionCatalog
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2022 Concordia CERC group
Project Coder Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
2023-02-21 10:14:55 -05:00
Contributors Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
"""
from unittest import TestCase
2023-01-24 10:51:50 -05:00
from hub.catalog_factories.construction_catalog_factory import ConstructionCatalogFactory
class TestConstructionCatalog(TestCase):
def test_nrel_catalog(self):
2022-04-11 12:44:23 -04:00
catalog = ConstructionCatalogFactory('nrel').catalog
catalog_categories = catalog.names()
constructions = catalog.names('constructions')
windows = catalog.names('windows')
materials = catalog.names('materials')
2023-03-10 12:13:56 -05:00
self.assertEqual(33, len(constructions['constructions']))
self.assertEqual(5, len(windows['windows']))
self.assertEqual(33, len(materials['materials']))
2023-02-21 10:14:55 -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')
def test_nrcan_catalog(self):
catalog = ConstructionCatalogFactory('nrcan').catalog
catalog_categories = catalog.names()
constructions = catalog.names('constructions')
windows = catalog.names('windows')
materials = catalog.names('materials')
self.assertEqual(540, len(constructions['constructions']))
self.assertEqual(96, len(windows['windows']))
self.assertEqual(552, len(materials['materials']))
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_eilat_catalog(self):
catalog = ConstructionCatalogFactory('eilat').catalog
catalog_categories = catalog.names()
constructions = catalog.names('constructions')
windows = catalog.names('windows')
materials = catalog.names('materials')
self.assertEqual(9, len(constructions['constructions']))
self.assertEqual(3, len(windows['windows']))
self.assertEqual(553, len(materials['materials']))
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_palma_catalog(self):
catalog = ConstructionCatalogFactory('palma').catalog
catalog_categories = catalog.names()
constructions = catalog.names('constructions')
windows = catalog.names('windows')
materials = catalog.names('materials')
self.assertEqual(29, len(constructions['constructions']))
self.assertEqual(9, len(windows['windows']))
self.assertEqual(122, len(materials['materials']))
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')