Compare commits

...

3 Commits

Author SHA1 Message Date
Guille
344b685094 Correct cerc_persistence autodocumentation 2024-05-24 11:28:43 +02:00
Guille
1df005ea8a Merge remote-tracking branch 'origin/main' 2024-05-24 11:19:06 +02:00
Guille
0908e64782 Correct cerc_persistence autodocumentation 2024-05-24 11:18:58 +02:00
3 changed files with 12 additions and 10 deletions

View File

@ -236,6 +236,13 @@ class DBControl:
def delete_application(self, application_uuid): def delete_application(self, application_uuid):
""" """
Deletes a single application from the database Deletes a single application from the database
:param application_uuid: the id of the application to get :param application_uuid: the id of the application to delete
""" """
self._application.delete(application_uuid) self._application.delete(application_uuid)
def get_city(self, city_id):
"""
Get a single city by id
:param city_id: the id of the city to get
"""
return self._city.get_by_id(city_id)

View File

@ -133,3 +133,7 @@ class City(Repository):
except SQLAlchemyError as err: except SQLAlchemyError as err:
logging.error('Error while fetching city by name %s', err) logging.error('Error while fetching city by name %s', err)
raise SQLAlchemyError from 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]

View File

@ -5,18 +5,9 @@ Copyright © 2022 Concordia CERC group
Project Coder Ruben Sanchez ruben.sanchez@mail.concordia.ca Project Coder Ruben Sanchez ruben.sanchez@mail.concordia.ca
""" """
import datetime import datetime
import distutils.spawn
import os
import unittest import unittest
from pathlib import Path
from unittest import TestCase 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 from unittests.control import Control
control = Control() control = Control()