3
3
from nodestream_github import GithubReposExtractor
4
4
from tests .data .orgs import GITHUB_ORG_SUMMARY
5
5
from tests .data .repos import HELLO_WORLD_REPO , repo
6
- from tests .data .users import OCTOCAT_USER , TURBO_USER
6
+ from tests .data .users import OCTOCAT_USER , TURBO_USER , user
7
7
from tests .data .webhooks import HELLO_WORLD_WEBHOOK
8
8
from tests .mocks .githubrest import DEFAULT_HOSTNAME , DEFAULT_PER_PAGE , GithubHttpxMock
9
9
10
+ TEST_USER = user (user_login = "bweaver" , user_id = 3 )
11
+
10
12
11
13
@pytest .fixture
12
14
def repo_client () -> GithubReposExtractor :
@@ -35,13 +37,30 @@ async def test_pull_org_repos(gh_rest_mock: GithubHttpxMock):
35
37
gh_rest_mock .get_repos_for_org ("github" , "public" , json = [HELLO_WORLD_REPO ])
36
38
gh_rest_mock .get_repos_for_org ("github" , "private" , json = [HELLO_WORLD_REPO ])
37
39
gh_rest_mock .get_languages_for_repo (
38
- "octocat" , "Hello-World" , json = [], is_reusable = True
40
+ "octocat" ,
41
+ "Hello-World" ,
42
+ json = [],
43
+ is_reusable = True ,
39
44
)
40
45
gh_rest_mock .get_webhooks_for_repo (
41
- "octocat" , "Hello-World" , json = [], is_reusable = True
46
+ "octocat" ,
47
+ "Hello-World" ,
48
+ json = [],
49
+ is_reusable = True ,
50
+ )
51
+ gh_rest_mock .get_collaborators_for_repo (
52
+ "octocat" ,
53
+ "Hello-World" ,
54
+ affiliation = "direct" ,
55
+ json = [],
56
+ is_reusable = True ,
42
57
)
43
58
gh_rest_mock .get_collaborators_for_repo (
44
- "octocat" , "Hello-World" , json = [], is_reusable = True
59
+ "octocat" ,
60
+ "Hello-World" ,
61
+ affiliation = "outside" ,
62
+ json = [],
63
+ is_reusable = True ,
45
64
)
46
65
47
66
assert len ([record async for record in extractor .extract_records ()]) == 2
@@ -62,13 +81,30 @@ async def test_pull_user_repos(gh_rest_mock: GithubHttpxMock):
62
81
gh_rest_mock .get_repos_for_user ("octocat" , "public" , json = [HELLO_WORLD_REPO ])
63
82
gh_rest_mock .get_repos_for_user ("octocat" , "private" , json = [HELLO_WORLD_REPO ])
64
83
gh_rest_mock .get_languages_for_repo (
65
- "octocat" , "Hello-World" , json = [], is_reusable = True
84
+ "octocat" ,
85
+ "Hello-World" ,
86
+ json = [],
87
+ is_reusable = True ,
66
88
)
67
89
gh_rest_mock .get_webhooks_for_repo (
68
- "octocat" , "Hello-World" , json = [], is_reusable = True
90
+ "octocat" ,
91
+ "Hello-World" ,
92
+ json = [],
93
+ is_reusable = True ,
94
+ )
95
+ gh_rest_mock .get_collaborators_for_repo (
96
+ "octocat" ,
97
+ "Hello-World" ,
98
+ affiliation = "direct" ,
99
+ json = [],
100
+ is_reusable = True ,
69
101
)
70
102
gh_rest_mock .get_collaborators_for_repo (
71
- "octocat" , "Hello-World" , json = [], is_reusable = True
103
+ "octocat" ,
104
+ "Hello-World" ,
105
+ affiliation = "outside" ,
106
+ json = [],
107
+ is_reusable = True ,
72
108
)
73
109
74
110
assert len ([record async for record in extractor .extract_records ()]) == 2
@@ -94,8 +130,15 @@ async def test_extract_records(
94
130
gh_rest_mock .get_collaborators_for_repo (
95
131
owner_login = "octocat" ,
96
132
repo_name = "Hello-World" ,
133
+ affiliation = "direct" ,
97
134
json = [TURBO_USER | {"role_name" : "write" }],
98
135
)
136
+ gh_rest_mock .get_collaborators_for_repo (
137
+ owner_login = "octocat" ,
138
+ repo_name = "Hello-World" ,
139
+ affiliation = "outside" ,
140
+ json = [TEST_USER | {"role_name" : "read" }],
141
+ )
99
142
gh_rest_mock .get_languages_for_repo (
100
143
owner_login = "github" ,
101
144
repo_name = "Hello-Moon" ,
@@ -109,8 +152,15 @@ async def test_extract_records(
109
152
gh_rest_mock .get_collaborators_for_repo (
110
153
owner_login = "github" ,
111
154
repo_name = "Hello-Moon" ,
155
+ affiliation = "direct" ,
112
156
json = [TURBO_USER ],
113
157
)
158
+ gh_rest_mock .get_collaborators_for_repo (
159
+ owner_login = "github" ,
160
+ repo_name = "Hello-Moon" ,
161
+ affiliation = "outside" ,
162
+ json = [TEST_USER ],
163
+ )
114
164
assert [record async for record in repo_client .extract_records ()] == [
115
165
{
116
166
"archive_url" : (
@@ -125,12 +175,22 @@ async def test_extract_records(
125
175
"https://HOSTNAME/repos/octocat/Hello-World/branches{/branch}"
126
176
),
127
177
"clone_url" : "https://github.com/octocat/Hello-World.git" ,
128
- "collaborators" : [{
129
- "id" : 2 ,
130
- "login" : "turbo" ,
131
- "node_id" : "MDQ6VXNlcjI=" ,
132
- "role_name" : "write" ,
133
- }],
178
+ "collaborators" : [
179
+ {
180
+ "affiliation" : "direct" ,
181
+ "id" : 2 ,
182
+ "login" : "turbo" ,
183
+ "node_id" : "MDQ6VXNlcjI=" ,
184
+ "role_name" : "write" ,
185
+ },
186
+ {
187
+ "affiliation" : "outside" ,
188
+ "id" : 3 ,
189
+ "login" : "bweaver" ,
190
+ "node_id" : "MDQ6VXNlcjM=" ,
191
+ "role_name" : "read" ,
192
+ },
193
+ ],
134
194
"collaborators_url" : "https://HOSTNAME/repos/octocat/Hello-World/collaborators{/collaborator}" ,
135
195
"comments_url" : (
136
196
"https://HOSTNAME/repos/octocat/Hello-World/comments{/number}"
@@ -280,7 +340,20 @@ async def test_extract_records(
280
340
"https://HOSTNAME/repos/github/Hello-Moon/branches{/branch}"
281
341
),
282
342
"clone_url" : "https://github.com/github/Hello-Moon.git" ,
283
- "collaborators" : [{"id" : 2 , "login" : "turbo" , "node_id" : "MDQ6VXNlcjI=" }],
343
+ "collaborators" : [
344
+ {
345
+ "affiliation" : "direct" ,
346
+ "id" : 2 ,
347
+ "login" : "turbo" ,
348
+ "node_id" : "MDQ6VXNlcjI=" ,
349
+ },
350
+ {
351
+ "affiliation" : "outside" ,
352
+ "id" : 3 ,
353
+ "login" : "bweaver" ,
354
+ "node_id" : "MDQ6VXNlcjM=" ,
355
+ },
356
+ ],
284
357
"collaborators_url" : (
285
358
"https://HOSTNAME/repos/github/Hello-Moon/collaborators{/collaborator}"
286
359
),
0 commit comments