From 4f96dfbee7a144a9256c0ce4d5bb7681359aacb1 Mon Sep 17 00:00:00 2001 From: missytake Date: Sun, 19 Mar 2023 14:49:26 +0100 Subject: [PATCH] [mastodon] Deprecate GET mastodon route --- .../src/kibicara/platforms/mastodon/webapi.py | 9 ---- .../test_api_mastodon_get_bot.py | 46 ------------------- 2 files changed, 55 deletions(-) delete mode 100644 backend/tests/tests_mastodon/test_api_mastodon_get_bot.py diff --git a/backend/src/kibicara/platforms/mastodon/webapi.py b/backend/src/kibicara/platforms/mastodon/webapi.py index a71f1fd..421467c 100644 --- a/backend/src/kibicara/platforms/mastodon/webapi.py +++ b/backend/src/kibicara/platforms/mastodon/webapi.py @@ -93,15 +93,6 @@ async def mastodon_read_all(hood=Depends(get_hood)): return await MastodonAccount.objects.filter(hood=hood).all() -@router.get( - "/{mastodon_id}", - # TODO response_model - operation_id="get_mastodon", -) -async def mastodon_read(mastodon=Depends(get_mastodon)): - return mastodon - - @router.delete( "/{mastodon_id}", status_code=status.HTTP_204_NO_CONTENT, diff --git a/backend/tests/tests_mastodon/test_api_mastodon_get_bot.py b/backend/tests/tests_mastodon/test_api_mastodon_get_bot.py deleted file mode 100644 index f6afa8d..0000000 --- a/backend/tests/tests_mastodon/test_api_mastodon_get_bot.py +++ /dev/null @@ -1,46 +0,0 @@ -# Copyright (C) 2020 by Cathy Hu -# Copyright (C) 2020 by Martin Rey -# -# SPDX-License-Identifier: 0BSD - -from fastapi import status -from kibicara.platforms.mastodon.model import MastodonInstance - - -def test_mastodon_get_bot(client, auth_header, event_loop, mastodon): - response = client.get( - "/api/hoods/{0}/mastodon/{1}".format(mastodon.hood.id, mastodon.id), - headers=auth_header, - ) - assert response.status_code == status.HTTP_200_OK - assert response.json()["id"] == mastodon.id - assert response.json()["username"] == mastodon.username - assert response.json()["access_token"] == mastodon.access_token - mastodon_instance = event_loop.run_until_complete( - MastodonInstance.objects.get(id=mastodon.instance) - ) - assert response.json()["instance"]["name"] == mastodon_instance.name - assert not response.json()["instance"].get("client_id") - assert not response.json()["instance"].get("client_secret") - - -def test_mastodon_get_bot_invalid_id(client, auth_header, hood_id): - response = client.get("/api/hoods/1337/mastodon/123", headers=auth_header) - assert response.status_code == status.HTTP_404_NOT_FOUND - response = client.get("/api/hoods/wrong/mastodon/123", headers=auth_header) - assert response.status_code == status.HTTP_422_UNPROCESSABLE_ENTITY - response = client.get( - "/api/hoods/{0}/mastodon/7331".format(hood_id), headers=auth_header - ) - assert response.status_code == status.HTTP_404_NOT_FOUND - response = client.get( - "/api/hoods/{0}/mastodon/wrong".format(hood_id), headers=auth_header - ) - assert response.status_code == status.HTTP_404_NOT_FOUND - - -def test_mastodon_get_bot_unauthorized(client, mastodon): - response = client.get( - "/api/hoods/{0}/mastodon/{1}".format(mastodon.hood.id, mastodon.id) - ) - assert response.status_code == status.HTTP_401_UNAUTHORIZED