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

feat: use new standard tests #93

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Secrets and internal config files
**/.secrets/*
.vscode

# API cache
api_caches
Expand Down
1,514 changes: 759 additions & 755 deletions poetry.lock

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ license = "Apache 2.0"
[tool.poetry.dependencies]
python = "<3.12,>=3.7.1"
requests = "^2.25.1"
singer-sdk = "^0.14.0"
singer-sdk = {git = "https://github.com/meltano/sdk.git", rev = "kgpayne/issue1169", extras=["testing"]}
requests-cache = "^0.9.3"
PyYAML = "^6.0"

[tool.poetry.dev-dependencies]
pytest = "^6.2.5"
tox = "^3.24.4"
flake8 = "^5.0.4"
black = "^22.10.0"
Expand Down
File renamed without changes.
3 changes: 3 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""Test Configuration."""

pytest_plugins = ("singer_sdk.testing.pytest_plugin",)
48 changes: 22 additions & 26 deletions tap_gitlab/tests/test_core.py → tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing import Any, Dict

from dotenv import load_dotenv
from singer_sdk.testing import get_standard_tap_tests
from singer_sdk.testing import get_tap_test_class

from tap_gitlab.streams import ProjectsStream
from tap_gitlab.tap import OPTIN_STREAM_NAMES, TapGitLab
Expand Down Expand Up @@ -36,34 +36,30 @@


# Run standard built-in tap tests from the SDK:
def test_standard_tap_tests():
"""Run standard tap tests from the SDK."""
tests = get_standard_tap_tests(TapGitLab, config=SAMPLE_CONFIG)
for test in tests:
test()
TestTapStackExchange = get_tap_test_class(tap_class=TapGitLab, config=SAMPLE_CONFIG)


# https://gitlab.com/meltano/sdk/-/merge_requests/265
def test_tap_config_defaults():
"""Run standard tap tests from the SDK."""
tap = TapGitLab(config=SAMPLE_CONFIG, parse_env_config=True)
for optin_stream in OPTIN_STREAM_NAMES:
assert f"fetch_{optin_stream}" in tap.config
# # https://gitlab.com/meltano/sdk/-/merge_requests/265
# def test_tap_config_defaults():
# """Run standard tap tests from the SDK."""
# tap = TapGitLab(config=SAMPLE_CONFIG, parse_env_config=True)
# for optin_stream in OPTIN_STREAM_NAMES:
# assert f"fetch_{optin_stream}" in tap.config


def test_get_repo_ids():
"""Check that the "presync" graphql call returns clean repo names/ids."""
tap = TapGitLab(config=SAMPLE_CONFIG, parse_env_config=True)
stream = ProjectsStream(tap=tap)
# def test_get_repo_ids():
# """Check that the "presync" graphql call returns clean repo names/ids."""
# tap = TapGitLab(config=SAMPLE_CONFIG, parse_env_config=True)
# stream = ProjectsStream(tap=tap)

list_of_buggy_repos = [
"meLTano/sDk", # incorrect case
"DoesNot/Exist", # does not exist ;)
"gitlab-org/graphql-sandbox", # correct value
]
clean_list = stream.get_repo_ids(list_of_buggy_repos)
# list_of_buggy_repos = [
# "meLTano/sDk", # incorrect case
# "DoesNot/Exist", # does not exist ;)
# "gitlab-org/graphql-sandbox", # correct value
# ]
# clean_list = stream.get_repo_ids(list_of_buggy_repos)

assert clean_list == [
{"project_id": "22672923", "project_path": "meltano/sdk"},
{"project_id": "15297693", "project_path": "gitlab-org/graphql-sandbox"},
]
# assert clean_list == [
# {"project_id": "22672923", "project_path": "meltano/sdk"},
# {"project_id": "15297693", "project_path": "gitlab-org/graphql-sandbox"},
# ]