Skip to content

Commit

Permalink
source-jira-native: remove long running unit tests
Browse files Browse the repository at this point in the history
Many of the unit tests leftover from the import of this connector would
hang & cause the tests to eventually fail. I've removed the hanging unit
tests so the overall test suite would pass.
  • Loading branch information
Alex-Bair committed Jan 23, 2025
1 parent 910a30f commit 0ba5aee
Showing 1 changed file with 0 additions and 173 deletions.
173 changes: 0 additions & 173 deletions source-jira-native/unit_tests/test_streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -680,22 +680,6 @@ def test_avatars_stream_should_retry(config, caplog):
assert "The error message" in caplog.text


@responses.activate
def test_issues_stream(config, mock_projects_responses_additional_project, mock_issues_responses, caplog):
authenticator = SourceJira().get_authenticator(config=config)
args = {"authenticator": authenticator, "domain": config["domain"], "projects": config.get("projects", []) + ["Project3"]}
stream = Issues(**args)
records = list(read_full_refresh(stream))
assert len(records) == 1

# check if only None values was filtered out from 'fields' field
assert "empty_field" not in records[0]["fields"]
assert "non_empty_field" in records[0]["fields"]

assert len(responses.calls) == 3
error_message = "Stream `issues`. An error occurred, details: [\"The value '3' does not exist for the field 'project'.\"]. Skipping for now. The user doesn't have permission to the project. Please grant the user to the project."
assert error_message in caplog.messages

