forked from MeltanoLabs/tap-github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_core.py
More file actions
71 lines (57 loc) · 2.19 KB
/
test_core.py
File metadata and controls
71 lines (57 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
"""Tests standard tap features using the built-in SDK tests library."""
import logging
import os
from unittest import mock
from unittest.mock import patch
from singer_sdk.testing import get_standard_tap_tests
from tap_github.tap import TapGitHub
from tap_github.utils.filter_stdout import nostdout
from .fixtures import ( # noqa: F401
alternative_sync_chidren,
organization_list_config,
repo_list_config,
search_config,
username_list_config,
)
# Run standard built-in tap tests from the SDK:
def test_standard_tap_tests_for_search_mode(search_config): # noqa: F811
"""Run standard tap tests from the SDK."""
tests = get_standard_tap_tests(TapGitHub, config=search_config)
with (
patch(
"singer_sdk.streams.core.Stream._sync_children", alternative_sync_chidren
),
nostdout(),
):
for test in tests:
test()
def test_standard_tap_tests_for_repo_list_mode(repo_list_config): # noqa: F811
"""Run standard tap tests from the SDK."""
tests = get_standard_tap_tests(TapGitHub, config=repo_list_config)
with (
patch(
"singer_sdk.streams.core.Stream._sync_children", alternative_sync_chidren
),
nostdout(),
):
for test in tests:
test()
def test_standard_tap_tests_for_username_list_mode(username_list_config): # noqa: F811
"""Run standard tap tests from the SDK."""
tests = get_standard_tap_tests(TapGitHub, config=username_list_config)
with nostdout():
for test in tests:
test()
# This token needs to have read:org access for the organization listed in fixtures.py
# Default is "MeltanoLabs"
ORG_LEVEL_TOKEN = os.environ.get("ORG_LEVEL_TOKEN")
@mock.patch.dict(os.environ, {"GITHUB_TOKEN": ORG_LEVEL_TOKEN or ""})
def test_standard_tap_tests_for_organization_list_mode(organization_list_config): # noqa: F811
"""Run standard tap tests from the SDK."""
if not ORG_LEVEL_TOKEN:
logging.warning('No "ORG_LEVEL_TOKEN" found. Skipping organization tap tests.')
return
tests = get_standard_tap_tests(TapGitHub, config=organization_list_config)
with nostdout():
for test in tests:
test()