Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MJedr committed Oct 17, 2023
1 parent 762ed91 commit 6701c8e
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 129 deletions.
49 changes: 18 additions & 31 deletions matomo-api/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion matomo-api/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ pytest = "^7.4.2"
pytest-vcr = "^1.0.2"
psycopg2 = "^2.9.8"
urllib3 = "1.26.7"
freezegun = "^1.2.2"

[tool.poetry.dev-dependencies]
mock = "^5.1.0"

[build-system]
requires = ["poetry-core>=1.0.0"]
Expand Down
90 changes: 0 additions & 90 deletions matomo-api/tests/cassettes/test_cli_default_arguments.yaml

This file was deleted.

18 changes: 11 additions & 7 deletions matomo-api/tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from datetime import datetime, timedelta

import mock
import pytest
from api import MatomoAPI
from cli import fetch_matomo_inspire_data
from click.testing import CliRunner
from freezegun import freeze_time


@pytest.mark.vcr(
Expand All @@ -14,12 +17,13 @@ def test_cli(db):
assert result.exit_code == 0


@pytest.mark.vcr(
filter_headers=["authorization", "Set-Cookie"],
filter_query_parameters=["token_auth", "idSite"],
)
@freeze_time("2023-10-05")
def test_cli_default_arguments(db):
@mock.patch.object(MatomoAPI, "fetch_inspire_statistics")
def test_cli_default_arguments(mocked_api, db):
runner = CliRunner()
result = runner.invoke(fetch_matomo_inspire_data, [])
yesterday = datetime.now() - timedelta(days=1)

assert result.exit_code == 0
assert mocked_api.call_args[0][0].day == yesterday.day
assert mocked_api.call_args[0][0].month == yesterday.month
assert mocked_api.call_args[0][0].year == yesterday.year

0 comments on commit 6701c8e

Please sign in to comment.