diff --git a/client/docs/source/conf.py b/client/docs/source/conf.py index 3bc082f..e614472 100644 --- a/client/docs/source/conf.py +++ b/client/docs/source/conf.py @@ -104,6 +104,7 @@ # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ["_static"] + # Add googleanalytics id # ref: https://github.com/orenhecht/googleanalytics/blob/master/sphinxcontrib/googleanalytics.py def add_ga_javascript(app, pagename, templatename, context, doctree): diff --git a/client/pyrostorage/client.py b/client/pyrostorage/client.py index f00def9..e8b3996 100644 --- a/client/pyrostorage/client.py +++ b/client/pyrostorage/client.py @@ -144,9 +144,13 @@ def create_annotation(self, media_id: int, observations: List[str]) -> Response: HTTP response containing the created annotation """ - return requests.post(self.routes["create-annotation"], headers=self.headers, json={"media_id": media_id, observations: observations}) + return requests.post( + self.routes["create-annotation"], + headers=self.headers, + json={"media_id": media_id, observations: observations}, + ) - def update_annotation(self, annotation_id: int, observations: List[str]=None) -> Response: + def update_annotation(self, annotation_id: int, observations: List[str] = None) -> Response: """Update an annotation entry Example:: @@ -161,4 +165,8 @@ def update_annotation(self, annotation_id: int, observations: List[str]=None) -> Returns: HTTP response containing the updated annotation """ - return requests.post(f'self.routes["update-annotation"]/{annotation_id}', headers=self.headers, json={"observations": observations}) + return requests.post( + f'self.routes["update-annotation"]/{annotation_id}', + headers=self.headers, + json={"observations": observations}, + ) diff --git a/src/app/api/schemas.py b/src/app/api/schemas.py index 004a555..513f0af 100644 --- a/src/app/api/schemas.py +++ b/src/app/api/schemas.py @@ -90,8 +90,10 @@ class AnnotationIn(BaseModel): media_id: int = Field(..., gt=0) observations: List[ObservationType] + class AnnotationUpdateIn(BaseModel): observations: List[ObservationType] + class AnnotationOut(AnnotationIn, _CreatedAt, _Id): pass diff --git a/src/app/db/models.py b/src/app/db/models.py index 5111af0..38a14bf 100644 --- a/src/app/db/models.py +++ b/src/app/db/models.py @@ -5,7 +5,7 @@ import enum -from sqlalchemy import Column, DateTime, Enum, ForeignKey, Integer, String, ARRAY +from sqlalchemy import ARRAY, Column, DateTime, Enum, ForeignKey, Integer, String from sqlalchemy.orm import relationship from sqlalchemy.sql import func @@ -53,6 +53,7 @@ class ObservationType(str, enum.Enum): sky: str = "sky" smoke: str = "smoke" + class Annotations(Base): __tablename__ = "annotations" diff --git a/src/tests/routes/test_annotations.py b/src/tests/routes/test_annotations.py index 9af7e73..365bfbb 100644 --- a/src/tests/routes/test_annotations.py +++ b/src/tests/routes/test_annotations.py @@ -6,11 +6,10 @@ from app import db from app.api import crud +from app.db.models import ObservationType from tests.db_utils import TestSessionLocal, fill_table, get_entry from tests.utils import update_only_datetime -from app.db.models import ObservationType - ACCESS_TABLE = [ {"id": 1, "login": "first_login", "hashed_password": "hashed_pwd", "scope": "user"}, {"id": 2, "login": "second_login", "hashed_password": "hashed_pwd", "scope": "admin"}, @@ -22,7 +21,12 @@ ] ANNOTATIONS_TABLE = [ - {"id": 1, "media_id": 1, "observations": [ObservationType.fire, ObservationType.smoke, ObservationType.clouds], "created_at": "2020-10-13T08:18:45.447773"}, + { + "id": 1, + "media_id": 1, + "observations": [ObservationType.fire, ObservationType.smoke, ObservationType.clouds], + "created_at": "2020-10-13T08:18:45.447773", + }, {"id": 2, "media_id": 2, "observations": [], "created_at": "2022-10-13T08:18:45.447773"}, ]