Browse Source

Add formatting to pipeline

pull/7/head
Inex Code 12 months ago
parent
commit
14ccc6b8c0
  1. 3
      .drone.yml
  2. 4
      tests/conftest.py
  3. 3
      tests/test_system.py

3
.drone.yml

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

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

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

Loading…
Cancel
Save