airbyte-source-github 1.5.7__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. airbyte_source_github-1.5.7.dist-info/METADATA +144 -0
  2. airbyte_source_github-1.5.7.dist-info/RECORD +88 -0
  3. airbyte_source_github-1.5.7.dist-info/WHEEL +5 -0
  4. airbyte_source_github-1.5.7.dist-info/entry_points.txt +2 -0
  5. airbyte_source_github-1.5.7.dist-info/top_level.txt +3 -0
  6. integration_tests/__init__.py +0 -0
  7. integration_tests/abnormal_state.json +237 -0
  8. integration_tests/acceptance.py +16 -0
  9. integration_tests/configured_catalog.json +435 -0
  10. integration_tests/configured_catalog_full_refresh_test.json +415 -0
  11. integration_tests/invalid_config.json +5 -0
  12. integration_tests/sample_config.json +5 -0
  13. integration_tests/sample_state.json +137 -0
  14. source_github/__init__.py +27 -0
  15. source_github/config_migrations.py +106 -0
  16. source_github/constants.py +9 -0
  17. source_github/github_schema.py +41034 -0
  18. source_github/graphql.py +327 -0
  19. source_github/run.py +17 -0
  20. source_github/schemas/assignees.json +63 -0
  21. source_github/schemas/branches.json +48 -0
  22. source_github/schemas/collaborators.json +80 -0
  23. source_github/schemas/comments.json +104 -0
  24. source_github/schemas/commit_comment_reactions.json +4 -0
  25. source_github/schemas/commit_comments.json +53 -0
  26. source_github/schemas/commits.json +126 -0
  27. source_github/schemas/contributor_activity.json +109 -0
  28. source_github/schemas/deployments.json +77 -0
  29. source_github/schemas/events.json +63 -0
  30. source_github/schemas/issue_comment_reactions.json +4 -0
  31. source_github/schemas/issue_events.json +335 -0
  32. source_github/schemas/issue_labels.json +30 -0
  33. source_github/schemas/issue_milestones.json +61 -0
  34. source_github/schemas/issue_reactions.json +28 -0
  35. source_github/schemas/issue_timeline_events.json +1056 -0
  36. source_github/schemas/issues.json +281 -0
  37. source_github/schemas/organizations.json +197 -0
  38. source_github/schemas/project_cards.json +50 -0
  39. source_github/schemas/project_columns.json +38 -0
  40. source_github/schemas/projects.json +50 -0
  41. source_github/schemas/projects_v2.json +80 -0
  42. source_github/schemas/pull_request_comment_reactions.json +28 -0
  43. source_github/schemas/pull_request_commits.json +122 -0
  44. source_github/schemas/pull_request_stats.json +84 -0
  45. source_github/schemas/pull_requests.json +363 -0
  46. source_github/schemas/releases.json +126 -0
  47. source_github/schemas/repositories.json +313 -0
  48. source_github/schemas/review_comments.json +118 -0
  49. source_github/schemas/reviews.json +69 -0
  50. source_github/schemas/shared/events/comment.json +188 -0
  51. source_github/schemas/shared/events/commented.json +118 -0
  52. source_github/schemas/shared/events/committed.json +56 -0
  53. source_github/schemas/shared/events/cross_referenced.json +784 -0
  54. source_github/schemas/shared/events/reviewed.json +139 -0
  55. source_github/schemas/shared/reaction.json +27 -0
  56. source_github/schemas/shared/reactions.json +35 -0
  57. source_github/schemas/shared/user.json +59 -0
  58. source_github/schemas/shared/user_graphql.json +26 -0
  59. source_github/schemas/stargazers.json +19 -0
  60. source_github/schemas/tags.json +32 -0
  61. source_github/schemas/team_members.json +66 -0
  62. source_github/schemas/team_memberships.json +24 -0
  63. source_github/schemas/teams.json +50 -0
  64. source_github/schemas/users.json +63 -0
  65. source_github/schemas/workflow_jobs.json +109 -0
  66. source_github/schemas/workflow_runs.json +449 -0
  67. source_github/schemas/workflows.json +41 -0
  68. source_github/source.py +339 -0
  69. source_github/spec.json +179 -0
  70. source_github/streams.py +1678 -0
  71. source_github/utils.py +152 -0
  72. unit_tests/__init__.py +3 -0
  73. unit_tests/conftest.py +29 -0
  74. unit_tests/projects_v2_pull_requests_query.json +3 -0
  75. unit_tests/pull_request_stats_query.json +3 -0
  76. unit_tests/responses/contributor_activity_response.json +33 -0
  77. unit_tests/responses/graphql_reviews_responses.json +405 -0
  78. unit_tests/responses/issue_timeline_events.json +166 -0
  79. unit_tests/responses/issue_timeline_events_response.json +170 -0
  80. unit_tests/responses/projects_v2_response.json +45 -0
  81. unit_tests/responses/pull_request_comment_reactions.json +744 -0
  82. unit_tests/responses/pull_request_stats_response.json +317 -0
  83. unit_tests/test_migrations/test_config.json +8 -0
  84. unit_tests/test_migrations/test_new_config.json +8 -0
  85. unit_tests/test_multiple_token_authenticator.py +160 -0
  86. unit_tests/test_source.py +326 -0
  87. unit_tests/test_stream.py +1471 -0
  88. unit_tests/utils.py +78 -0
