Skip to content

Commit

Permalink
Source zendesk support: validate datetime on check (#24252)
Browse files Browse the repository at this point in the history
* #1683 source zendesk support: validate datetime on check

* #1683 source zendesk support: upd changelog

* Automated Change

* rm extra files

* auto-bump connector version

---------

Co-authored-by: davydov-d <davydov-d@users.noreply.github.com>
Co-authored-by: Octavia Squidington III <octavia-squidington-iii@users.noreply.github.com>
  • Loading branch information
3 people authored and erohmensing committed Mar 22, 2023
1 parent 42cce35 commit 1ce5403
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2317,7 +2317,7 @@
- name: Zendesk Support
sourceDefinitionId: 79c1aa37-dae3-42ae-b333-d1c105477715
dockerRepository: airbyte/source-zendesk-support
dockerImageTag: 0.2.25
dockerImageTag: 0.2.26
documentationUrl: https://docs.airbyte.com/integrations/sources/zendesk-support
icon: zendesk-support.svg
sourceType: api
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17095,7 +17095,7 @@
path_in_connector_config:
- "credentials"
- "client_secret"
- dockerImage: "airbyte/source-zendesk-support:0.2.25"
- dockerImage: "airbyte/source-zendesk-support:0.2.26"
spec:
documentationUrl: "https://docs.airbyte.com/integrations/sources/zendesk-support"
connectionSpecification:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ COPY source_zendesk_support ./source_zendesk_support
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]

LABEL io.airbyte.version=0.2.25
LABEL io.airbyte.version=0.2.26
LABEL io.airbyte.name=airbyte/source-zendesk-support
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

import base64
import logging
from datetime import datetime
from typing import Any, List, Mapping, Tuple

import requests
from airbyte_cdk.models import SyncMode
from airbyte_cdk.sources import AbstractSource
from airbyte_cdk.sources.streams import Stream
from airbyte_cdk.sources.streams.http.requests_native_auth import TokenAuthenticator
from source_zendesk_support.streams import SourceZendeskException
from source_zendesk_support.streams import DATETIME_FORMAT, SourceZendeskException

