1
0
mirror of synced 2025-12-23 21:03:15 -05:00

Source GitHub: add stream ProjectsV2 (#30731)

Co-authored-by: artem1205 <artem1205@users.noreply.github.com>
This commit is contained in:
Artem Inzhyyants
2023-09-28 08:46:29 +02:00
committed by GitHub
parent 0537dde7d2
commit 61a63ec2ff
11 changed files with 9507 additions and 2518 deletions

View File

@@ -10,7 +10,7 @@ from unittest.mock import MagicMock, patch
import pytest
import requests
import responses
from airbyte_cdk.sources.streams.http.exceptions import BaseBackoffException
from airbyte_cdk.sources.streams.http.exceptions import BaseBackoffException, UserDefinedBackoffException
from requests import HTTPError
from responses import matchers
from source_github import constants
@@ -29,6 +29,7 @@ from source_github.streams import (
ProjectCards,
ProjectColumns,
Projects,
ProjectsV2,
PullRequestCommentReactions,
PullRequestCommits,
PullRequests,
@@ -1288,3 +1289,33 @@ def test_stream_pull_request_comment_reactions_read():
]
assert stream_state == {"airbytehq/airbyte": {"created_at": "2022-01-02T00:00:01Z"}}
@responses.activate
def test_stream_projects_v2_graphql_retry():
repository_args_with_start_date = {
"start_date": "2022-01-01T00:00:00Z",
"page_size_for_large_streams": 20,
"repositories": ["airbytehq/airbyte"],
}
stream = ProjectsV2(**repository_args_with_start_date)
resp = responses.add(responses.POST, "https://api.github.com/graphql", json={"errors": "not found"}, status=200, )
with patch.object(stream, "backoff_time", return_value=0.01), pytest.raises(UserDefinedBackoffException):
read_incremental(stream, stream_state={})
assert resp.call_count == stream.max_retries + 1
def test_stream_projects_v2_graphql_query():
repository_args_with_start_date = {
"start_date": "2022-01-01T00:00:00Z",
"page_size_for_large_streams": 20,
"repositories": ["airbytehq/airbyte"],
}
stream = ProjectsV2(**repository_args_with_start_date)
query = stream.request_body_json(stream_state={}, stream_slice={'repository': 'airbytehq/airbyte'})
f = Path(__file__).parent / "projects_v2_pull_requests_query.json"
expected_query = json.load(open(f))
assert query == expected_query