Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to legacy tests setup to be able to mock requests #1

Merged
merged 4 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 13 additions & 114 deletions poetry.lock

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

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ requests = "^2.31.0"
[tool.poetry.group.dev.dependencies]
pytest = "^7.4.0"
singer-sdk = { version="^0.31.1", extras = ["testing"] }
requests-mock = "^1.11.0"

[tool.mypy]
python_version = "3.9"
Expand All @@ -34,7 +35,7 @@ ignore = [
]
select = ["ALL"]
src = ["tap_linear"]
target-version = "py311"
target-version = "py38"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why Python 3.8?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because ruff will otherwise propose code improvements that are not compatible with older yet supported Python versions. Notably https://github.com/leukeleu/tap-linear/pull/1/files/3bc74435bb0edf42e6c9193cb2c5634553808231#diff-938de46e643ab091cff6a7c23e4e752e8907e2266f47889d988923352f7a1058L10 was ruff's idea, but it broke on Python < 3.11.



[tool.ruff.flake8-annotations]
Expand Down
15 changes: 8 additions & 7 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@

import datetime

from singer_sdk.testing import get_tap_test_class
from singer_sdk.testing.legacy import get_standard_tap_tests

from tap_linear.tap import TapLinear

SAMPLE_CONFIG = {
"start_date": datetime.datetime.now(datetime.UTC).strftime("%Y-%m-%d"),
"start_date": datetime.datetime.now(datetime.timezone.utc).strftime("%Y-%m-%d"),
"auth_token": "test",
}


# Run standard built-in tap tests from the SDK:
TestTapLinear = get_tap_test_class(
tap_class=TapLinear,
config=SAMPLE_CONFIG,
)
def test_standard_tap_tests(requests_mock) -> None: # noqa: ANN001
"""Run standard built-in tap tests from the SDK."""
requests_mock.post("/graphql", json={"data": {"results": {"nodes": []}}})
tests = get_standard_tap_tests(TapLinear, config=SAMPLE_CONFIG)
for test in tests:
test()
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This file can be used to customize tox tests as well as other test frameworks like flake8 and mypy

[tox]
envlist = py37, py38, py39, py310, py311
envlist = py38, py39, py310, py311
isolated_build = true

[testenv]
Expand All @@ -13,7 +13,7 @@ commands =
[testenv:pytest]
# Run the python tests.
# To execute, run `tox -e pytest`
envlist = py37, py38, py39, py310, py311
envlist = py38, py39, py310, py311
commands =
poetry install -v
poetry run pytest