Skip to content

Commit 22efeae

Browse files
topefolorunsooctavia-squidington-iiinatikgadzhi
authored
Source Zendesk Talk : Restore Unit Test (#50956)
Co-authored-by: Octavia Squidington III <[email protected]> Co-authored-by: Natik Gadzhi <[email protected]>
1 parent 3318e14 commit 22efeae

File tree

7 files changed

+2280
-6
lines changed

7 files changed

+2280
-6
lines changed

airbyte-integrations/connectors/source-zendesk-talk/integration_tests/abnormal_state.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"type": "STREAM",
44
"stream": {
55
"stream_state": {
6-
"updated_at": "2121-01-01T00:00:00Z"
6+
"updated_at": "4765132800"
77
},
88
"stream_descriptor": { "name": "calls" }
99
}
@@ -12,7 +12,7 @@
1212
"type": "STREAM",
1313
"stream": {
1414
"stream_state": {
15-
"updated_at": "2121-01-01T00:00:00Z"
15+
"updated_at": "4765132800"
1616
},
1717
"stream_descriptor": { "name": "call_legs" }
1818
}

airbyte-integrations/connectors/source-zendesk-talk/metadata.yaml

+2-4
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ data:
77
- ${subdomain}.zendesk.com
88
- zendesk.com
99
connectorBuildOptions:
10-
baseImage: docker.io/airbyte/source-declarative-manifest:5.15.0@sha256:09a84e0622f36393077332faf11cc239e77083fae5fa500592c049dca25888a7
10+
baseImage: docker.io/airbyte/source-declarative-manifest:6.36.2@sha256:fda118585769dba6abccd6dc72c05a993ecd53790cbbe8cf6253b79ce7079db2
1111
connectorSubtype: api
1212
connectorType: source
1313
definitionId: c8630570-086d-4a40-99ae-ea5b18673071
14-
dockerImageTag: 1.1.0-rc.1
14+
dockerImageTag: 1.2.0
1515
dockerRepository: airbyte/source-zendesk-talk
1616
documentationUrl: https://docs.airbyte.com/integrations/sources/zendesk-talk
1717
githubIssueLabel: source-zendesk-talk
@@ -41,8 +41,6 @@ data:
4141
stream schema, this migration constitutes a breaking change. After updating,
4242
please reset your source before resuming syncs. For more information, see
4343
our migration documentation for source Zendesk Talk.
44-
rolloutConfiguration:
45-
enableProgressiveRollout: true
4644
tags:
4745
- language:manifest-only
4846
- cdk:low-code
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Copyright (c) 2024 Airbyte, Inc., all rights reserved.
2+
3+
pytest_plugins = ["airbyte_cdk.test.utils.manifest_only_fixtures"]

airbyte-integrations/connectors/source-zendesk-talk/unit_tests/poetry.lock

+2,143
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[build-system]
2+
requires = [ "poetry-core>=1.0.0",]
3+
build-backend = "poetry.core.masonry.api"
4+
5+
[tool.poetry]
6+
name = "source-zendesk-talk-tests"
7+
version = "1.2.0"
8+
description = "Unit tests for source-zendesk-talk"
9+
authors = ["Airbyte <[email protected]>"]
10+
11+
[tool.poetry.dependencies]
12+
python = "^3.10,<3.13"
13+
airbyte-cdk = "*"
14+
pytest = "^8"
15+
requests-mock = "*"
16+
17+
[tool.pytest.ini_options]
18+
filterwarnings = [
19+
"ignore:This class is experimental*"
20+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
2+
3+
from unittest.mock import MagicMock, patch
4+
5+
import pytest
6+
import requests
7+
8+
from airbyte_cdk.sources.declarative.auth.token import BasicHttpAuthenticator, BearerAuthenticator
9+
10+
11+
@pytest.mark.parametrize(
12+
"response_data, expected_records",
13+
[
14+
# Test cases for IVRMenusRecordExtractor
15+
(
16+
{
17+
"ivrs": [
18+
{"id": "ivr_1", "menus": [{"id": "menu_1a", "name": "Menu 1A"}, {"id": "menu_1b", "name": "Menu 1B"}]},
19+
{"id": "ivr_2", "menus": [{"id": "menu_2a", "name": "Menu 2A"}]},
20+
]
21+
},
22+
[
23+
{"ivr_id": "ivr_1", "id": "menu_1a", "name": "Menu 1A"},
24+
{"ivr_id": "ivr_1", "id": "menu_1b", "name": "Menu 1B"},
25+
{"ivr_id": "ivr_2", "id": "menu_2a", "name": "Menu 2A"},
26+
],
27+
),
28+
({"ivrs": []}, []),
29+
({"ivrs": [{"id": "ivr_1", "menus": []}]}, []),
30+
],
31+
)
32+
def test_ivr_menus_record_extractor(components_module, response_data, expected_records):
33+
IVRMenusRecordExtractor = components_module.IVRMenusRecordExtractor
34+
with patch("requests.get") as mock_get:
35+
mock_response = MagicMock()
36+
mock_response.json.return_value = response_data
37+
mock_get.return_value = mock_response
38+
response = requests.get("https://not-the-real.api/ivrs")
39+
40+
extractor = IVRMenusRecordExtractor()
41+
records = extractor.extract_records(response)
42+
43+
assert records == expected_records
44+
45+
46+
@pytest.mark.parametrize(
47+
"response_data, expected_records",
48+
[
49+
# Test cases for IVRRoutesRecordExtractor
50+
(
51+
{
52+
"ivrs": [
53+
{
54+
"id": "ivr_1",
55+
"menus": [
56+
{
57+
"id": "menu_1a",
58+
"routes": [{"id": "route_1a1", "name": "Route 1A1"}, {"id": "route_1a2", "name": "Route 1A2"}],
59+
}
60+
],
61+
}
62+
]
63+
},
64+
[
65+
{"ivr_id": "ivr_1", "ivr_menu_id": "menu_1a", "id": "route_1a1", "name": "Route 1A1"},
66+
{"ivr_id": "ivr_1", "ivr_menu_id": "menu_1a", "id": "route_1a2", "name": "Route 1A2"},
67+
],
68+
),
69+
({"ivrs": [{"id": "ivr_1", "menus": [{"id": "menu_1a", "routes": []}]}]}, []),
70+
],
71+
)
72+
def test_ivr_routes_record_extractor(components_module, response_data, expected_records):
73+
IVRRoutesRecordExtractor = components_module.IVRRoutesRecordExtractor
74+
with patch("requests.get") as mock_get:
75+
mock_response = MagicMock()
76+
mock_response.json.return_value = response_data
77+
mock_get.return_value = mock_response
78+
response = requests.get("https://not-the-real.api/ivrs")
79+
80+
extractor = IVRRoutesRecordExtractor()
81+
records = extractor.extract_records(response)
82+
83+
assert records == expected_records
84+
85+
86+
@pytest.mark.parametrize(
87+
"config, authenticator_type",
88+
[
89+
({"access_token": "dummy_token", "email": "[email protected]"}, BasicHttpAuthenticator),
90+
({"credentials": {"auth_type": "api_token"}}, BasicHttpAuthenticator),
91+
({"credentials": {"auth_type": "oauth2.0"}}, BearerAuthenticator),
92+
],
93+
)
94+
def test_zendesk_talk_authenticator(components_module, config, authenticator_type):
95+
ZendeskTalkAuthenticator = components_module.ZendeskTalkAuthenticator
96+
legacy_basic_auth = MagicMock(spec=BasicHttpAuthenticator)
97+
basic_auth = MagicMock(spec=BasicHttpAuthenticator)
98+
oauth = MagicMock(spec=BearerAuthenticator)
99+
100+
authenticator = ZendeskTalkAuthenticator(legacy_basic_auth, basic_auth, oauth, config)
101+
assert isinstance(authenticator, authenticator_type)
102+
103+
104+
def test_zendesk_talk_authenticator_invalid(components_module):
105+
ZendeskTalkAuthenticator = components_module.ZendeskTalkAuthenticator
106+
with pytest.raises(Exception) as excinfo:
107+
config = {"credentials": {"auth_type": "invalid"}}
108+
ZendeskTalkAuthenticator(None, None, None, config)
109+
assert "Missing valid authenticator" in str(excinfo.value)

docs/integrations/sources/zendesk-talk.md

+1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ The Zendesk connector should not run into Zendesk API limitations under normal u
7979

8080
| Version | Date | Pull Request | Subject |
8181
|:--------|:-----------|:---------------------------------------------------------|:----------------------------------------------------------------------------|
82+
| 1.2.0 | 2025-02-07 | [50956](https://github.com/airbytehq/airbyte/pull/50956) | Restore Unit Test |
8283
| 1.1.0-rc.1 | 2024-10-31 | [47313](https://github.com/airbytehq/airbyte/pull/47313) | Migrate to Manifest-only |
8384
| 1.0.21 | 2024-10-29 | [47082](https://github.com/airbytehq/airbyte/pull/47082) | Update dependencies |
8485
| 1.0.20 | 2024-10-12 | [46861](https://github.com/airbytehq/airbyte/pull/46861) | Update dependencies |

0 commit comments

Comments
 (0)