selfprivacy-rest-api/tests/test_common.py

41 lines
947 B
Python
Raw Normal View History

# pylint: disable=redefined-outer-name
# pylint: disable=unused-argument
import json
2022-08-20 18:47:32 +00:00
import os
import pytest
2022-01-24 20:01:37 +00:00
from selfprivacy_api.utils import WriteUserData, ReadUserData
def test_get_api_version(authorized_client):
response = authorized_client.get("/api/version")
assert response.status_code == 200
2022-08-10 23:36:36 +00:00
assert "version" in response.json()
def test_get_api_version_unauthorized(client):
response = client.get("/api/version")
assert response.status_code == 200
2022-08-10 23:36:36 +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-20 18:47:32 +00:00
@pytest.fixture
def test_mode():
return os.environ.get("TEST_MODE")
def test_the_test_mode(test_mode):
assert test_mode == "true"