diff --git a/cerc_persistence/repositories/city.py b/cerc_persistence/repositories/city.py index 5737b69..9c9a2e9 100644 --- a/cerc_persistence/repositories/city.py +++ b/cerc_persistence/repositories/city.py @@ -133,3 +133,7 @@ class City(Repository): except SQLAlchemyError as err: logging.error('Error while fetching city by name %s', err) raise SQLAlchemyError from err + + def get_by_id(self, city_id) -> Model: + with Session(self.engine) as session: + return session.execute(select(Model).where(Model.id == city_id)).first()[0] \ No newline at end of file diff --git a/unittests/test_db_retrieve.py b/unittests/test_db_retrieve.py index 6dda2b0..f10a8cf 100644 --- a/unittests/test_db_retrieve.py +++ b/unittests/test_db_retrieve.py @@ -5,18 +5,9 @@ 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()