Add formatting to pipeline
continuous-integration/drone/push Build is passing Details

pull/7/head
Inex Code 2021-12-15 12:02:29 +03:00
parent c6873c2af3
commit 14ccc6b8c0
3 changed files with 10 additions and 0 deletions

View File

@ -14,3 +14,6 @@ steps:
- name: bandit
commands:
- bandit -ll -r selfprivacy_api
- name: formatting
commands:
- black --check .

View File

@ -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()

View File

@ -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"