2022-04-11 12:37:46 -04:00
|
|
|
"""
|
|
|
|
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
|
2022-04-11 12:37:46 -04:00
|
|
|
"""
|
|
|
|
|
|
|
|
from unittest import TestCase
|
2023-01-24 10:51:50 -05:00
|
|
|
from hub.catalog_factories.construction_catalog_factory import ConstructionCatalogFactory
|
2022-04-11 12:37:46 -04:00
|
|
|
|
|
|
|
|
|
|
|
class TestConstructionCatalog(TestCase):
|
|
|
|
|
|
|
|
def test_nrel_catalog(self):
|
2022-04-11 12:44:23 -04:00
|
|
|
catalog = ConstructionCatalogFactory('nrel').catalog
|
2022-04-11 12:37:46 -04:00
|
|
|
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')
|
2023-05-29 14:13:57 -04:00
|
|
|
self.assertEqual(540, len(constructions['constructions']))
|
|
|
|
self.assertEqual(96, len(windows['windows']))
|
|
|
|
self.assertEqual(552, len(materials['materials']))
|
2022-04-11 12:37:46 -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-07-12 11:36:35 -04:00
|
|
|
|
|
|
|
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')
|
2024-10-29 06:36:47 -04:00
|
|
|
|
|
|
|
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')
|
2024-12-12 16:22:02 -05:00
|
|
|
|
|
|
|
def test_cerc_catalog(self):
|
|
|
|
catalog = ConstructionCatalogFactory('cerc').catalog
|
|
|
|
catalog_categories = catalog.names()
|
|
|
|
constructions = catalog.names('constructions')
|
|
|
|
windows = catalog.names('windows')
|
|
|
|
materials = catalog.names('materials')
|
|
|
|
self.assertEqual(600, len(constructions['constructions']))
|
|
|
|
self.assertEqual(106, 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')
|