File tree Expand file tree Collapse file tree 2 files changed +50
-0
lines changed
Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -291,3 +291,33 @@ async def remove_member(
291291 api = f"/orgs/{ organization } /teams/{ team } /memberships/{ username } "
292292 response = await self ._client .delete (api )
293293 response .raise_for_status ()
294+
295+ async def repositories (
296+ self ,
297+ organization : str ,
298+ team : str ,
299+ ) -> Iterable [JSON_OBJECT ]:
300+ """
301+ Lists a team's repositories visible to the authenticated user.
302+
303+ https://docs.github.com/en/rest/teams/teams#list-team-repositories
304+
305+ Args:
306+ organization: GitHub organization to use
307+ team: The slug of the team name.
308+
309+ Raises:
310+ `httpx.HTTPStatusError` if there was an error in the request
311+ """
312+ api = f"/orgs/{ organization } /teams/{ team } /repos"
313+ repos = []
314+ params = {
315+ "per_page" : "100" ,
316+ }
317+
318+ async for response in self ._client .get_all (api , params = params ):
319+ response .raise_for_status ()
320+
321+ repos .extend (response .json ())
322+
323+ return repos
Original file line number Diff line number Diff line change @@ -263,3 +263,23 @@ async def test_remove_member_failure(self):
263263 self .client .delete .assert_awaited_once_with (
264264 "/orgs/foo/teams/bar/memberships/baz"
265265 )
266+
267+ async def test_repositories (self ):
268+ response1 = create_response ()
269+ response1 .json .return_value = [{"id" : 1 }]
270+ response2 = create_response ()
271+ response2 .json .return_value = [{"id" : 2 }, {"id" : 3 }]
272+
273+ self .client .get_all .return_value = AsyncIteratorMock (
274+ [response1 , response2 ]
275+ )
276+
277+ repos = await self .api .repositories ("foo" , "bar" )
278+
279+ self .assertEqual (len (repos ), 3 )
280+ self .assertEqual (repos , [{"id" : 1 }, {"id" : 2 }, {"id" : 3 }])
281+
282+ self .client .get_all .assert_called_once_with (
283+ "/orgs/foo/teams/bar/repos" ,
284+ params = {"per_page" : "100" },
285+ )
You can’t perform that action at this time.
0 commit comments