2022-03-09 11:40:06 -05:00
|
|
|
"""
|
2022-11-21 13:53:58 -05:00
|
|
|
Test greenery factory test and validate the greenery construction
|
2022-03-09 11:40:06 -05:00
|
|
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
2022-04-08 09:35:33 -04:00
|
|
|
Copyright © 2022 Concordia CERC group
|
|
|
|
Project Coder Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
|
2022-03-09 11:40:06 -05:00
|
|
|
"""
|
|
|
|
|
|
|
|
from unittest import TestCase
|
|
|
|
|
2022-04-08 18:03:35 -04:00
|
|
|
from catalog_factories.greenery_catalog_factory import GreeneryCatalogFactory
|
2022-03-09 11:40:06 -05:00
|
|
|
|
|
|
|
|
|
|
|
class TestGreeneryCatalog(TestCase):
|
|
|
|
def test_catalog(self):
|
2022-04-11 12:37:46 -04:00
|
|
|
catalog = GreeneryCatalogFactory('nrel').catalog
|
2022-03-09 11:40:06 -05:00
|
|
|
catalog_categories = catalog.names()
|
|
|
|
vegetations = catalog.names('vegetations')
|
|
|
|
plants = catalog.names('plants')
|
|
|
|
soils = catalog.names('soils')
|
|
|
|
self.assertTrue(len(catalog_categories) == 3)
|
|
|
|
self.assertTrue(len(vegetations['vegetations']) == 4)
|
|
|
|
self.assertTrue(len(plants['plants']) == 14)
|
|
|
|
self.assertTrue(len(soils['soils']) == 6)
|
|
|
|
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')
|
|
|
|
|
|
|
|
self.assertTrue(len(catalog.entries().vegetations) == 4)
|
|
|
|
self.assertTrue(len(catalog.entries().plants) == 14)
|
|
|
|
self.assertTrue(len(catalog.entries().soils) == 6)
|
|
|
|
|