From 4898c44e43d4a7f3282453e73eaf3248b6b2c121 Mon Sep 17 00:00:00 2001 From: Mark Date: Fri, 10 May 2024 14:19:50 +0300 Subject: [PATCH] add test for sign_up endpoint --- backend/api/auth/test_auth.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 backend/api/auth/test_auth.py diff --git a/backend/api/auth/test_auth.py b/backend/api/auth/test_auth.py new file mode 100644 index 0000000..8657904 --- /dev/null +++ b/backend/api/auth/test_auth.py @@ -0,0 +1,20 @@ +import json + +import pytest +from fastapi.testclient import TestClient + +from main import app + +client = TestClient(app) + + +@pytest.mark.parametrize('user,status', + [ + ({'name': 'new_user', 'password': 'test', 'lifetime': 1}, 200), + ({'name': 'existing_user', 'password': 'test', 'lifetime': 2}, 401), + ({'name': 'bad_user', 'password': 'test'}, 422), + ]) +def test_sign_up(fill_db, user: dict, status: int): + req = client.post('/api/sign-up', content=json.dumps(user)) + assert req.status_code == status + assert 1 == 1