unit_tests/utils.py ADDED
@@ -0,0 +1,78 @@
1
+ #
2
+ # Copyright (c) 2023 Airbyte, Inc., all rights reserved.
3
+ #
4
+
5
+ from typing import Any, MutableMapping
6
+ from unittest import mock
7
+
8
+ import responses
9
+ from airbyte_cdk.models import SyncMode
10
+ from airbyte_cdk.models.airbyte_protocol import ConnectorSpecification
11
+ from airbyte_cdk.sources import Source
12
+ from airbyte_cdk.sources.streams import Stream
13
+ from airbyte_cdk.sources.utils.schema_helpers import check_config_against_spec_or_exit, split_config
14
+
15
+
16
+ def read_incremental(stream_instance: Stream, stream_state: MutableMapping[str, Any]):
17
+ res = []
18
+ slices = stream_instance.stream_slices(sync_mode=SyncMode.incremental, stream_state=stream_state)
19
+ for slice in slices:
20
+ records = stream_instance.read_records(sync_mode=SyncMode.incremental, stream_slice=slice, stream_state=stream_state)
21
+ for record in records:
22
+ stream_state = stream_instance.get_updated_state(stream_state, record)
23
+ res.append(record)
24
+ return res
25
+
26
+
27
+ class ProjectsResponsesAPI:
28
+ """
29
+ Fake Responses API for github projects, columns, cards
30
+ """
31
+
32
+ projects_url = "https://api.github.com/repos/organization/repository/projects"
33
+ columns_url = "https://api.github.com/projects/{project_id}/columns"
34
+ cards_url = "https://api.github.com/projects/columns/{column_id}/cards"
35
+
36
+ @classmethod
37
+ def get_json_projects(cls, data):
38
+ res = []
39
+ for n, project in enumerate(data, start=1):
40
+ name = f"project_{n}"
41
+ res.append({"id": n, "name": name, "updated_at": project["updated_at"]})
42
+ return res
43
+
44
+ @classmethod
45
+ def get_json_columns(cls, project, project_id):
46
+ res = []
47
+ for n, column in enumerate(project.get("columns", []), start=1):
48
+ column_id = int(str(project_id) + str(n))
49
+ name = f"column_{column_id}"
50
+ res.append({"id": column_id, "name": name, "updated_at": column["updated_at"]})
51
+ return res
52
+
53
+ @classmethod
54
+ def get_json_cards(cls, column, column_id):
55
+ res = []
56
+ for n, card in enumerate(column.get("cards", []), start=1):
57
+ card_id = int(str(column_id) + str(n))
58
+ name = f"card_{card_id}"
59
+ res.append({"id": card_id, "name": name, "updated_at": card["updated_at"]})
60
+ return res
61
+
62
+ @classmethod
63
+ def register(cls, data):
64
+ responses.upsert("GET", cls.projects_url, json=cls.get_json_projects(data))
65
+ for project_id, project in enumerate(data, start=1):
66
+ responses.upsert("GET", cls.columns_url.format(project_id=project_id), json=cls.get_json_columns(project, project_id))
67
+ for n, column in enumerate(project.get("columns", []), start=1):
68
+ column_id = int(str(project_id) + str(n))
69
+ responses.upsert("GET", cls.cards_url.format(column_id=column_id), json=cls.get_json_cards(column, column_id))
70
+
71
+
72
+ def command_check(source: Source, config):
73
+ logger = mock.MagicMock()
74
+ connector_config, _ = split_config(config)
75
+ if source.check_config_against_spec:
76
+ source_spec: ConnectorSpecification = source.spec(logger)
77
+ check_config_against_spec_or_exit(connector_config, source_spec)
78
+ return source.check(logger, config)