From 14ccc6b8c095b7c8a859f9a6a3ca26b79a38ef0e Mon Sep 17 00:00:00 2001 From: Inex Code Date: Wed, 15 Dec 2021 12:02:29 +0300 Subject: [PATCH] Add formatting to pipeline --- .drone.yml | 3 +++ tests/conftest.py | 4 ++++ tests/test_system.py | 3 +++ 3 files changed, 10 insertions(+) diff --git a/.drone.yml b/.drone.yml index 0f30dc5..24142c8 100644 --- a/.drone.yml +++ b/.drone.yml @@ -14,3 +14,6 @@ steps: - name: bandit commands: - bandit -ll -r selfprivacy_api +- name: formatting + commands: + - black --check . \ No newline at end of file diff --git a/tests/conftest.py b/tests/conftest.py index 93f1e04..aab30dd 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -31,6 +31,7 @@ class AuthorizedClient(testing.FlaskClient): kwargs["headers"]["Authorization"] = f"Bearer {self.token}" return super().open(*args, **kwargs) + class WrongAuthClient(testing.FlaskClient): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) @@ -42,16 +43,19 @@ class WrongAuthClient(testing.FlaskClient): kwargs["headers"]["Authorization"] = f"Bearer {self.token}" return super().open(*args, **kwargs) + @pytest.fixture def authorized_client(app): app.test_client_class = AuthorizedClient return app.test_client() + @pytest.fixture def wrong_auth_client(app): app.test_client_class = WrongAuthClient return app.test_client() + @pytest.fixture def runner(app): return app.test_cli_runner() diff --git a/tests/test_system.py b/tests/test_system.py index 33aed6f..e7cfb0b 100644 --- a/tests/test_system.py +++ b/tests/test_system.py @@ -4,14 +4,17 @@ import json import pytest from selfprivacy_api.utils import get_domain + @pytest.fixture def domain_file(mocker, datadir): mocker.patch("selfprivacy_api.utils.DOMAIN_FILE", datadir / "domain") return datadir + def test_wrong_auth(wrong_auth_client): response = wrong_auth_client.get("/system/pythonVersion") assert response.status_code == 401 + def test_get_domain(authorized_client, domain_file): assert get_domain() == "test-domain.tld"