I'm try to test the api I wrote with Fastapi. I have the following method in my router :
@app.get('/webrecord/check_if_object_exist')
async def check_if_object_exist(payload: WebRecord) -> bool:
key = get_key_of_obj(payload.data) if payload.key is None else payload.key
return await check_if_key_exist(key)
and the following test in my test file :
client = TestClient(app)
class ServiceTest(unittest.TestCase):
.....
def test_check_if_object_is_exist(self):
webrecord_json = {'a':1}
response = client.get("/webrecord/check_if_object_exist", json=webrecord_json)
assert response.status_code == 200
assert response.json(), "webrecord should already be in db, expected : True, got : {}".format(response.json())
When I run the code in debug I realized that the break points inside the get method aren't reached. When I changed the type of the request to post everything worked fine.
What am I doing wrong?