Skip to content

Commit

Permalink
✅ Added more tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
myles committed Dec 29, 2022
1 parent 72a916c commit e4cb640
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ jobs:
- id: run-linters
name: Run linters 🚨
run: |
poetry run black --check mastodon_to_sqlite tests
poetry run isort --check mastodon_to_sqlite tests
poetry run black --check .
poetry run isort --check .
- id: run-typing
name: Run mypy 🏷
Expand Down
20 changes: 19 additions & 1 deletion poetry.lock

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

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pytest-cov = "^4.0.0"
responses = "^0.22.0"
mypy = "^0.991"
types-requests = "^2.28.11.7"
pytest-mock = "^3.10.0"

[tool.poetry.scripts]
mastodon-to-sqlite = "mastodon_to_sqlite.cli:cli"
Expand Down
4 changes: 4 additions & 0 deletions tests/fixture-auth.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"mastodon_domain": "mastodon.ooo",
"mastodon_access_token": "SBY-IAmAMastodonAccessToken",
}
27 changes: 27 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import pytest
from click.testing import CliRunner

from mastodon_to_sqlite import cli


@pytest.mark.parametrize(
"verify_auth_return_value, expected_stdout_startswith",
(
(True, "Successfully"),
(False, "Failed"),
),
)
def test_verify_auth(
verify_auth_return_value, expected_stdout_startswith, mocker
):
mocker.patch(
"mastodon_to_sqlite.cli.service.verify_auth",
return_value=verify_auth_return_value,
)

runner = CliRunner()
result = runner.invoke(
cli.verify_auth, ["--auth", "tests/fixture-auth.json"]
)

assert result.stdout.startswith(expected_stdout_startswith)

0 comments on commit e4cb640

Please sign in to comment.