From d57503aa32e10df71bb44884a7fe7a574920cf71 Mon Sep 17 00:00:00 2001 From: frgfm Date: Mon, 15 Mar 2021 23:26:21 +0100 Subject: [PATCH 1/4] feat: Updated media scopes --- src/app/api/routes/media.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/api/routes/media.py b/src/app/api/routes/media.py index e10ef138..9f32b38f 100644 --- a/src/app/api/routes/media.py +++ b/src/app/api/routes/media.py @@ -58,7 +58,7 @@ async def create_media_from_device(payload: BaseMedia, @router.get("/{media_id}/", response_model=MediaOut, summary="Get information about a specific media") -async def get_media(media_id: int = Path(..., gt=0)): +async def get_media(media_id: int = Path(..., gt=0), _=Security(get_current_access, scopes=["admin"])): """ Based on a media_id, retrieves information about the specified media """ @@ -66,7 +66,7 @@ async def get_media(media_id: int = Path(..., gt=0)): @router.get("/", response_model=List[MediaOut], summary="Get the list of all media") -async def fetch_media(): +async def fetch_media( _=Security(get_current_access, scopes=["admin"])): """ Retrieves the list of all media and their information """ From 48d68eb25a33db6f2b1f30ecd3e0b8b41c8d7782 Mon Sep 17 00:00:00 2001 From: frgfm Date: Mon, 15 Mar 2021 23:26:35 +0100 Subject: [PATCH 2/4] refactor: Renamed route function --- src/app/api/routes/media.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/api/routes/media.py b/src/app/api/routes/media.py index 9f32b38f..86e7e454 100644 --- a/src/app/api/routes/media.py +++ b/src/app/api/routes/media.py @@ -94,7 +94,7 @@ async def delete_media(media_id: int = Path(..., gt=0), _=Security(get_current_a @router.post("/{media_id}/upload", response_model=MediaOut, status_code=200) -async def upload_media( +async def upload_media_from_device( background_tasks: BackgroundTasks, media_id: int = Path(..., gt=0), file: UploadFile = File(...), From a95ba8f1b39a88e1bd54b89a8a2143a3d3f029c8 Mon Sep 17 00:00:00 2001 From: frgfm Date: Mon, 15 Mar 2021 23:59:46 +0100 Subject: [PATCH 3/4] test: Reindented properly table --- src/tests/routes/test_media.py | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/tests/routes/test_media.py b/src/tests/routes/test_media.py index 55faa50d..c53f2faf 100644 --- a/src/tests/routes/test_media.py +++ b/src/tests/routes/test_media.py @@ -26,19 +26,17 @@ {"id": 2, "login": "connected_user", "access_id": 2, "created_at": "2020-11-13T08:18:45.447773"}, ] -DEVICE_TABLE = [{"id": 1, "login": "connected_device", "owner_id": 1, - "access_id": 3, "specs": "raspberry", "elevation": None, "lat": None, - "lon": None, "yaw": None, "pitch": None, - "last_ping": None, "created_at": "2020-10-13T08:18:45.447773"}, - {"id": 2, "login": "second_device", "owner_id": 2, - "access_id": 4, "specs": "v0.1", "elevation": None, "lat": None, - "lon": None, "yaw": None, "pitch": None, - "last_ping": None, "created_at": "2020-10-13T08:18:45.447773"}, - {"id": 3, "login": "third_device", "owner_id": 1, - "access_id": 5, "specs": "v0.1", "elevation": None, - "lat": None, "lon": None, "yaw": None, "pitch": None, "last_ping": None, - "created_at": "2020-10-13T08:18:45.447773"} - ] +DEVICE_TABLE = [ + {"id": 1, "login": "connected_device", "owner_id": 1, "access_id": 3, "specs": "raspberry", + "elevation": None, "lat": None, "lon": None, "yaw": None, "pitch": None, "last_ping": None, + "created_at": "2020-10-13T08:18:45.447773"}, + {"id": 2, "login": "second_device", "owner_id": 2, "access_id": 4, "specs": "v0.1", + "elevation": None, "lat": None, "lon": None, "yaw": None, "pitch": None, "last_ping": None, + "created_at": "2020-10-13T08:18:45.447773"}, + {"id": 3, "login": "third_device", "owner_id": 1, "access_id": 5, "specs": "v0.1", + "elevation": None, "lat": None, "lon": None, "yaw": None, "pitch": None, "last_ping": None, + "created_at": "2020-10-13T08:18:45.447773"}, +] CONNECTED_DEVICE_ID = 3 From f397f665cee7c42e29202b31fa5f195d1472e7f4 Mon Sep 17 00:00:00 2001 From: frgfm Date: Tue, 16 Mar 2021 00:09:09 +0100 Subject: [PATCH 4/4] style: Fixed lint --- src/app/api/routes/media.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/api/routes/media.py b/src/app/api/routes/media.py index 86e7e454..cb8595c7 100644 --- a/src/app/api/routes/media.py +++ b/src/app/api/routes/media.py @@ -66,7 +66,7 @@ async def get_media(media_id: int = Path(..., gt=0), _=Security(get_current_acce @router.get("/", response_model=List[MediaOut], summary="Get the list of all media") -async def fetch_media( _=Security(get_current_access, scopes=["admin"])): +async def fetch_media(_=Security(get_current_access, scopes=["admin"])): """ Retrieves the list of all media and their information """