Skip to content

Commit a75690f

Browse files
passing most pytests
1 parent d5cd1e5 commit a75690f

21 files changed

+269
-114
lines changed

gs/backend/data/data_wrappers/abstract_wrapper.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ async def get_all(self) -> list[T]:
2525
:return: a list of all model instances
2626
"""
2727
async with get_db_session() as session:
28-
result = await session.exec(select(self.model))
29-
return list(result.all())
28+
result = await session.execute(select(self.model))
29+
return list(result.scalars().all())
3030

3131
async def get_by_id(self, obj_id: PK) -> T:
3232
"""
@@ -66,6 +66,8 @@ async def delete_by_id(self, obj_id: PK) -> T:
6666
obj = await session.get(self.model, obj_id)
6767
if not obj:
6868
raise ValueError(f"{self.model.__name__} with ID {obj_id} not found.")
69+
# Preserve object state before deleting
70+
obj_copy = self.model(**{c.name: getattr(obj, c.name) for c in obj.__table__.columns})
6971
session.delete(obj)
7072
await session.commit()
71-
return obj
73+
return obj_copy

gs/backend/data/data_wrappers/aro_wrapper/aro_request_wrapper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ async def get_all_requests() -> list[ARORequest]:
1414
Get all the requests from aro
1515
"""
1616
async with get_db_session() as session:
17-
result = await session.exec(select(ARORequest))
18-
requests = list(result.all())
17+
result = await session.execute(select(ARORequest))
18+
requests = list(result.scalars().all())
1919
return requests
2020

2121

gs/backend/data/data_wrappers/aro_wrapper/aro_user_auth_token_wrapper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ async def get_all_auth_tokens() -> list[AROUserAuthToken]:
1313
Get all the auth tokens
1414
"""
1515
async with get_db_session() as session:
16-
result = await session.exec(select(AROUserAuthToken))
17-
auth_tokens = list(result.all())
16+
result = await session.execute(select(AROUserAuthToken))
17+
auth_tokens = list(result.scalars().all())
1818
return auth_tokens
1919

2020

gs/backend/data/data_wrappers/aro_wrapper/aro_user_data_wrapper.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ async def get_all_users() -> list[AROUsers]:
1212
Gets all user
1313
"""
1414
async with get_db_session() as session:
15-
result = await session.exec(select(AROUsers))
16-
users = list(result.all())
15+
result = await session.execute(select(AROUsers))
16+
users = list(result.scalars().all())
1717
return users
1818

1919

@@ -31,8 +31,8 @@ async def add_user(call_sign: str, email: str, f_name: str, l_name: str, phone_n
3131
"""
3232
async with get_db_session() as session:
3333
# check if the user already exists with email as it is unique
34-
result = await session.exec(select(AROUsers).where(AROUsers.email == email))
35-
existing_user = result.first()
34+
result = await session.execute(select(AROUsers).where(AROUsers.email == email))
35+
existing_user = result.scalars().first()
3636

3737
if existing_user:
3838
raise ValueError("User already exsits based on email")
@@ -63,8 +63,8 @@ async def update_user_by_id(
6363
"""
6464
async with get_db_session() as session:
6565
# check if the user already exists with email as it is unique
66-
result = await session.exec(select(AROUsers).where(AROUsers.id == userid))
67-
user = result.first()
66+
result = await session.execute(select(AROUsers).where(AROUsers.id == userid))
67+
user = result.scalars().first()
6868

6969
if not user:
7070
raise ValueError("User does not exist based on user ID")

gs/backend/data/data_wrappers/aro_wrapper/aro_user_login_wrapper.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ async def get_all_logins() -> list[AROUserLogin]:
1111
Gets all the logins
1212
"""
1313
async with get_db_session() as session:
14-
result = await session.exec(select(AROUserLogin))
15-
user_logins = list(result.all())
14+
result = await session.execute(select(AROUserLogin))
15+
user_logins = list(result.scalars().all())
1616
return user_logins
1717

1818

@@ -30,8 +30,8 @@ async def add_login(
3030
"""
3131
async with get_db_session() as session:
3232
# check if the user exists already
33-
result = await session.exec(select(AROUserLogin).where(AROUserLogin.email == email))
34-
existing_login = result.first()
33+
result = await session.execute(select(AROUserLogin).where(AROUserLogin.email == email))
34+
existing_login = result.scalars().first()
3535

3636
if existing_login:
3737
raise ValueError("User login already exists based on email")

gs/backend/data/data_wrappers/mcc_wrappers/commands_wrapper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ async def get_all_commands() -> list[Commands]:
1414
:return: a list of all commands
1515
"""
1616
async with get_db_session() as session:
17-
result = await session.exec(select(Commands))
18-
commands = list(result.all())
17+
result = await session.execute(select(Commands))
18+
commands = list(result.scalars().all())
1919
return commands
2020

2121

gs/backend/data/data_wrappers/mcc_wrappers/comms_session_wrapper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ async def get_all_comms_sessions() -> list[CommsSession]:
1414
:return: a list of all sessions
1515
"""
1616
async with get_db_session() as session:
17-
result = await session.exec(select(CommsSession))
18-
sessions = list(result.all())
17+
result = await session.execute(select(CommsSession))
18+
sessions = list(result.scalars().all())
1919
return sessions
2020

2121

gs/backend/data/data_wrappers/mcc_wrappers/main_command_wrapper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ async def get_all_main_commands() -> list[MainCommand]:
1313
:return: a list of all main_commands
1414
"""
1515
async with get_db_session() as session:
16-
result = await session.exec(select(MainCommand))
17-
commands = list(result.all())
16+
result = await session.execute(select(MainCommand))
17+
commands = list(result.scalars().all())
1818
return commands
1919

2020

gs/backend/data/data_wrappers/mcc_wrappers/main_telemetry_wrapper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ async def get_all_main_telemetries() -> list[MainTelemetry]:
1313
:return: a list of all main_telemetries
1414
"""
1515
async with get_db_session() as session:
16-
result = await session.exec(select(MainTelemetry))
17-
telemetries = list(result.all())
16+
result = await session.execute(select(MainTelemetry))
17+
telemetries = list(result.scalars().all())
1818
return telemetries
1919

2020

gs/backend/data/data_wrappers/mcc_wrappers/packet_commands_wrapper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ async def get_all_packet_commands() -> list[PacketCommands]:
1414
:return: a list of all packet_commands
1515
"""
1616
async with get_db_session() as session:
17-
result = await session.exec(select(PacketCommands))
18-
commands = list(result.all())
17+
result = await session.execute(select(PacketCommands))
18+
commands = list(result.scalars().all())
1919
return commands
2020

2121

0 commit comments

Comments
 (0)