-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🎉 Source Mixpanel: Increase unit test coverage (#11633)
- Loading branch information
Showing
11 changed files
with
378 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
airbyte-integrations/connectors/source-mixpanel/unit_tests/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# | ||
# Copyright (c) 2021 Airbyte, Inc., all rights reserved. | ||
# |
18 changes: 18 additions & 0 deletions
18
airbyte-integrations/connectors/source-mixpanel/unit_tests/conftest.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# | ||
# Copyright (c) 2021 Airbyte, Inc., all rights reserved. | ||
# | ||
import pendulum | ||
import pytest | ||
|
||
|
||
@pytest.fixture | ||
def config(): | ||
return { | ||
"api_secret": "unexisting-secret", | ||
"attribution_window": 5, | ||
"project_timezone": "UTC", | ||
"select_properties_by_default": True, | ||
"start_date": pendulum.parse("2017-01-25T00:00:00Z").date(), | ||
"end_date": pendulum.parse("2017-02-25T00:00:00Z").date(), | ||
"region": "US", | ||
} |
41 changes: 41 additions & 0 deletions
41
airbyte-integrations/connectors/source-mixpanel/unit_tests/test_source.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# | ||
# Copyright (c) 2021 Airbyte, Inc., all rights reserved. | ||
# | ||
import pytest | ||
from airbyte_cdk import AirbyteLogger | ||
from source_mixpanel.source import FunnelsList, SourceMixpanel, TokenAuthenticatorBase64 | ||
|
||
from .utils import get_url_to_mock, setup_response | ||
|
||
logger = AirbyteLogger() | ||
|
||
|
||
@pytest.fixture | ||
def check_connection_url(config): | ||
auth = TokenAuthenticatorBase64(token=config["api_secret"]) | ||
funnel_list = FunnelsList(authenticator=auth, **config) | ||
return get_url_to_mock(funnel_list) | ||
|
||
|
||
@pytest.mark.parametrize("response_code,expect_success", [(200, True), (400, False)]) | ||
def test_check_connection(requests_mock, check_connection_url, config, response_code, expect_success): | ||
requests_mock.register_uri("GET", check_connection_url, setup_response(response_code, {})) | ||
ok, error = SourceMixpanel().check_connection(logger, config) | ||
assert ok == expect_success and error != expect_success | ||
|
||
|
||
def test_check_connection_bad_config(): | ||
config = {} | ||
ok, error = SourceMixpanel().check_connection(logger, config) | ||
assert not ok and error | ||
|
||
|
||
def test_check_connection_incomplete(config): | ||
config.pop("api_secret") | ||
ok, error = SourceMixpanel().check_connection(logger, config) | ||
assert not ok and error | ||
|
||
|
||
def test_streams(config): | ||
streams = SourceMixpanel().streams(config) | ||
assert len(streams) == 7 |
Oops, something went wrong.