""" Test db retrieve SPDX - License - Identifier: LGPL - 3.0 - or -later Copyright © 2022 Concordia CERC group Project Coder Ruben Sanchez ruben.sanchez@mail.concordia.ca """ import datetime import distutils.spawn import os import unittest from pathlib import Path from unittest import TestCase from sqlalchemy import create_engine from sqlalchemy_utils import database_exists, create_database, drop_database from cerc_persistence.db_control import DBControl from cerc_persistence.repository import Repository from cerc_persistence.models import City, Application, CityObject, SimulationResults, User from unittests.control import Control control = Control() class TestDBFactory(TestCase): """ TestDBFactory """ @unittest.skipIf(control.skip_test, control.skip_reason) def test_retrieve_results(self): datetime.datetime.now() request_values = { "scenarios": [ {"current status": ["01002777", "01002773", "01036804"]}, {"skin retrofit": ["01002777", "01002773", "01036804"]}, {"system retrofit and pv": ["01002777", "01002773", "01036804"]}, {"skin and system retrofit with pv": ["01002777", "01002773", "01036804"]} ] } results = control.database.results(control.user_id, control.application_id, request_values) scenarios = ['current status', 'skin retrofit', 'system retrofit and pv', 'skin and system retrofit with pv'] for key, value in results.items(): self.assertTrue(key in scenarios, 'Wrong key value') self.assertEqual(len(value), 0, 'wrong number of results')