Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alafanechere committed Jan 21, 2022
1 parent 492d773 commit 79d4dec
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions airbyte-integrations/connectors/source-persistiq/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
]

TEST_REQUIREMENTS = [
"pytest~=6.1",
"pytest-mock~=3.6.1",
"pytest==6.1.2",
"requests_mock==1.8.0",
"source-acceptance-test",
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
# Copyright (c) 2021 Airbyte, Inc., all rights reserved.
#

from unittest.mock import ANY, MagicMock

import requests
from source_persistiq.source import SourcePersistiq


def test_check_connection(mocker, requests_mock):
source = SourcePersistiq()
logger_mock = MagicMock(), MagicMock()
config_mock = {"api_key": "mybeautifulkey"}
mock_logger = mocker.Mock()
test_config = {"api_key": "mybeautifulkey"}
# success
requests_mock.get(
"https://api.persistiq.com/v1/users",
Expand All @@ -23,16 +22,17 @@ def test_check_connection(mocker, requests_mock):
"salesforce_id": "",
},
)
assert source.check_connection(logger_mock, config_mock) == (True, None)
assert source.check_connection(mock_logger, test_config) == (True, None)

# failure
requests_mock.get("https://api.persistiq.com/v1/users", status_code=500)
assert source.check_connection(logger_mock, config_mock) == (False, ANY)
connection_success, connection_failure = source.check_connection(mock_logger, test_config)
assert not connection_success
assert isinstance(connection_failure, requests.exceptions.HTTPError)


def test_streams(mocker):
def test_streams():
source = SourcePersistiq()
config_mock = MagicMock()
streams = source.streams(config_mock)
expected_streams_number = 3
assert len(streams) == expected_streams_number
config = {"api_key": "my-api-key"}
streams = source.streams(config)
assert len(streams) == 3

0 comments on commit 79d4dec

Please sign in to comment.