From 88706ebdc9fa4077aa3c519e873c0a47c2e1d991 Mon Sep 17 00:00:00 2001 From: "Roman Yermilov [GL]" <86300758+roman-yermilov-gl@users.noreply.github.com> Date: Thu, 9 Nov 2023 11:39:45 +0400 Subject: [PATCH] Source Jira: increase test coverage (#32321) Co-authored-by: roman-yermilov-gl --- .../source-jira/unit_tests/test_streams.py | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/airbyte-integrations/connectors/source-jira/unit_tests/test_streams.py b/airbyte-integrations/connectors/source-jira/unit_tests/test_streams.py index d063abe3947a..d41c0c692da6 100644 --- a/airbyte-integrations/connectors/source-jira/unit_tests/test_streams.py +++ b/airbyte-integrations/connectors/source-jira/unit_tests/test_streams.py @@ -386,6 +386,17 @@ def test_board_issues_stream(config, board_issues_response): assert len(responses.calls) == 3 +def test_stream_updated_state(config): + authenticator = SourceJira().get_authenticator(config=config) + args = {"authenticator": authenticator, "domain": config["domain"], "projects": config.get("projects", [])} + stream = BoardIssues(**args) + + current_stream_state = {"updated": "09.11.2023"} + latest_record = {"updated": "10.11.2023"} + + assert {"updated": "10.11.2023"} == stream.get_updated_state(current_stream_state=current_stream_state, latest_record=latest_record) + + @responses.activate def test_filter_sharing_stream(config, filter_sharing_response): responses.add( @@ -684,6 +695,21 @@ def test_avatars_stream(config, avatars_response): assert len(responses.calls) == 1 +@responses.activate +def test_avatars_stream_should_retry(config, caplog): + url = f"https://{config['domain']}/rest/api/3/avatar/issuetype/system?maxResults=50" + responses.add(method=responses.GET, url=url, json={"errorMessages": ["The error message"], "errors": {}}, status=400) + + authenticator = SourceJira().get_authenticator(config=config) + args = {"authenticator": authenticator, "domain": config["domain"], "projects": config.get("projects", [])} + stream = Avatars(**args) + + response = requests.get(url) + actual = stream.should_retry(response) + assert actual is False + assert "The error message" in caplog.text + + @responses.activate def test_issues_stream(config, projects_response, mock_issues_responses, issues_response, caplog): Projects.use_cache = False