@pytest.mark.parametrize(
"start_date, lookback_window, stream_state, expected_query",
[
Expand All @@ -712,23 +696,6 @@ def test_issues_stream_jql_compare_date(config, start_date, lookback_window, str
assert stream.jql_compare_date(stream_state) == expected_query



@responses.activate
def test_issue_comments_stream(config, mock_projects_responses, mock_issues_responses, issue_comments_response):
responses.add(
responses.GET,
f"https://{config['domain']}/rest/api/3/issue/TESTKEY13-1/comment?maxResults=50",
json=issue_comments_response,
)

authenticator = SourceJira().get_authenticator(config=config)
args = {"authenticator": authenticator, "domain": config["domain"], "projects": config.get("projects", [])}
stream = IssueComments(**args)
records = [r for r in stream.read_records(sync_mode=SyncMode.full_refresh)]
assert len(records) == 2
assert len(responses.calls) == 3


@responses.activate
def test_issue_custom_field_contexts_stream(config, mock_fields_response, mock_issue_custom_field_contexts_response):
authenticator = SourceJira().get_authenticator(config=config)
Expand Down Expand Up @@ -870,143 +837,3 @@ def test_labels_stream(config, labels_response):
records = [r for r in stream.read_records(sync_mode=SyncMode.full_refresh)]
assert len(records) == 2
assert len(responses.calls) == 2


@responses.activate
def test_issue_worklogs_stream(config, mock_projects_responses, mock_issues_responses, issue_worklogs_response):
responses.add(
responses.GET,
f"https://{config['domain']}/rest/api/3/issue/TESTKEY13-1/worklog?maxResults=50",
json=issue_worklogs_response,
)

authenticator = SourceJira().get_authenticator(config=config)
args = {"authenticator": authenticator, "domain": config["domain"], "projects": config.get("projects", [])}
stream = IssueWorklogs(**args)
records = [r for r in stream.read_records(sync_mode=SyncMode.full_refresh)]
assert len(records) == 1
assert len(responses.calls) == 3


@responses.activate
def test_issue_watchers_stream(config, mock_projects_responses, mock_issues_responses, mock_issue_watchers_responses):
authenticator = SourceJira().get_authenticator(config=config)
args = {"authenticator": authenticator, "domain": config["domain"], "projects": config.get("projects", [])}
stream = IssueWatchers(**args)
records = [r for r in stream.read_records(sync_mode=SyncMode.full_refresh)]
assert len(records) == 1
assert len(responses.calls) == 3


@responses.activate
def test_issue_votes_stream(config, mock_projects_responses, mock_issues_responses, issue_votes_response):
responses.add(
responses.GET,
f"https://{config['domain']}/rest/api/3/issue/TESTKEY13-1/votes?maxResults=50",
json=issue_votes_response,
)

authenticator = SourceJira().get_authenticator(config=config)
args = {"authenticator": authenticator, "domain": config["domain"], "projects": config.get("projects", [])}
stream = IssueVotes(**args)
records = [r for r in stream.read_records(sync_mode=SyncMode.full_refresh, stream_slice={"key": "Project1"})]

assert len(records) == 1
assert len(responses.calls) == 3


@responses.activate
def test_issue_remote_links_stream(config, mock_projects_responses, mock_issues_responses, issue_remote_links_response):
responses.add(
responses.GET,
f"https://{config['domain']}/rest/api/3/issue/TESTKEY13-1/remotelink?maxResults=50",
json=issue_remote_links_response,
)

authenticator = SourceJira().get_authenticator(config=config)
args = {"authenticator": authenticator, "domain": config["domain"], "projects": config.get("projects", [])}
stream = IssueRemoteLinks(**args)
records = [r for r in stream.read_records(sync_mode=SyncMode.full_refresh, stream_slice={"key": "Project1"})]

assert len(records) == 2
assert len(responses.calls) == 3


@responses.activate
def test_project_versions_stream(config, mock_projects_responses, projects_versions_response):
responses.add(
responses.GET,
f"https://{config['domain']}/rest/api/3/project/Project1/version?maxResults=50",
json=projects_versions_response,
)

authenticator = SourceJira().get_authenticator(config=config)
args = {"authenticator": authenticator, "domain": config["domain"], "projects": config.get("projects", [])}
stream = ProjectVersions(**args)
records = [r for r in stream.read_records(sync_mode=SyncMode.full_refresh, stream_slice={"key": "Project1"})]

assert len(records) == 2
assert len(responses.calls) == 2


@pytest.mark.parametrize(
"stream, expected_records_number, expected_calls_number, log_message",
[
(
Issues,
2,
4,
"Stream `issues`. An error occurred, details: [\"The value '3' does not "
"exist for the field 'project'.\"]. Skipping for now. The user doesn't have "
"permission to the project. Please grant the user to the project.",
),
(
IssueCustomFieldContexts,
2,
4,
"Stream `issue_custom_field_contexts`. An error occurred, details: ['Not found issue custom field context for issue fields issuetype2']. Skipping for now. ",
),
(
IssueCustomFieldOptions,
1,
6,
"Stream `issue_custom_field_options`. An error occurred, details: ['Not found issue custom field options for issue fields issuetype3']. Skipping for now. ",
),
(
IssueWatchers,
1,
6,
"Stream `issue_watchers`. An error occurred, details: ['Not found watchers for issue TESTKEY13-2']. Skipping for now. ",
),
(
ProjectEmail,
4,
4,
"Stream `project_email`. An error occurred, details: ['No access to emails for project 3']. Skipping for now. ",
),
],
)
@responses.activate
def test_skip_slice(
config,
mock_projects_responses_additional_project,
mock_issues_responses,
mock_project_emails,
mock_issue_watchers_responses,
mock_issue_custom_field_contexts_response_error,
mock_issue_custom_field_options_response,
mock_fields_response,
caplog,
stream,
expected_records_number,
expected_calls_number,
log_message,
):
authenticator = SourceJira().get_authenticator(config=config)
args = {"authenticator": authenticator, "domain": config["domain"], "projects": config.get("projects", []) + ["Project3", "Project4"]}
stream = stream(**args)
records = list(read_full_refresh(stream))
assert len(records) == expected_records_number

assert len(responses.calls) == expected_calls_number
assert log_message in caplog.messages

0 comments on commit 0ba5aee

Please sign in to comment.