From 404f8d561d7670d579f5e510cb637ab16a09d599 Mon Sep 17 00:00:00 2001 From: r_sanchez Date: Mon, 20 Nov 2023 11:10:22 -0500 Subject: [PATCH] Removed the jenkins replace with cerc --- tests/test_db_factory.py | 29 +++++++++-------------------- tests/test_db_retrieve.py | 5 +++-- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/tests/test_db_factory.py b/tests/test_db_factory.py index cba6421..d0d44d5 100644 --- a/tests/test_db_factory.py +++ b/tests/test_db_factory.py @@ -46,7 +46,7 @@ class Control: """ self._skip_test = False # Create test database - dotenv_path = Path("{}/.local/etc/hub_api/.env".format(os.path.expanduser('~').replace('jenkins', 'cerc'))).resolve() + dotenv_path = Path("{}/.local/etc/hub/.env".format(os.path.expanduser('~'))).resolve() if not dotenv_path.exists(): self._skip_test = True self._skip_reason = f'.env file missing at {dotenv_path}' @@ -106,19 +106,13 @@ class Control: self._application_uuid = 'b9e0ce80-1218-410c-8a64-9d9b7026aad8' self._application_id = 1 self._user_id = 1 - try: - self._application_id = self._database.persist_application( - 'test', - 'test', - self.application_uuid - ) - except sqlalchemy.exc.SQLAlchemyError: - self._application_id = self._database.application_info(self.application_uuid).id - try: - self._user_id = self._database.create_user('test', self._application_id, 'test', UserRoles.Admin) - except sqlalchemy.exc.SQLAlchemyError: - self._user_id = self._database.user_info(name='test', password='test', application_id=self._application_id).id + self._application_id = self._database.persist_application( + 'test', + 'test', + self.application_uuid + ) + self._user_id = self._database.create_user('test', self._application_id, 'test', UserRoles.Admin) self._pickle_path = Path('tests_data/pickle_path.bz2').resolve() @@ -279,10 +273,8 @@ TestDBFactory {'yearly_cooling_consumption': yearly_cooling_consumption}, {'monthly_domestic_hot_water_consumption': monthly_domestic_hot_water_consumption}, {'yearly_domestic_hot_water_consumption': yearly_domestic_hot_water_consumption}, - { - 'monthly_distribution_systems_electrical_consumption': monthly_distribution_systems_electrical_consumption}, - { - 'yearly_distribution_systems_electrical_consumption': yearly_distribution_systems_electrical_consumption}, + {'monthly_distribution_systems_electrical_consumption': monthly_distribution_systems_electrical_consumption}, + {'yearly_distribution_systems_electrical_consumption': yearly_distribution_systems_electrical_consumption}, {'monthly_on_site_electrical_production': monthly_on_site_electrical_production}, {'yearly_on_site_electrical_production': yearly_on_site_electrical_production} ]}) @@ -304,6 +296,3 @@ TestDBFactory control.database.delete_application(control.application_uuid) control.database.delete_user(control.user_id) os.unlink(control.pickle_path) - output_files = glob.glob('./tests_outputs/*') - for output_file in output_files: - os.unlink(output_file) diff --git a/tests/test_db_retrieve.py b/tests/test_db_retrieve.py index c072939..d30228c 100644 --- a/tests/test_db_retrieve.py +++ b/tests/test_db_retrieve.py @@ -109,8 +109,8 @@ control = Control() class TestDBFactory(TestCase): """ - TestDBFactory - """ +TestDBFactory +""" @unittest.skipIf(control.skip_test, control.skip_reason) def test_retrieve_results(self): @@ -129,6 +129,7 @@ class TestDBFactory(TestCase): "skin and system retrofit with pv": ["01002777", "01002773", "01036804"] } + ] } results = control.database.results(control.user_id, control.application_id, request_values)