Skip to content

Commit

Permalink
updated discovery test
Browse files Browse the repository at this point in the history
  • Loading branch information
somethingmorerelevant committed Oct 24, 2024
1 parent bdb3e14 commit 805ca17
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions tests/unittests/test_auth_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from requests.exceptions import HTTPError

import tap_zendesk_chat
from tap_zendesk_chat.http import Client
from tap_zendesk_chat.http import Client, InvalidConfigurationError


# Mock args
Expand All @@ -13,6 +13,7 @@ def __init__(self):
self.discover = True
self.properties = False
self.config = {"access_token": "abc-def"}
self.config_wd_subdomain = {"access_token": "abc-def", "subdomain":"test"}
self.state = False
self.properties = {}

Expand Down Expand Up @@ -43,9 +44,16 @@ def test_basic_auth_no_access_401(self):

with self.assertRaises(HTTPError) as e:
tap_zendesk_chat.discover(args.config)
# Verifying the message formed for the custom exception
expected_error_message = "401 Client Error: Unauthorized for url:"
self.assertIn(expected_error_message, str(e.exception))
# Verifying the message formed for the custom exception
expected_error_message = "401 Client Error: Unauthorized for url:"
self.assertIn(expected_error_message, str(e.exception))

expected_error_message = "Please check the URL or reauthenticate"

with self.assertRaises(InvalidConfigurationError) as e:
tap_zendesk_chat.discover(args.config_wd_subdomain)
self.assertIn(expected_error_message, str(e.exception))


@mock.patch("tap_zendesk_chat.utils", return_value=Args())
@mock.patch("singer.catalog.Catalog.from_dict", return_value={"key": "value"})
Expand All @@ -63,6 +71,7 @@ def test_discovery(self, mock_utils, mock_catalog, mock_request):
self.assertEqual(tap_zendesk_chat.discover(Args().config), expected)



class TestAccountEndpointAuthorized(unittest.TestCase):
def test_is_account_not_authorized_404(self):
"""tests if account_not_authorized method in discover raises http
Expand Down

0 comments on commit 805ca17

Please sign in to comment.