diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6d003be..2c91e4a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,8 +27,53 @@ concurrency: cancel-in-progress: true jobs: + run: + runs-on: ubuntu-latest + env: + PIP_CONSTRAINT: .github/workflows/constraints.txt + FORCE_COLOR: "1" + NOXSESSION: run + NOXPYTHON: "3.11" + steps: + - name: Checkout code + uses: actions/checkout@v4.1.0 + with: + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v4.7.0 + with: + python-version: 3.11 + + - name: Install Poetry + run: | + pipx install poetry + pipx inject poetry poetry-dynamic-versioning[plugin] + poetry --version + poetry self show plugins + + - name: Install Nox + run: | + pipx install nox + pipx inject nox nox-poetry + nox --version + + - name: Run Nox + env: + TAP_JOTFORM_API_KEY: ${{ secrets.TAP_JOTFORM_API_KEY }} + TAP_JOTFORM_API_URL: "https://api.jotform.com" + run: | + nox + + - name: Upload request cache + uses: actions/upload-artifact@v3 + with: + name: requests-cache + path: http_cache.sqlite + tests: runs-on: ubuntu-latest + needs: run env: PIP_CONSTRAINT: .github/workflows/constraints.txt NOXSESSION: ${{ matrix.session }} @@ -37,7 +82,7 @@ jobs: strategy: matrix: include: - - {python-version: "3.10", session: "mypy"} + - {python-version: "3.11", session: "mypy"} - {python-version: "3.11", session: "tests"} - {python-version: "3.10", session: "tests"} - {python-version: "3.9", session: "tests"} @@ -72,6 +117,11 @@ jobs: pipx inject nox nox-poetry nox --version + - name: Download request cache + uses: actions/download-artifact@v3 + with: + name: requests-cache + - name: Run Nox env: TAP_JOTFORM_API_KEY: ${{ secrets.TAP_JOTFORM_API_KEY }} diff --git a/noxfile.py b/noxfile.py index 9acd23b..e5f653b 100644 --- a/noxfile.py +++ b/noxfile.py @@ -22,7 +22,7 @@ tests_dir = "tests" python_versions = ["3.11", "3.10", "3.9", "3.8"] -main_python_version = "3.10" +main_python_version = "3.11" locations = src_dir, tests_dir, "noxfile.py" nox.options.sessions = ( "mypy", @@ -30,6 +30,19 @@ ) +@session(python=main_python_version) +def run(session: Session) -> None: + """Run the tap with request caching enabled.""" + session.install(".") + session.run( + "tap-jotform", + "--config", + "requests_cache.config.json", + "--config", + "ENV", + ) + + @session(python=python_versions) def mypy(session: Session) -> None: """Check types with mypy.""" diff --git a/poetry.lock b/poetry.lock index f68a15b..2f55ee3 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1303,13 +1303,13 @@ six = "*" [[package]] name = "urllib3" -version = "1.26.17" +version = "1.26.18" description = "HTTP library with thread-safe connection pooling, file post, and more." optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*" files = [ - {file = "urllib3-1.26.17-py2.py3-none-any.whl", hash = "sha256:94a757d178c9be92ef5539b8840d48dc9cf1b2709c9d6b588232a055c524458b"}, - {file = "urllib3-1.26.17.tar.gz", hash = "sha256:24d6a242c28d29af46c3fae832c36db3bbebcc533dd1bb549172cd739c82df21"}, + {file = "urllib3-1.26.18-py2.py3-none-any.whl", hash = "sha256:34b97092d7e0a3a8cf7cd10e386f401b3737364026c45e622aa02903dffe0f07"}, + {file = "urllib3-1.26.18.tar.gz", hash = "sha256:f8ecc1bba5667413457c529ab955bf8c67b45db799d159066261719e328580a0"}, ] [package.extras] diff --git a/pyproject.toml b/pyproject.toml index 9bc7d29..2900c10 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -44,6 +44,9 @@ select = ["ALL"] src = ["tap_jotform", "tests", "noxfile.py"] target-version = "py38" +[tool.ruff.flake8-annotations] +allow-star-arg-any = true + [tool.ruff.isort] known-first-party = ["tap_jotform"] @@ -54,6 +57,11 @@ known-first-party = ["tap_jotform"] [tool.ruff.pydocstyle] convention = "google" +[tool.pytest.ini_options] +addopts = [ + "-vvv", +] + [tool.poetry-dynamic-versioning] enable = true format-jinja = """ diff --git a/requests_cache.config.json b/requests_cache.config.json new file mode 100644 index 0000000..422a5dc --- /dev/null +++ b/requests_cache.config.json @@ -0,0 +1,8 @@ +{ + "requests_cache": { + "enabled": true, + "config": { + "expire_after": 3600 + } + } +} diff --git a/tap_jotform/client.py b/tap_jotform/client.py index 380e95f..3582fb5 100644 --- a/tap_jotform/client.py +++ b/tap_jotform/client.py @@ -38,6 +38,13 @@ class JotformStream(RESTStream): INTEGER_FIELDS: tuple[str, ...] = () + _requests_session: requests.Session | None + + def __init__(self, *args: t.Any, **kwargs: t.Any) -> None: + """Initialize the stream object.""" + super().__init__(*args, **kwargs) + self._requests_session = None + @property def url_base(self) -> str: """Return the API URL root, configurable via tap settings. diff --git a/tap_jotform/streams.py b/tap_jotform/streams.py index ea18bd9..fec7165 100644 --- a/tap_jotform/streams.py +++ b/tap_jotform/streams.py @@ -263,17 +263,25 @@ class UserHistory(JotformStream): allowed_values=[ "userCreation", "userLogin", + "userLogout", "formCreation", "formUpdate", "formDelete", "formPurge", + "lastUpdate", + "passwordChanged", + "portalCreated", + "portalUpdated", + "reportCreated", + "reportUpdated", + "submissionDeleteAll", ], ), th.Property("username", th.StringType), th.Property("ip", th.StringType), th.Property("server", th.StringType), th.Property("timestamp", th.IntegerType), - th.Property("email", th.EmailType), + th.Property("email", th.StringType), th.Property("parent", th.StringType), th.Property("subuser", th.StringType), ).to_dict() diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..e8ecb41 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,5 @@ +"""Pytest configuration for tests in this directory.""" + +from __future__ import annotations + +pytest_plugins = ("singer_sdk.testing.pytest_plugin",) diff --git a/tests/test_core.py b/tests/test_core.py index 91f444f..2362d27 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -4,15 +4,19 @@ from typing import Any -from singer_sdk.testing import get_standard_tap_tests +from singer_sdk.testing import get_tap_test_class from tap_jotform.tap import TapJotform -SAMPLE_CONFIG: dict[str, Any] = {} +SAMPLE_CONFIG: dict[str, Any] = { + "requests_cache": { + "enabled": True, + "config": { + "expire_after": 3600, + }, + }, + "start_date": "2021-01-01T00:00:00Z", +} -def test_standard_tap_tests(): - """Run standard tap tests from the SDK.""" - tests = get_standard_tap_tests(TapJotform, config=SAMPLE_CONFIG) - for test in tests: - test() +TestTapJotform = get_tap_test_class(TapJotform, config=SAMPLE_CONFIG)