From 9901d85589b6316cb7646efb64a779535e401992 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgar=20Ram=C3=ADrez=20Mondrag=C3=B3n?= <16805946+edgarrmondragon@users.noreply.github.com> Date: Thu, 18 Jul 2024 22:26:56 -0600 Subject: [PATCH] test: Use DummyJSON instead of Google Analytics for integration tests (#2551) --- .github/workflows/test.yml | 3 - .../.github/dependabot.yml | 41 ++++ .../.github/workflows/build.yml | 45 ++++ .../.github/workflows/test.yml | 32 +++ samples/sample_tap_dummy_json/.gitignore | 139 ++++++++++++ .../.pre-commit-config.yaml | 38 ++++ .../sample_tap_dummy_json/.secrets/.gitignore | 10 + samples/sample_tap_dummy_json/LICENSE | 202 ++++++++++++++++++ samples/sample_tap_dummy_json/README.md | 131 ++++++++++++ samples/sample_tap_dummy_json/__init__.py | 0 samples/sample_tap_dummy_json/meltano.yml | 43 ++++ .../sample_tap_dummy_json/output/.gitignore | 4 + .../loaders/target-jsonl--andyh1203.lock | 34 +++ samples/sample_tap_dummy_json/pyproject.toml | 44 ++++ samples/sample_tap_dummy_json/ruff.toml | 24 +++ .../tap_dummyjson/__init__.py | 1 + .../tap_dummyjson/__main__.py | 7 + .../tap_dummyjson/auth.py | 72 +++++++ .../tap_dummyjson/client.py | 45 ++++ .../tap_dummyjson/schemas/__init__.py | 1 + .../tap_dummyjson/streams.py | 67 ++++++ .../tap_dummyjson/tap.py | 51 +++++ .../sample_tap_dummy_json/tests/__init__.py | 1 + .../sample_tap_dummy_json/tests/test_core.py | 11 + samples/sample_tap_dummy_json/tox.ini | 19 ++ .../sample_tap_google_analytics/__init__.py | 3 - .../sample_tap_google_analytics/__main__.py | 5 - samples/sample_tap_google_analytics/ga_tap.py | 38 ---- .../ga_tap_stream.py | 95 -------- .../resources/default_report_definitions.json | 95 -------- .../schemas/simple-sample.json | 11 - tests/external/test_tap_dummyjson.py | 11 + tests/external/test_tap_google_analytics.py | 26 --- 33 files changed, 1073 insertions(+), 276 deletions(-) create mode 100644 samples/sample_tap_dummy_json/.github/dependabot.yml create mode 100644 samples/sample_tap_dummy_json/.github/workflows/build.yml create mode 100644 samples/sample_tap_dummy_json/.github/workflows/test.yml create mode 100644 samples/sample_tap_dummy_json/.gitignore create mode 100644 samples/sample_tap_dummy_json/.pre-commit-config.yaml create mode 100644 samples/sample_tap_dummy_json/.secrets/.gitignore create mode 100644 samples/sample_tap_dummy_json/LICENSE create mode 100644 samples/sample_tap_dummy_json/README.md create mode 100644 samples/sample_tap_dummy_json/__init__.py create mode 100644 samples/sample_tap_dummy_json/meltano.yml create mode 100644 samples/sample_tap_dummy_json/output/.gitignore create mode 100644 samples/sample_tap_dummy_json/plugins/loaders/target-jsonl--andyh1203.lock create mode 100644 samples/sample_tap_dummy_json/pyproject.toml create mode 100644 samples/sample_tap_dummy_json/ruff.toml create mode 100644 samples/sample_tap_dummy_json/tap_dummyjson/__init__.py create mode 100644 samples/sample_tap_dummy_json/tap_dummyjson/__main__.py create mode 100644 samples/sample_tap_dummy_json/tap_dummyjson/auth.py create mode 100644 samples/sample_tap_dummy_json/tap_dummyjson/client.py create mode 100644 samples/sample_tap_dummy_json/tap_dummyjson/schemas/__init__.py create mode 100644 samples/sample_tap_dummy_json/tap_dummyjson/streams.py create mode 100644 samples/sample_tap_dummy_json/tap_dummyjson/tap.py create mode 100644 samples/sample_tap_dummy_json/tests/__init__.py create mode 100644 samples/sample_tap_dummy_json/tests/test_core.py create mode 100644 samples/sample_tap_dummy_json/tox.ini delete mode 100644 samples/sample_tap_google_analytics/__init__.py delete mode 100644 samples/sample_tap_google_analytics/__main__.py delete mode 100644 samples/sample_tap_google_analytics/ga_tap.py delete mode 100644 samples/sample_tap_google_analytics/ga_tap_stream.py delete mode 100644 samples/sample_tap_google_analytics/resources/default_report_definitions.json delete mode 100644 samples/sample_tap_google_analytics/schemas/simple-sample.json create mode 100644 tests/external/test_tap_dummyjson.py delete mode 100644 tests/external/test_tap_google_analytics.py diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 960aede32..3acc509fb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -113,9 +113,6 @@ jobs: SAMPLE_TAP_GITLAB_GROUP_IDS: ${{ secrets.SAMPLE_TAP_GITLAB_GROUP_IDS }} SAMPLE_TAP_GITLAB_PROJECT_IDS: ${{ secrets.SAMPLE_TAP_GITLAB_PROJECT_IDS }} SAMPLE_TAP_GITLAB_START_DATE: "2022-01-01T00:00:00Z" - SAMPLE_TAP_GOOGLE_ANALYTICS_CLIENT_EMAIL: ${{ secrets.SAMPLE_TAP_GOOGLE_ANALYTICS_CLIENT_EMAIL }} - SAMPLE_TAP_GOOGLE_ANALYTICS_PRIVATE_KEY: ${{ secrets.SAMPLE_TAP_GOOGLE_ANALYTICS_PRIVATE_KEY }} - SAMPLE_TAP_GOOGLE_ANALYTICS_VIEW_ID: ${{ secrets.SAMPLE_TAP_GOOGLE_ANALYTICS_VIEW_ID }} steps: - uses: actions/checkout@v4 diff --git a/samples/sample_tap_dummy_json/.github/dependabot.yml b/samples/sample_tap_dummy_json/.github/dependabot.yml new file mode 100644 index 000000000..0660ffdd4 --- /dev/null +++ b/samples/sample_tap_dummy_json/.github/dependabot.yml @@ -0,0 +1,41 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: pip + directory: "/" + schedule: + interval: weekly + commit-message: + prefix: "chore(deps): " + prefix-development: "chore(deps-dev): " + groups: + development-dependencies: + dependency-type: development + runtime-dependencies: + dependency-type: production + update-types: + - "patch" + - package-ecosystem: pip + directory: "/.github/workflows" + schedule: + interval: weekly + commit-message: + prefix: "ci: " + groups: + ci: + patterns: + - "*" + - package-ecosystem: github-actions + directory: "/" + schedule: + interval: weekly + commit-message: + prefix: "ci: " + groups: + actions: + patterns: + - "*" diff --git a/samples/sample_tap_dummy_json/.github/workflows/build.yml b/samples/sample_tap_dummy_json/.github/workflows/build.yml new file mode 100644 index 000000000..6698b8b6a --- /dev/null +++ b/samples/sample_tap_dummy_json/.github/workflows/build.yml @@ -0,0 +1,45 @@ +name: Release + +on: + push: + +permissions: + contents: write # Needed to upload artifacts to the release + id-token: write # Needed for OIDC PyPI publishing + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: hynek/build-and-inspect-python-package@v2 + + publish: + name: Publish to PyPI + runs-on: ubuntu-latest + needs: [build] + ## TODO: optionally provide the name of the environment for the trusted + ## publisher on PyPI + ## https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment + # environment: pypi + if: startsWith(github.ref, 'refs/tags/') + steps: + - uses: actions/download-artifact@v4 + with: + name: Packages + path: dist + - name: Upload wheel to release + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{secrets.GITHUB_TOKEN}} + file: dist/*.whl + tag: ${{github.ref}} + overwrite: true + file_glob: true + + - name: Publish + ## TODO: create a trusted publisher on PyPI + ## https://docs.pypi.org/trusted-publishers/ + uses: pypa/gh-action-pypi-publish@v1.9.0 diff --git a/samples/sample_tap_dummy_json/.github/workflows/test.yml b/samples/sample_tap_dummy_json/.github/workflows/test.yml new file mode 100644 index 000000000..6e3d559c0 --- /dev/null +++ b/samples/sample_tap_dummy_json/.github/workflows/test.yml @@ -0,0 +1,32 @@ +### A CI workflow template that runs linting and python testing +### TODO: Modify as needed or as desired. + +name: Test tap-dummyjson + +on: [push] + +jobs: + pytest: + runs-on: ubuntu-latest + env: + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + strategy: + fail-fast: false + matrix: + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Install Poetry + run: | + pip install poetry + - name: Install dependencies + run: | + poetry env use ${{ matrix.python-version }} + poetry install + - name: Test with pytest + run: | + poetry run pytest diff --git a/samples/sample_tap_dummy_json/.gitignore b/samples/sample_tap_dummy_json/.gitignore new file mode 100644 index 000000000..9fd224433 --- /dev/null +++ b/samples/sample_tap_dummy_json/.gitignore @@ -0,0 +1,139 @@ +# Poetry +poetry.lock + +# Secrets and internal config files +**/.secrets/* + +# Ignore meltano internal cache and sqlite systemdb + +.meltano/ + +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +.python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ diff --git a/samples/sample_tap_dummy_json/.pre-commit-config.yaml b/samples/sample_tap_dummy_json/.pre-commit-config.yaml new file mode 100644 index 000000000..5cad9ea54 --- /dev/null +++ b/samples/sample_tap_dummy_json/.pre-commit-config.yaml @@ -0,0 +1,38 @@ +ci: + autofix_prs: true + autoupdate_schedule: weekly + autoupdate_commit_msg: 'chore: pre-commit autoupdate' + +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.6.0 + hooks: + - id: check-json + exclude: | + (?x)^( + \.vscode/.*\.json + )$ + - id: check-toml + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace + +- repo: https://github.com/python-jsonschema/check-jsonschema + rev: 0.28.6 + hooks: + - id: check-dependabot + - id: check-github-workflows + +- repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.5.0 + hooks: + - id: ruff + args: [--fix, --exit-non-zero-on-fix, --show-fixes] + - id: ruff-format + +- repo: https://github.com/pre-commit/mirrors-mypy + rev: v1.10.1 + hooks: + - id: mypy + additional_dependencies: + - types-requests diff --git a/samples/sample_tap_dummy_json/.secrets/.gitignore b/samples/sample_tap_dummy_json/.secrets/.gitignore new file mode 100644 index 000000000..33c6acd03 --- /dev/null +++ b/samples/sample_tap_dummy_json/.secrets/.gitignore @@ -0,0 +1,10 @@ +# IMPORTANT! This folder is hidden from git - if you need to store config files or other secrets, +# make sure those are never staged for commit into your git repo. You can store them here or another +# secure location. +# +# Note: This may be redundant with the global .gitignore for, and is provided +# for redundancy. If the `.secrets` folder is not needed, you may delete it +# from the project. + +* +!.gitignore diff --git a/samples/sample_tap_dummy_json/LICENSE b/samples/sample_tap_dummy_json/LICENSE new file mode 100644 index 000000000..20f02f1bc --- /dev/null +++ b/samples/sample_tap_dummy_json/LICENSE @@ -0,0 +1,202 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + + Copyright 2024 Edgar Ramírez-Mondragón + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/samples/sample_tap_dummy_json/README.md b/samples/sample_tap_dummy_json/README.md new file mode 100644 index 000000000..e154663d9 --- /dev/null +++ b/samples/sample_tap_dummy_json/README.md @@ -0,0 +1,131 @@ +# tap-dummyjson + +`tap-dummyjson` is a Singer tap for DummyJSON. + +Built with the [Meltano Tap SDK](https://sdk.meltano.com) for Singer Taps. + + + +## Configuration + +### Accepted Config Options + + + +A full list of supported settings and capabilities for this +tap is available by running: + +```bash +tap-dummyjson --about +``` + +### Configure using environment variables + +This Singer tap will automatically import any environment variables within the working directory's +`.env` if the `--config=ENV` is provided, such that config values will be considered if a matching +environment variable is set either in the terminal context or in the `.env` file. + +### Source Authentication and Authorization + + + +## Usage + +You can easily run `tap-dummyjson` by itself or in a pipeline using [Meltano](https://meltano.com/). + +### Executing the Tap Directly + +```bash +tap-dummyjson --version +tap-dummyjson --help +tap-dummyjson --config CONFIG --discover > ./catalog.json +``` + +## Developer Resources + +Follow these instructions to contribute to this project. + +### Initialize your Development Environment + +```bash +pipx install poetry +poetry install +``` + +### Create and Run Tests + +Create tests within the `tests` subfolder and + then run: + +```bash +poetry run pytest +``` + +You can also test the `tap-dummyjson` CLI interface directly using `poetry run`: + +```bash +poetry run tap-dummyjson --help +``` + +### Testing with [Meltano](https://www.meltano.com) + +_**Note:** This tap will work in any Singer environment and does not require Meltano. +Examples here are for convenience and to streamline end-to-end orchestration scenarios._ + + + +Next, install Meltano (if you haven't already) and any needed plugins: + +```bash +# Install meltano +pipx install meltano +# Initialize meltano within this directory +cd tap-dummyjson +meltano install +``` + +Now you can test and orchestrate using Meltano: + +```bash +# Test invocation: +meltano invoke tap-dummyjson --version +# OR run a test `elt` pipeline: +meltano elt tap-dummyjson target-jsonl +``` + +### SDK Dev Guide + +See the [dev guide](https://sdk.meltano.com/en/latest/dev_guide.html) for more instructions on how to use the SDK to +develop your own taps and targets. diff --git a/samples/sample_tap_dummy_json/__init__.py b/samples/sample_tap_dummy_json/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/samples/sample_tap_dummy_json/meltano.yml b/samples/sample_tap_dummy_json/meltano.yml new file mode 100644 index 000000000..02a2120e2 --- /dev/null +++ b/samples/sample_tap_dummy_json/meltano.yml @@ -0,0 +1,43 @@ +version: 1 +send_anonymous_usage_stats: true +project_id: "tap-dummyjson" +default_environment: test +environments: +- name: test +plugins: + extractors: + - name: "tap-dummyjson" + namespace: "tap_dummyjson" + + pip_url: -e . + + capabilities: + - state + - catalog + - discover + - about + - stream-maps + + settings: + - name: username + label: Username + - name: password + label: Password + kind: password + sensitive: true + - name: api_url + label: API URL + description: The base URL for the API + - name: start_date + kind: date_iso8601 + + settings_group_validation: + - [username, password] + + config: + start_date: '2024-01-01T00:00:00Z' + + loaders: + - name: target-jsonl + variant: andyh1203 + pip_url: target-jsonl diff --git a/samples/sample_tap_dummy_json/output/.gitignore b/samples/sample_tap_dummy_json/output/.gitignore new file mode 100644 index 000000000..80ff9d2a6 --- /dev/null +++ b/samples/sample_tap_dummy_json/output/.gitignore @@ -0,0 +1,4 @@ +# This directory is used as a target by target-jsonl, so ignore all files + +* +!.gitignore diff --git a/samples/sample_tap_dummy_json/plugins/loaders/target-jsonl--andyh1203.lock b/samples/sample_tap_dummy_json/plugins/loaders/target-jsonl--andyh1203.lock new file mode 100644 index 000000000..11fa0ba2e --- /dev/null +++ b/samples/sample_tap_dummy_json/plugins/loaders/target-jsonl--andyh1203.lock @@ -0,0 +1,34 @@ +{ + "plugin_type": "loaders", + "name": "target-jsonl", + "namespace": "target_jsonl", + "variant": "andyh1203", + "label": "JSON Lines (JSONL)", + "docs": "https://hub.meltano.com/loaders/target-jsonl--andyh1203", + "repo": "https://github.com/andyh1203/target-jsonl", + "pip_url": "target-jsonl", + "description": "JSONL loader", + "logo_url": "https://hub.meltano.com/assets/logos/loaders/jsonl.png", + "settings": [ + { + "name": "destination_path", + "kind": "string", + "value": "output", + "label": "Destination Path", + "description": "Sets the destination path the JSONL files are written to, relative\nto the project root.\n\nThe directory needs to exist already, it will not be created\nautomatically.\n\nTo write JSONL files to the project root, set an empty string (`\"\"`).\n" + }, + { + "name": "do_timestamp_file", + "kind": "boolean", + "value": false, + "label": "Include Timestamp in File Names", + "description": "Specifies if the files should get timestamped.\n\nBy default, the resulting file will not have a timestamp in the file name (i.e. `exchange_rate.jsonl`).\n\nIf this option gets set to `true`, the resulting file will have a timestamp associated with it (i.e. `exchange_rate-{timestamp}.jsonl`).\n" + }, + { + "name": "custom_name", + "kind": "string", + "label": "Custom File Name Override", + "description": "Specifies a custom name for the filename, instead of the stream name.\n\nThe file name will be `{custom_name}-{timestamp}.jsonl`, if `do_timestamp_file` is `true`.\nOtherwise the file name will be `{custom_name}.jsonl`.\n\nIf custom name is not provided, the stream name will be used.\n" + } + ] +} diff --git a/samples/sample_tap_dummy_json/pyproject.toml b/samples/sample_tap_dummy_json/pyproject.toml new file mode 100644 index 000000000..1263b3ca4 --- /dev/null +++ b/samples/sample_tap_dummy_json/pyproject.toml @@ -0,0 +1,44 @@ +[tool.poetry] +name = "tap-dummyjson" +version = "0.0.1" +description = "Singer tap for DummyJSON, built with the Meltano Singer SDK." +readme = "README.md" +authors = ["Edgar Ramírez-Mondragón "] +keywords = [ + "ELT", + "DummyJSON", +] +classifiers = [ + "Intended Audience :: Developers", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", +] +license = "Apache-2.0" + +[tool.poetry.dependencies] +python = ">=3.8" +requests = "~=2.32.3" +singer-sdk = { version="~=0.38.0", extras = [] } + +[tool.poetry.group.dev.dependencies] +pytest = ">=8" +singer-sdk = { version="~=0.38.0", extras = ["testing"] } + +[tool.poetry.extras] +s3 = ["fs-s3fs"] + +[tool.mypy] +python_version = "3.12" +warn_unused_configs = true + +[build-system] +requires = ["poetry-core==1.9.0"] +build-backend = "poetry.core.masonry.api" + +[tool.poetry.scripts] +# CLI declaration +tap-dummyjson = 'tap_dummyjson.tap:TapDummyJSON.cli' diff --git a/samples/sample_tap_dummy_json/ruff.toml b/samples/sample_tap_dummy_json/ruff.toml new file mode 100644 index 000000000..dd2f13459 --- /dev/null +++ b/samples/sample_tap_dummy_json/ruff.toml @@ -0,0 +1,24 @@ +src = ["tap_dummyjson"] +target-version = "py38" + +[lint] +ignore = [ + "ANN", + "ARG", + "D", + "COM812", # missing-trailing-comma + "ISC001", # single-line-implicit-string-concatenation + "S113", # request-without-timeout + "PLR2004", # magic-value-comparison + "RUF012", # mutable-class-default +] +select = ["ALL"] + +[lint.flake8-annotations] +allow-star-arg-any = true + +[lint.isort] +known-first-party = ["tap_dummyjson"] + +[lint.pydocstyle] +convention = "google" diff --git a/samples/sample_tap_dummy_json/tap_dummyjson/__init__.py b/samples/sample_tap_dummy_json/tap_dummyjson/__init__.py new file mode 100644 index 000000000..81bcb2663 --- /dev/null +++ b/samples/sample_tap_dummy_json/tap_dummyjson/__init__.py @@ -0,0 +1 @@ +"""Tap for DummyJSON.""" diff --git a/samples/sample_tap_dummy_json/tap_dummyjson/__main__.py b/samples/sample_tap_dummy_json/tap_dummyjson/__main__.py new file mode 100644 index 000000000..a51459e64 --- /dev/null +++ b/samples/sample_tap_dummy_json/tap_dummyjson/__main__.py @@ -0,0 +1,7 @@ +"""DummyJSON entry point.""" + +from __future__ import annotations + +from tap_dummyjson.tap import TapDummyJSON + +TapDummyJSON.cli() diff --git a/samples/sample_tap_dummy_json/tap_dummyjson/auth.py b/samples/sample_tap_dummy_json/tap_dummyjson/auth.py new file mode 100644 index 000000000..4f21f432f --- /dev/null +++ b/samples/sample_tap_dummy_json/tap_dummyjson/auth.py @@ -0,0 +1,72 @@ +import logging +import time + +import requests +from singer_sdk.authenticators import SingletonMeta + +logger = logging.getLogger(__name__) + +EXPIRES_IN_MINS = 30 + + +class DummyJSONAuthenticator(metaclass=SingletonMeta): + def __init__(self, auth_url, refresh_token_url, username, password): + self.auth_url = auth_url + self.refresh_token_url = refresh_token_url + self.username = username + self.password = password + + self.token = None + self.refresh_token = None + + self.expires = 0 + + def __call__(self, request): + if not self.refresh_token: + logger.info("Retrieving token") + self.auth() + request.headers["Authorization"] = f"Bearer {self.token}" + return request + + if self.needs_refresh(): + logger.info("Refreshing token") + self.refresh() + request.headers["Authorization"] = f"Bearer {self.token}" + return request + + return request + + def needs_refresh(self) -> bool: + return True if self.expires is None else self.expires < time.time() + + def _handle_response(self, response): + if response.status_code != 200: + logger.error("Error: %s", response.text) + response.raise_for_status() + + data = response.json() + self.token = data["token"] + self.refresh_token = data["refreshToken"] + self.expires = time.time() + EXPIRES_IN_MINS * 60 + logger.info("Authenticated") + + def refresh(self): + response = requests.post( + self.refresh_token_url, + json={ + "refreshToken": self.refresh_token, + "expiresInMins": EXPIRES_IN_MINS, + }, + ) + self._handle_response(response) + + def auth(self): + response = requests.post( + self.auth_url, + json={ + "username": self.username, + "password": self.password, + "expiresInMins": EXPIRES_IN_MINS, + }, + ) + self._handle_response(response) diff --git a/samples/sample_tap_dummy_json/tap_dummyjson/client.py b/samples/sample_tap_dummy_json/tap_dummyjson/client.py new file mode 100644 index 000000000..c946675f3 --- /dev/null +++ b/samples/sample_tap_dummy_json/tap_dummyjson/client.py @@ -0,0 +1,45 @@ +"""REST client handling, including DummyJSONStream base class.""" + +from __future__ import annotations + +from singer_sdk.pagination import BaseOffsetPaginator +from singer_sdk.streams import RESTStream + +from .auth import DummyJSONAuthenticator + +PAGE_SIZE = 25 + + +class DummyJSONStream(RESTStream): + """DummyJSON stream class.""" + + records_jsonpath: str = ... + + @property + def url_base(self): + return self.config["api_url"] + + @property + def authenticator(self): + return DummyJSONAuthenticator( + auth_url=f"{self.url_base}/auth/login", + refresh_token_url=f"{self.url_base}/refresh", + username=self.config["username"], + password=self.config["password"], + ) + + @property + def http_headers(self): + return {"User-Agent": "tap-dummyjson"} + + def get_new_paginator(self): + return BaseOffsetPaginator(start_value=0, page_size=PAGE_SIZE) + + def get_url_params(self, context, next_page_token): + return { + "skip": next_page_token, + "limit": PAGE_SIZE, + } + + def post_process(self, row, context=None): + return row diff --git a/samples/sample_tap_dummy_json/tap_dummyjson/schemas/__init__.py b/samples/sample_tap_dummy_json/tap_dummyjson/schemas/__init__.py new file mode 100644 index 000000000..06c0a1988 --- /dev/null +++ b/samples/sample_tap_dummy_json/tap_dummyjson/schemas/__init__.py @@ -0,0 +1 @@ +"""JSON schema files for the REST API.""" diff --git a/samples/sample_tap_dummy_json/tap_dummyjson/streams.py b/samples/sample_tap_dummy_json/tap_dummyjson/streams.py new file mode 100644 index 000000000..b9867bf84 --- /dev/null +++ b/samples/sample_tap_dummy_json/tap_dummyjson/streams.py @@ -0,0 +1,67 @@ +from singer_sdk import typing as th + +from .client import DummyJSONStream + + +class Products(DummyJSONStream): + """Define custom stream.""" + + name = "products" + path = "/products" + + records_jsonpath = "$.products[*]" + + primary_keys = ["id"] + + replication_key = None + + schema = th.PropertiesList( + th.Property("id", th.IntegerType), + th.Property("title", th.StringType), + th.Property("description", th.StringType), + th.Property("category", th.StringType), + th.Property("price", th.NumberType), + th.Property("discountPercentage", th.NumberType), + th.Property("rating", th.NumberType), + th.Property("stock", th.NumberType), + th.Property("tags", th.ArrayType(th.StringType)), + th.Property("brand", th.StringType), + th.Property("sku", th.StringType), + th.Property("weight", th.NumberType), + th.Property( + "dimensions", + th.ObjectType( + th.Property("width", th.NumberType), + th.Property("height", th.NumberType), + th.Property("depth", th.NumberType), + ), + ), + th.Property("warrantyInformation", th.StringType), + th.Property("shippingInformation", th.StringType), + th.Property("availabilityStatus", th.StringType), + th.Property( + "reviews", + th.ArrayType( + th.ObjectType( + th.Property("rating", th.NumberType), + th.Property("comment", th.StringType), + th.Property("date", th.DateTimeType), + th.Property("reviewerName", th.StringType), + th.Property("reviewerEmail", th.StringType), + ) + ), + ), + th.Property("returnPolicy", th.StringType), + th.Property("minimumOrderQuantity", th.NumberType), + th.Property( + "meta", + th.ObjectType( + th.Property("createdAt", th.DateTimeType), + th.Property("updatedAt", th.DateTimeType), + th.Property("barcode", th.StringType), + th.Property("qrCode", th.StringType), + ), + ), + th.Property("images", th.ArrayType(th.StringType)), + th.Property("thumbnail", th.StringType), + ).to_dict() diff --git a/samples/sample_tap_dummy_json/tap_dummyjson/tap.py b/samples/sample_tap_dummy_json/tap_dummyjson/tap.py new file mode 100644 index 000000000..b352d0172 --- /dev/null +++ b/samples/sample_tap_dummy_json/tap_dummyjson/tap.py @@ -0,0 +1,51 @@ +from singer_sdk import Tap +from singer_sdk import typing as th # JSON schema typing helpers + +from . import streams + + +class TapDummyJSON(Tap): + """DummyJSON tap class.""" + + name = "tap-dummyjson" + + config_jsonschema = th.PropertiesList( + th.Property( + "username", + th.StringType, + required=True, + description="Username for the API service", + ), + th.Property( + "password", + th.StringType, + required=True, + secret=True, # Flag config as protected. + description="Password for the API service", + ), + th.Property( + "start_date", + th.DateTimeType, + description="The earliest record date to sync", + ), + th.Property( + "api_url", + th.StringType, + default="https://dummyjson.com", + description="The base url for the API service", + ), + ).to_dict() + + def discover_streams(self): + """Return a list of discovered streams. + + Returns: + A list of discovered streams. + """ + return [ + streams.Products(self), + ] + + +if __name__ == "__main__": + TapDummyJSON.cli() diff --git a/samples/sample_tap_dummy_json/tests/__init__.py b/samples/sample_tap_dummy_json/tests/__init__.py new file mode 100644 index 000000000..1c65c2337 --- /dev/null +++ b/samples/sample_tap_dummy_json/tests/__init__.py @@ -0,0 +1 @@ +"""Test suite for tap-dummyjson.""" diff --git a/samples/sample_tap_dummy_json/tests/test_core.py b/samples/sample_tap_dummy_json/tests/test_core.py new file mode 100644 index 000000000..a9f180afc --- /dev/null +++ b/samples/sample_tap_dummy_json/tests/test_core.py @@ -0,0 +1,11 @@ +from __future__ import annotations + +from samples.sample_tap_dummy_json.tap_dummyjson.tap import TapDummyJSON +from singer_sdk.testing import get_tap_test_class + +CONFIG = { + "username": "emilys", + "password": "emilyspass", +} + +TestTapDummyJSON = get_tap_test_class(tap_class=TapDummyJSON, config=CONFIG) diff --git a/samples/sample_tap_dummy_json/tox.ini b/samples/sample_tap_dummy_json/tox.ini new file mode 100644 index 000000000..6be1c116a --- /dev/null +++ b/samples/sample_tap_dummy_json/tox.ini @@ -0,0 +1,19 @@ +# This file can be used to customize tox tests as well as other test frameworks like flake8 and mypy + +[tox] +envlist = py{38,39,310,311,312} +isolated_build = true + +[testenv] +allowlist_externals = poetry +commands = + poetry install -v + poetry run pytest + +[testenv:pytest] +# Run the python tests. +# To execute, run `tox -e pytest` +envlist = py{38,39,310,311,312} +commands = + poetry install -v + poetry run pytest diff --git a/samples/sample_tap_google_analytics/__init__.py b/samples/sample_tap_google_analytics/__init__.py deleted file mode 100644 index dbe8aec91..000000000 --- a/samples/sample_tap_google_analytics/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -"""Google Analytics sample.""" - -from __future__ import annotations diff --git a/samples/sample_tap_google_analytics/__main__.py b/samples/sample_tap_google_analytics/__main__.py deleted file mode 100644 index e274833e6..000000000 --- a/samples/sample_tap_google_analytics/__main__.py +++ /dev/null @@ -1,5 +0,0 @@ -from __future__ import annotations - -from samples.sample_tap_google_analytics.ga_tap import SampleTapGoogleAnalytics - -SampleTapGoogleAnalytics.cli() diff --git a/samples/sample_tap_google_analytics/ga_tap.py b/samples/sample_tap_google_analytics/ga_tap.py deleted file mode 100644 index 1528452e5..000000000 --- a/samples/sample_tap_google_analytics/ga_tap.py +++ /dev/null @@ -1,38 +0,0 @@ -"""Sample tap test for tap-google-analytics.""" - -from __future__ import annotations - -import json -from pathlib import Path - -from samples.sample_tap_google_analytics.ga_tap_stream import ( - GASimpleSampleStream, - SampleGoogleAnalyticsStream, -) -from singer_sdk.tap_base import Tap -from singer_sdk.typing import PropertiesList, Property, StringType - -REPORT_DEFS_FILE = ( - "samples/sample_tap_google_analytics/resources/default_report_definitions.json" -) -REPORT_DEFS = json.loads(Path(REPORT_DEFS_FILE).read_text(encoding="utf-8")) - - -class SampleTapGoogleAnalytics(Tap): - """Sample tap for GoogleAnalytics.""" - - name: str = "sample-tap-google-analytics" - config_jsonschema = PropertiesList( - Property("view_id", StringType(), required=True), - Property( - "client_email", - StringType(), - required=True, - examples=["me@example.com"], - ), - Property("private_key", StringType(), required=True, secret=True), - ).to_dict() - - def discover_streams(self) -> list[SampleGoogleAnalyticsStream]: - """Return a list of all streams.""" - return [GASimpleSampleStream(tap=self)] diff --git a/samples/sample_tap_google_analytics/ga_tap_stream.py b/samples/sample_tap_google_analytics/ga_tap_stream.py deleted file mode 100644 index 75cdb4c47..000000000 --- a/samples/sample_tap_google_analytics/ga_tap_stream.py +++ /dev/null @@ -1,95 +0,0 @@ -"""Sample tap stream test for tap-google-analytics.""" - -from __future__ import annotations - -import datetime -import sys -import typing as t - -from singer_sdk.authenticators import OAuthJWTAuthenticator -from singer_sdk.streams import RESTStream - -if sys.version_info < (3, 9): - import importlib_resources -else: - from importlib import resources as importlib_resources - - -GOOGLE_OAUTH_ENDPOINT = "https://oauth2.googleapis.com/token" -GA_OAUTH_SCOPES = "https://www.googleapis.com/auth/analytics.readonly" -SCHEMAS_DIR = importlib_resources.files(__package__) / "schemas" - - -class GoogleJWTAuthenticator(OAuthJWTAuthenticator): - """Class responsible for Google Auth via JWT and OAuth.""" - - @property - def client_id(self) -> str: - """Override since Google auth uses email, not numeric client ID.""" - return t.cast(str, self.config["client_email"]) - - -class SampleGoogleAnalyticsStream(RESTStream): - """Sample tap test for google-analytics.""" - - url_base = "https://analyticsreporting.googleapis.com/v4" - path = "/reports:batchGet" - rest_method = "POST" - - # Child class overrides: - dimensions: tuple[str] = () - metrics: tuple[str] = () - - @property - def authenticator(self) -> GoogleJWTAuthenticator: - """Return authenticator for Google Analytics.""" - return GoogleJWTAuthenticator( - stream=self, - auth_endpoint=GOOGLE_OAUTH_ENDPOINT, - oauth_scopes=GA_OAUTH_SCOPES, - ) - - def prepare_request_payload( - self, - context: dict | None, # noqa: ARG002 - next_page_token: t.Any | None, # noqa: ARG002 - ) -> dict | None: - """Prepare the data payload for the REST API request.""" - request_def = { - "viewId": self.config["view_id"], - "metrics": [{"expression": m} for m in self.metrics], - "dimensions": [{"name": d} for d in self.dimensions], - } - if self.config.get("start_date"): - request_def["dateRanges"] = [ - { - "startDate": self.config.get("start_date"), - "endDate": datetime.datetime.now(datetime.timezone.utc), - }, - ] - return {"reportRequests": [request_def]} - - def parse_response(self, response) -> t.Iterable[dict]: - """Parse Google Analytics API response into individual records.""" - self.logger.info( - "Received raw Google Analytics query response: %s", - response.json(), - ) - report_data = response.json().get("reports", [{}])[0].get("data") - if not report_data: - self.logger.info( - "Received empty Google Analytics query response: %s", - response.json(), - ) - for total in report_data["totals"]: - yield {"totals": total["values"]} - - -class GASimpleSampleStream(SampleGoogleAnalyticsStream): - """A super simple sample report.""" - - name = "simple_sample" - schema_filepath = SCHEMAS_DIR / "simple-sample.json" - - dimensions = ("ga:date",) - metrics = ("ga:users", "ga:sessions") diff --git a/samples/sample_tap_google_analytics/resources/default_report_definitions.json b/samples/sample_tap_google_analytics/resources/default_report_definitions.json deleted file mode 100644 index 33978e57f..000000000 --- a/samples/sample_tap_google_analytics/resources/default_report_definitions.json +++ /dev/null @@ -1,95 +0,0 @@ -{ - "type": "object", - "properties": { - "id": { - "type": "string" - }, - "project_id": { - "type": "integer" - }, - "short_id": { - "type": "string" - }, - "title": { - "type": [ - "null", - "string" - ] - }, - "author_name": { - "type": [ - "null", - "string" - ] - }, - "author_email": { - "type": [ - "null", - "string" - ] - }, - "authored_date": { - "type": "string", - "format": "date-time" - }, - "committer_name": { - "type": [ - "null", - "string" - ] - }, - "committer_email": { - "type": [ - "null", - "string" - ] - }, - "committed_date": { - "type": "string", - "format": "date-time" - }, - "created_at": { - "type": "string", - "format": "date-time" - }, - "message": { - "type": [ - "null", - "string" - ] - }, - "allow_failure": { - "type": [ - "null", - "boolean" - ] - }, - "parent_ids": { - "anyOf": [ - { - "type": "array", - "items": { - "type": "string" - } - }, - { - "type": "null" - } - ] - }, - "stats": { - "type": "object", - "properties": { - "additions": { - "type": "integer" - }, - "deletions": { - "type": "integer" - }, - "total": { - "type": "integer" - } - } - } - } -} \ No newline at end of file diff --git a/samples/sample_tap_google_analytics/schemas/simple-sample.json b/samples/sample_tap_google_analytics/schemas/simple-sample.json deleted file mode 100644 index 0a5f97f4d..000000000 --- a/samples/sample_tap_google_analytics/schemas/simple-sample.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "type": "object", - "properties": { - "totals": { - "type": "array", - "items": { - "type": "string" - } - } - } -} diff --git a/tests/external/test_tap_dummyjson.py b/tests/external/test_tap_dummyjson.py new file mode 100644 index 000000000..a9f180afc --- /dev/null +++ b/tests/external/test_tap_dummyjson.py @@ -0,0 +1,11 @@ +from __future__ import annotations + +from samples.sample_tap_dummy_json.tap_dummyjson.tap import TapDummyJSON +from singer_sdk.testing import get_tap_test_class + +CONFIG = { + "username": "emilys", + "password": "emilyspass", +} + +TestTapDummyJSON = get_tap_test_class(tap_class=TapDummyJSON, config=CONFIG) diff --git a/tests/external/test_tap_google_analytics.py b/tests/external/test_tap_google_analytics.py deleted file mode 100644 index 1bed825fd..000000000 --- a/tests/external/test_tap_google_analytics.py +++ /dev/null @@ -1,26 +0,0 @@ -"""Tests standard tap features using the built-in SDK tests library.""" - -from __future__ import annotations - -import warnings - -from samples.sample_tap_google_analytics.ga_tap import SampleTapGoogleAnalytics -from singer_sdk.exceptions import ConfigValidationError -from singer_sdk.testing import get_tap_test_class - -from .conftest import ga_config - -try: - TestSampleTapGoogleAnalytics = get_tap_test_class( - tap_class=SampleTapGoogleAnalytics, - config=ga_config(), - parse_env_config=True, - ) -except ConfigValidationError as e: - warnings.warn( - UserWarning( - "Could not configure external gitlab tests. " - f"Config in CI is expected via env vars.\n{e}", - ), - stacklevel=2, - )