[mastodon] Deprecate GET mastodon route
This commit is contained in:
parent
afd0894952
commit
4f96dfbee7
|
@ -93,15 +93,6 @@ async def mastodon_read_all(hood=Depends(get_hood)):
|
||||||
return await MastodonAccount.objects.filter(hood=hood).all()
|
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(
|
@router.delete(
|
||||||
"/{mastodon_id}",
|
"/{mastodon_id}",
|
||||||
status_code=status.HTTP_204_NO_CONTENT,
|
status_code=status.HTTP_204_NO_CONTENT,
|
||||||
|
|
|
@ -1,46 +0,0 @@
|
||||||
# Copyright (C) 2020 by Cathy Hu <cathy.hu@fau.de>
|
|
||||||
# Copyright (C) 2020 by Martin Rey <martin.rey@mailbox.org>
|
|
||||||
#
|
|
||||||
# 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
|
|
Loading…
Reference in a new issue