Skip to content

Commit 0349e1b

Browse files
committedDec 12, 2023
use string for entry ID
1 parent 7895695 commit 0349e1b

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed
 

‎code/api/app/db_interfaces.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ class ExperimentModel(BaseModel):
1313

1414

1515
class ExperimentDBModel(ExperimentModel):
16-
id: int
16+
id: str
1717
is_running: bool
1818
started: Optional[int] = None
1919

2020

2121
class ExperimentDetailsDBModel(ExperimentDBModel):
22-
snapshots: List[tuple]
23-
temperatures: List[tuple]
22+
snapshots: List[tuple] = []
23+
temperatures: List[tuple] = []
2424

2525

2626
class DatabaseIface(ABC):

‎code/api/app/local_db.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def __init__(self):
1515
def add(self, experiment: ExperimentModel) -> int:
1616
experiment_id = len(self.experiments) + 1
1717
new_item = ExperimentDBModel(
18-
id=experiment_id,
18+
id=str(experiment_id),
1919
is_running=True,
2020
started=int(datetime.now().timestamp()),
2121
**experiment.dict()

‎code/api/app/tests/test_main.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def test_get_existing_experiment(client):
6060
response = client.get("/experiments/1")
6161
assert response.status_code == 200
6262
assert response.json() == {
63-
'id': 1,
63+
'id': '1',
6464
'is_running': True,
6565
**experiment_data,
6666
'started': fake_datetime,
@@ -81,7 +81,7 @@ def test_list_past_experiments(client):
8181
response = client.get("/experiments")
8282
assert response.status_code == 200
8383
assert response.json() == [{
84-
'id': 1,
84+
'id': '1',
8585
'is_running': True,
8686
'started': fake_datetime,
8787
**experiment_data

0 commit comments

Comments
 (0)
Please sign in to comment.