Skip to content

Commit

Permalink
update conftest in matomo-api
Browse files Browse the repository at this point in the history
  • Loading branch information
MJedr committed Oct 2, 2023
1 parent 549b11f commit 74c0521
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 6 additions & 0 deletions matomo-api/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import psycopg2
import pytest
from api import MatomoAPI


@pytest.fixture(scope="module")
Expand Down Expand Up @@ -45,3 +46,8 @@ def updated_env(monkeypatch):
)
for env_name, env_value in matomo_api_kwargs.items():
monkeypatch.setenv(env_name, env_value)


@pytest.fixture(scope='function')
def matomo_api():
yield MatomoAPI()
8 changes: 3 additions & 5 deletions matomo-api/tests/test_api.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
from datetime import datetime

import pytest
from api import MatomoAPI

matomo_api = MatomoAPI()

TEST_DAY = day = datetime.strptime("2023-10-02", "%Y-%m-%d")

Expand All @@ -12,7 +10,7 @@
filter_headers=["authorization", "Set-Cookie"],
filter_query_parameters=["token_auth", "idSite"],
)
def test_matomo_api_get_unique_visitors():
def test_matomo_api_get_unique_visitors(matomo_api):
visitors = matomo_api.get_unique_visitors(date=TEST_DAY)
assert visitors > 0

Expand All @@ -21,7 +19,7 @@ def test_matomo_api_get_unique_visitors():
filter_headers=["authorization", "Set-Cookie"],
filter_query_parameters=["token_auth", "idSite"],
)
def test_matomo_api_get_visits_per_day():
def test_matomo_api_get_visits_per_day(matomo_api):
visitors = matomo_api.get_visits_per_day(date=TEST_DAY)
assert visitors > 0

Expand All @@ -30,7 +28,7 @@ def test_matomo_api_get_visits_per_day():
filter_headers=["authorization", "Set-Cookie"],
filter_query_parameters=["token_auth", "idSite"],
)
def test_matomo_fetch_inspire_statistics(db):
def test_matomo_fetch_inspire_statistics(db, matomo_api):
_, db_cursor = db
matomo_api.fetch_inspire_statistics(date=TEST_DAY)

Expand Down

0 comments on commit 74c0521

Please sign in to comment.