2022-01-10 20:35:00 +00:00
|
|
|
# pylint: disable=redefined-outer-name
|
|
|
|
# pylint: disable=unused-argument
|
2022-08-25 17:03:56 +00:00
|
|
|
import os
|
2022-01-10 20:35:00 +00:00
|
|
|
import pytest
|
2024-12-11 13:36:32 +00:00
|
|
|
from typing import Optional
|
2022-01-10 20:35:00 +00:00
|
|
|
|
2024-12-11 15:55:52 +00:00
|
|
|
from selfprivacy_api.utils import WriteUserData, ReadUserData, get_test_mode
|
2023-09-20 13:48:30 +00:00
|
|
|
|
2022-01-10 20:35:00 +00:00
|
|
|
|
|
|
|
def test_get_api_version(authorized_client):
|
|
|
|
response = authorized_client.get("/api/version")
|
|
|
|
assert response.status_code == 200
|
2022-08-25 17:03:56 +00:00
|
|
|
assert "version" in response.json()
|
2022-01-10 20:35:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_get_api_version_unauthorized(client):
|
|
|
|
response = client.get("/api/version")
|
|
|
|
assert response.status_code == 200
|
2022-08-25 17:03:56 +00:00
|
|
|
assert "version" in response.json()
|
2022-01-24 20:01:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_read_invalid_user_data():
|
|
|
|
with pytest.raises(ValueError):
|
|
|
|
with ReadUserData("invalid") as user_data:
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
def test_write_invalid_user_data():
|
|
|
|
with pytest.raises(ValueError):
|
|
|
|
with WriteUserData("invalid") as user_data:
|
|
|
|
pass
|
2022-08-25 17:03:56 +00:00
|
|
|
|
|
|
|
|
2024-12-11 13:36:32 +00:00
|
|
|
# TODO: Does it make any sense to have such a fixture though?
|
|
|
|
# If it can only be called from tests then it is always test
|
2022-08-25 17:03:56 +00:00
|
|
|
@pytest.fixture
|
|
|
|
def test_mode():
|
2024-12-11 13:36:32 +00:00
|
|
|
return get_test_mode()
|
2022-08-25 17:03:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_the_test_mode(test_mode):
|
|
|
|
assert test_mode == "true"
|