-
Notifications
You must be signed in to change notification settings - Fork 4.5k
/
Copy pathtest_source.py
33 lines (25 loc) · 1.13 KB
/
test_source.py
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
#
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
#
from unittest.mock import MagicMock
import logging
from source_sentry.source import SourceSentry
def test_source_wrong_credentials(requests_mock):
source = SourceSentry()
status, error = source.check_connection(logger=logging.getLogger("airbyte"), config={"auth_token": "test_auth_token"})
assert not status
def test_check_connection(requests_mock):
source = SourceSentry()
logger_mock = MagicMock()
requests_mock.get(url="https://sentry.io/api/0/projects/test-org/test-project/", json={"id": "id", "name": "test-project"})
config = {"auth_token": "token", "organization": "test-org", "project": "test-project", "hostname": "sentry.io"}
assert source.check_connection(logger_mock, config) == (True, None)
def test_streams(mocker):
source = SourceSentry()
config_mock = MagicMock()
config_mock["auth_token"] = "test-token"
config_mock["organization"] = "test-organization"
config_mock["project"] = "test-project"
streams = source.streams(config_mock)
expected_streams_number = 5
assert len(streams) == expected_streams_number