from .streams import (
Brands,
Expand Down Expand Up @@ -82,8 +82,9 @@ def check_connection(self, logger, config) -> Tuple[bool, any]:
auth = self.get_authenticator(config)
settings = None
try:
datetime.strptime(config["start_date"], DATETIME_FORMAT)
settings = UserSettingsStream(config["subdomain"], authenticator=auth, start_date=None).get_settings()
except requests.exceptions.RequestException as e:
except Exception as e:
return False, e

active_features = [k for k, v in settings.get("active_features", {}).items() if v]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@


import calendar
import copy
import re
from datetime import datetime
from unittest.mock import patch
Expand Down Expand Up @@ -117,17 +118,21 @@ def test_get_authenticator(config, expected):


@pytest.mark.parametrize(
"response, check_passed",
"response, start_date, check_passed",
[
({"active_features": {"organization_access_enabled": True}}, (True, None)),
({"active_features": {"organization_access_enabled": True}}, "2020-01-01T00:00:00Z", True),
({}, "2020-01-00T00:00:00Z", False)
],
ids=["check_connection"],
ids=["check_successful", "invalid_start_date"],
)
def test_check(response, check_passed):
def test_check(response, start_date, check_passed):
config = copy.deepcopy(TEST_CONFIG)
config["start_date"] = start_date
with patch.object(UserSettingsStream, "get_settings", return_value=response) as mock_method:
result = SourceZendeskSupport().check_connection(logger=AirbyteLogger, config=TEST_CONFIG)
mock_method.assert_called()
assert check_passed == result
ok, _ = SourceZendeskSupport().check_connection(logger=AirbyteLogger, config=config)
assert check_passed == ok
if ok:
mock_method.assert_called()


@pytest.mark.parametrize(
Expand Down
2 changes: 1 addition & 1 deletion connectors.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@
| **Zendesk Chat** | <img alt="Zendesk Chat icon" src="https://raw.githubusercontent.com/airbytehq/airbyte/master/airbyte-config/init/src/main/resources/icons/zendesk-chat.svg" height="30" height="30"/> | Source | airbyte/source-zendesk-chat:0.1.13 | generally_available | [link](https://docs.airbyte.com/integrations/sources/zendesk-chat) | [code](https://github.com/airbytehq/airbyte/tree/master/airbyte-integrations/connectors/source-zendesk-chat) | <small>`40d24d0f-b8f9-4fe0-9e6c-b06c0f3f45e4`</small> |
| **Zendesk Sell** | <img alt="Zendesk Sell icon" src="https://raw.githubusercontent.com/airbytehq/airbyte/master/airbyte-config/init/src/main/resources/icons/zendesk.svg" height="30" height="30"/> | Source | airbyte/source-zendesk-sell:0.1.0 | alpha | [link](https://docs.airbyte.com/integrations/sources/zendesk-sell) | [code](https://github.com/airbytehq/airbyte/tree/master/airbyte-integrations/connectors/source-zendesk-sell) | <small>`982eaa4c-bba1-4cce-a971-06a41f700b8c`</small> |
| **Zendesk Sunshine** | <img alt="Zendesk Sunshine icon" src="https://raw.githubusercontent.com/airbytehq/airbyte/master/airbyte-config/init/src/main/resources/icons/zendesk-sunshine.svg" height="30" height="30"/> | Source | airbyte/source-zendesk-sunshine:0.1.1 | alpha | [link](https://docs.airbyte.com/integrations/sources/zendesk-sunshine) | [code](https://github.com/airbytehq/airbyte/tree/master/airbyte-integrations/connectors/source-zendesk-sunshine) | <small>`325e0640-e7b3-4e24-b823-3361008f603f`</small> |
| **Zendesk Support** | <img alt="Zendesk Support icon" src="https://raw.githubusercontent.com/airbytehq/airbyte/master/airbyte-config/init/src/main/resources/icons/zendesk-support.svg" height="30" height="30"/> | Source | airbyte/source-zendesk-support:0.2.25 | generally_available | [link](https://docs.airbyte.com/integrations/sources/zendesk-support) | [code](https://github.com/airbytehq/airbyte/tree/master/airbyte-integrations/connectors/source-zendesk-support) | <small>`79c1aa37-dae3-42ae-b333-d1c105477715`</small> |
| **Zendesk Support** | <img alt="Zendesk Support icon" src="https://raw.githubusercontent.com/airbytehq/airbyte/master/airbyte-config/init/src/main/resources/icons/zendesk-support.svg" height="30" height="30"/> | Source | airbyte/source-zendesk-support:0.2.26 | generally_available | [link](https://docs.airbyte.com/integrations/sources/zendesk-support) | [code](https://github.com/airbytehq/airbyte/tree/master/airbyte-integrations/connectors/source-zendesk-support) | <small>`79c1aa37-dae3-42ae-b333-d1c105477715`</small> |
| **Zendesk Talk** | <img alt="Zendesk Talk icon" src="https://raw.githubusercontent.com/airbytehq/airbyte/master/airbyte-config/init/src/main/resources/icons/zendesk-talk.svg" height="30" height="30"/> | Source | airbyte/source-zendesk-talk:0.1.6 | generally_available | [link](https://docs.airbyte.com/integrations/sources/zendesk-talk) | [code](https://github.com/airbytehq/airbyte/tree/master/airbyte-integrations/connectors/source-zendesk-talk) | <small>`c8630570-086d-4a40-99ae-ea5b18673071`</small> |
| **Zenefits** | <img alt="Zenefits icon" src="https://raw.githubusercontent.com/airbytehq/airbyte/master/airbyte-config/init/src/main/resources/icons/zenefits.svg" height="30" height="30"/> | Source | airbyte/source-zenefits:0.1.0 | alpha | [link](https://docs.airbyte.com/integrations/sources/zenefits) | [code](https://github.com/airbytehq/airbyte/tree/master/airbyte-integrations/connectors/source-zenefits) | <small>`8baba53d-2fe3-4e33-bc85-210d0eb62884`</small> |
| **Zenloop** | <img alt="Zenloop icon" src="https://raw.githubusercontent.com/airbytehq/airbyte/master/airbyte-config/init/src/main/resources/icons/zenloop.svg" height="30" height="30"/> | Source | airbyte/source-zenloop:0.1.6 | beta | [link](https://docs.airbyte.com/integrations/sources/zenloop) | [code](https://github.com/airbytehq/airbyte/tree/master/airbyte-integrations/connectors/source-zenloop) | <small>`f1e4c7f6-db5c-4035-981f-d35ab4998794`</small> |
Expand Down
5 changes: 3 additions & 2 deletions docs/integrations/sources/zendesk-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ The Zendesk connector ideally should not run into Zendesk API limitations under

| Version | Date | Pull Request | Subject |
|:---------|:-----------|:---------------------------------------------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `0.2.25` | 2023-02-28 | [22308](https://github.com/airbytehq/airbyte/pull/22308) | Add `AvailabilityStrategy` for all streams |
| `0.2.24` | 2023-02-17 | [23246](https://github.com/airbytehq/airbyte/pull/23246) | Handle `StartTimeTooRecent` error for Tickets stream |
| `0.2.26` | 2023-03-20 | [24252](https://github.com/airbytehq/airbyte/pull/24252) | Handle invalid `start_date` when checking connection |
| `0.2.25` | 2023-02-28 | [22308](https://github.com/airbytehq/airbyte/pull/22308) | Add `AvailabilityStrategy` for all streams |
| `0.2.24` | 2023-02-17 | [23246](https://github.com/airbytehq/airbyte/pull/23246) | Handle `StartTimeTooRecent` error for Tickets stream |
| `0.2.23` | 2023-02-15 | [23035](https://github.com/airbytehq/airbyte/pull/23035) | Handle 403 Error |
| `0.2.22` | 2023-02-14 | [22483](https://github.com/airbytehq/airbyte/pull/22483) | Fix test; handle 400 error |
| `0.2.21` | 2023-01-27 | [22027](https://github.com/airbytehq/airbyte/pull/22027) | Set `AvailabilityStrategy` for streams explicitly to `None` |
Expand Down

0 comments on commit 1ce5403

Please sign in to comment.