Skip to content

Commit

Permalink
ProjectColumns tests added
Browse files Browse the repository at this point in the history
Signed-off-by: Sergey Chvalyuk <grubberr@gmail.com>
  • Loading branch information
grubberr committed Feb 18, 2022
1 parent c69bf91 commit 9ca6b31
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ tests:
issue_events: ["airbytehq/integration-test", "created_at"]
issue_milestones: ["airbytehq/integration-test", "updated_at"]
issues: ["airbytehq/integration-test", "updated_at"]
project_columns: ["airbytehq/integration-test", "13167124", "updated_at"]
projects: ["airbytehq/integration-test", "updated_at"]
pull_request_stats: ["airbytehq/integration-test", "updated_at"]
pull_requests: ["airbytehq/integration-test", "updated_at"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@
"updated_at": "2121-06-30T06:44:42Z"
}
},
"project_columns": {
"airbytehq/integration-test": {
"13167122": {
"updated_at": "2121-06-29T02:04:57Z"
},
"13167124": {
"updated_at": "2121-06-29T02:04:57Z"
}
}
},
"projects": {
"airbytehq/integration-test": {
"updated_at": "2121-06-28T17:24:51Z"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,15 @@ def check_connection(self, logger: AirbyteLogger, config: Mapping[str, Any]) ->

except Exception as e:
message = repr(e)
if '404 Client Error: Not Found for url: https://api.github.com/repos/' in message:
if "404 Client Error: Not Found for url: https://api.github.com/repos/" in message:
# HTTPError('404 Client Error: Not Found for url: https://api.github.com/repos/airbytehq/airbyte3?per_page=100')"
full_repo_name = message.split('https://api.github.com/repos/')[1]
full_repo_name = full_repo_name.split('?')[0]
full_repo_name = message.split("https://api.github.com/repos/")[1]
full_repo_name = full_repo_name.split("?")[0]
message = f'Unknown repo name: "{full_repo_name}", use existing full repo name <organization>/<repository>'
elif '404 Client Error: Not Found for url: https://api.github.com/orgs/' in message:
elif "404 Client Error: Not Found for url: https://api.github.com/orgs/" in message:
# HTTPError('404 Client Error: Not Found for url: https://api.github.com/orgs/airbytehqBLA/repos?per_page=100')"
org_name = message.split('https://api.github.com/orgs/')[1]
org_name = org_name.split('/')[0]
org_name = message.split("https://api.github.com/orgs/")[1]
org_name = org_name.split("/")[0]
message = f'Unknown organization name: "{org_name}"'

return False, message
Expand All @@ -178,6 +178,7 @@ def streams(self, config: Mapping[str, Any]) -> List[Stream]:

default_branches, branches_to_pull = self._get_branches_data(config.get("branch", ""), repository_args)
pull_requests_stream = PullRequests(**repository_args_with_start_date)
projects_stream = Projects(**repository_args_with_start_date)

return [
Assignees(**repository_args),
Expand All @@ -196,8 +197,8 @@ def streams(self, config: Mapping[str, Any]) -> List[Stream]:
IssueReactions(**repository_args_with_start_date),
Issues(**repository_args_with_start_date),
Organizations(**organization_args),
ProjectColumns(Projects(**repository_args_with_start_date), **repository_args_with_start_date),
Projects(**repository_args_with_start_date),
ProjectColumns(projects_stream, **repository_args_with_start_date),
projects_stream,
PullRequestCommentReactions(**repository_args_with_start_date),
PullRequestStats(parent=pull_requests_stream, **repository_args_with_start_date),
PullRequests(**repository_args_with_start_date),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -881,11 +881,12 @@ def read_records(
yield record

def get_starting_point(self, stream_state: Mapping[str, Any], stream_slice: Mapping[str, Any]) -> str:
repository = stream_slice["repository"]
project_id = stream_slice["project_id"]
stream_state_value = stream_state.get(repository, {}).get(project_id, {}).get(self.cursor_field)
if stream_state_value:
return max(self._start_date, stream_state_value)
if stream_state:
repository = stream_slice["repository"]
project_id = stream_slice["project_id"]
stream_state_value = stream_state.get(repository, {}).get(project_id, {}).get(self.cursor_field)
if stream_state_value:
return max(self._start_date, stream_state_value)
return self._start_date

def get_updated_state(self, current_stream_state: MutableMapping[str, Any], latest_record: Mapping[str, Any]):
Expand Down

1 comment on commit 9ca6b31

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SonarQube Report

SonarQube report for Airbyte Connectors Source Github(#10385)

Measures

Name Value Name Value Name Value
Code Smells 3 Lines to Cover 50 Coverage 22.0
Vulnerabilities 0 Security Rating A Lines of Code 926
Bugs 0 Duplicated Blocks 0 Quality Gate Status ERROR
Reliability Rating A Duplicated Lines (%) 0.0 Blocker Issues 0
Critical Issues 6 Major Issues 6 Minor Issues 6

Detected Issues

Rule File Description Message
python:S2638 (CRITICAL) source_github/streams.py:906 Method overrides should not change contracts Make parameter stream_state keyword-or-positional.
python:S2638 (CRITICAL) source_github/streams.py:907 Method overrides should not change contracts Make parameter stream_slice keyword-or-positional.
python:S2638 (CRITICAL) source_github/streams.py:908 Method overrides should not change contracts Make parameter next_page_token keyword-or-positional.
python:black_need_format (MINOR) source_github/source.py black:python:black_need_format 1 code part(s) should be updated.
flake8:E501 (MAJOR) source_github/streams.py:71 line too long (82 > 79 characters) line too long (143 > 140 characters)
python:isort_need_format (MINOR) unit_tests/test_stream.py isort:python:isort_need_format 1 code part(s) should be updated.
python:S3776 (CRITICAL) source_github/streams.py:91 Cognitive Complexity of functions should not be too high Refactor this function to reduce its Cognitive Complexity from 25 to the 15 allowed.
flake8:E501 (MAJOR) source_github/streams.py:67 line too long (82 > 79 characters) line too long (150 > 140 characters)
python:S5886 (MAJOR) source_github/streams.py:84 Function return types should be consistent with their type hint Return a value of type "Union[int, float]" instead of "NoneType" or update function "backoff_time" type hint.
python:S2638 (CRITICAL) source_github/streams.py:747 Method overrides should not change contracts Add missing parameters organization project_id.
python:isort_need_format (MINOR) unit_tests/test_source.py isort:python:isort_need_format 1 code part(s) should be updated.
python:isort_need_format (MINOR) unit_tests/unit_test.py isort:python:isort_need_format 1 code part(s) should be updated.
python:isort_need_format (MINOR) main.py isort:python:isort_need_format 1 code part(s) should be updated.
python:mypy_unknown (MINOR) main.py Unknown error Duplicate module named "main" (also at "./fixtures/main.py")
flake8:E501 (MAJOR) fixtures/github.py:22 line too long (82 > 79 characters) line too long (151 > 140 characters)
python:S5797 (CRITICAL) fixtures/github.py:79 Constants should not be used as conditions Replace this expression; used as a condition it will always be constant.
python:S112 (MAJOR) source_github/source.py:71 "Exception" and "BaseException" should not be raised Replace this generic exception class with a more specific one.
flake8:C901 (MAJOR) source_github/streams.py:91 flake8:C901 'GithubStream.read_records' is too complex (14)

Coverage (22.0%)

File Coverage File Coverage
fixtures/github.py 0.0 fixtures/main.py 0.0
integration_tests/acceptance.py 0.0 main.py 0.0
setup.py 0.0 source_github/init.py 100.0
source_github/source.py 48.9 source_github/streams.py 53.4
unit_tests/test_source.py 0.0 unit_tests/test_stream.py 0.0
unit_tests/unit_test.py 0.0

Please sign in to comment.