Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/pip/singer-sdk-0.33.0
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon authored Oct 19, 2023
2 parents ce5432b + e141c51 commit 4b3f5e9
Show file tree
Hide file tree
Showing 9 changed files with 116 additions and 13 deletions.
52 changes: 51 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
with:
fetch-depth: 0

- name: Set up Python
uses: actions/[email protected]
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 }}
Expand All @@ -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"}
Expand Down Expand Up @@ -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 }}
Expand Down
15 changes: 14 additions & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,27 @@
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",
"tests",
)


@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."""
Expand Down
6 changes: 3 additions & 3 deletions poetry.lock

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

8 changes: 8 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand All @@ -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 = """
Expand Down
8 changes: 8 additions & 0 deletions requests_cache.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"requests_cache": {
"enabled": true,
"config": {
"expire_after": 3600
}
}
}
7 changes: 7 additions & 0 deletions tap_jotform/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 9 additions & 1 deletion tap_jotform/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
5 changes: 5 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""Pytest configuration for tests in this directory."""

from __future__ import annotations

pytest_plugins = ("singer_sdk.testing.pytest_plugin",)
18 changes: 11 additions & 7 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 4b3f5e9

Please sign in to comment.