From a09c24030f4de9b5219c797ecab84ab8cb1b5d17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgar=20Ram=C3=ADrez-Mondrag=C3=B3n?= Date: Thu, 4 Jul 2024 17:57:48 -0600 Subject: [PATCH] Fix fixtures --- tap_github/tests/conftest.py | 40 +++++++++++++++++++++++++++++++++++ tap_github/tests/fixtures.py | 35 ------------------------------ tap_github/tests/test_core.py | 4 +--- 3 files changed, 41 insertions(+), 38 deletions(-) create mode 100644 tap_github/tests/conftest.py diff --git a/tap_github/tests/conftest.py b/tap_github/tests/conftest.py new file mode 100644 index 00000000..c2b58ec1 --- /dev/null +++ b/tap_github/tests/conftest.py @@ -0,0 +1,40 @@ +from __future__ import annotations + +import datetime + +import pytest + + +@pytest.fixture() +def repo_list_config(request): + """Get a default list of repos or pass your own by decorating your test with + @pytest.mark.repo_list(['org1/repo1', 'org2/repo2']) + """ + marker = request.node.get_closest_marker("repo_list") + if marker is None: + repo_list = ["MeltanoLabs/tap-github", "mapswipe/mapswipe"] + else: + repo_list = marker.args[0] + + return { + "metrics_log_level": "warning", + "start_date": datetime.datetime.now(datetime.timezone.utc).strftime("%Y-%m-%d"), + "repositories": repo_list, + "rate_limit_buffer": 100, + } + + +@pytest.fixture() +def username_list_config(request): + """Get a default list of usernames or pass your own by decorating your test with + @pytest.mark.username_list(['ericboucher', 'aaronsteers']) + """ + marker = request.node.get_closest_marker("username_list") + username_list = ["ericboucher", "aaronsteers"] if marker is None else marker.args[0] + + return { + "metrics_log_level": "warning", + "start_date": datetime.datetime.now(datetime.timezone.utc).strftime("%Y-%m-%d"), + "user_usernames": username_list, + "rate_limit_buffer": 100, + } diff --git a/tap_github/tests/fixtures.py b/tap_github/tests/fixtures.py index ec6cd1c1..5d60c94f 100644 --- a/tap_github/tests/fixtures.py +++ b/tap_github/tests/fixtures.py @@ -25,41 +25,6 @@ def search_config(): } -@pytest.fixture() -def repo_list_config(request): - """Get a default list of repos or pass your own by decorating your test with - @pytest.mark.repo_list(['org1/repo1', 'org2/repo2']) - """ - marker = request.node.get_closest_marker("repo_list") - if marker is None: - repo_list = ["MeltanoLabs/tap-github", "mapswipe/mapswipe"] - else: - repo_list = marker.args[0] - - return { - "metrics_log_level": "warning", - "start_date": datetime.datetime.now(datetime.timezone.utc).strftime("%Y-%m-%d"), - "repositories": repo_list, - "rate_limit_buffer": 100, - } - - -@pytest.fixture() -def username_list_config(request): - """Get a default list of usernames or pass your own by decorating your test with - @pytest.mark.username_list(['ericboucher', 'aaronsteers']) - """ - marker = request.node.get_closest_marker("username_list") - username_list = ["ericboucher", "aaronsteers"] if marker is None else marker.args[0] - - return { - "metrics_log_level": "warning", - "start_date": datetime.datetime.now(datetime.timezone.utc).strftime("%Y-%m-%d"), - "user_usernames": username_list, - "rate_limit_buffer": 100, - } - - @pytest.fixture() def user_id_list_config(request): """Get a default list of usernames or pass your own by decorating your test with diff --git a/tap_github/tests/test_core.py b/tap_github/tests/test_core.py index 7697a724..00d1be6d 100644 --- a/tap_github/tests/test_core.py +++ b/tap_github/tests/test_core.py @@ -10,9 +10,7 @@ from tap_github.tap import TapGitHub from tap_github.utils.filter_stdout import nostdout -from .fixtures import ( - alternative_sync_children, -) +from .fixtures import alternative_sync_children # Run standard built-in tap tests from the SDK: