Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
344b685094 | ||
|
1df005ea8a | ||
|
0908e64782 |
|
@ -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)
|
||||||
|
|
|
@ -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]
|
|
@ -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()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user