Skip to content

Commit 994f987

Browse files
committed
refactor(client): rename "update" function model's argument to payload
1 parent 4a06722 commit 994f987

File tree

3 files changed

+11
-38
lines changed

3 files changed

+11
-38
lines changed

pygitguardian/client.py

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,7 +1021,6 @@ def list_teams(
10211021
else:
10221022
obj = load_detail(response)
10231023

1024-
obj.status_code
10251024
return obj
10261025

10271026
def get_team(
@@ -1063,11 +1062,11 @@ def create_team(
10631062

10641063
def update_team(
10651064
self,
1066-
team: UpdateTeam,
1065+
payload: UpdateTeam,
10671066
extra_headers: Optional[Dict[str, str]] = None,
10681067
) -> Union[Detail, Team]:
1069-
team_id = team.id
1070-
data = UpdateTeam.to_dict(team)
1068+
team_id = payload.id
1069+
data = UpdateTeam.to_dict(payload)
10711070
del data["id"]
10721071

10731072
response = self.patch(
@@ -1118,7 +1117,6 @@ def list_team_invitations(
11181117
else:
11191118
obj = load_detail(response)
11201119

1121-
obj.status_code
11221120
return obj
11231121

11241122
def create_team_invitation(
@@ -1176,7 +1174,6 @@ def list_team_members(
11761174
else:
11771175
obj = load_detail(response)
11781176

1179-
obj.status_code
11801177
return obj
11811178

11821179
def create_team_member(
@@ -1233,7 +1230,6 @@ def list_sources(
12331230
else:
12341231
obj = load_detail(response)
12351232

1236-
obj.status_code
12371233
return obj
12381234

12391235
def list_team_sources(
@@ -1254,16 +1250,15 @@ def list_team_sources(
12541250
else:
12551251
obj = load_detail(response)
12561252

1257-
obj.status_code
12581253
return obj
12591254

12601255
def update_team_source(
12611256
self,
1262-
team_sources: UpdateTeamSource,
1257+
payload: UpdateTeamSource,
12631258
extra_headers: Optional[Dict[str, str]] = None,
1264-
) -> Union[Detail, int]:
1265-
team_id = team_sources.team_id
1266-
data = team_sources.to_dict()
1259+
) -> Optional[Detail]:
1260+
team_id = payload.team_id
1261+
data = payload.to_dict()
12671262
del data["team_id"]
12681263

12691264
response = self.post(
@@ -1272,10 +1267,8 @@ def update_team_source(
12721267
extra_headers=extra_headers,
12731268
)
12741269

1275-
if response.status_code == 204:
1276-
return 204
1277-
1278-
return load_detail(response)
1270+
if not response.status_code == 204:
1271+
return load_detail(response)
12791272

12801273
def list_invitations(
12811274
self,
@@ -1296,7 +1289,6 @@ def list_invitations(
12961289
else:
12971290
obj = load_detail(response)
12981291

1299-
obj.status_code
13001292
return obj
13011293

13021294
def create_invitation(

tests/conftest.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -71,25 +71,6 @@ def inner():
7171
return inner
7272

7373

74-
@pytest.fixture
75-
def get_member(client: GGClient):
76-
"""
77-
Return a function that fetches the first member available
78-
in the account, every account should have at least
79-
one member (the owner)
80-
"""
81-
82-
def inner():
83-
paginated_teams = client.list_members()
84-
assert isinstance(
85-
paginated_teams, CursorPaginatedResponse
86-
), "Could not fetch members from GitGuardian"
87-
88-
return paginated_teams.data[0]
89-
90-
return inner
91-
92-
9374
@pytest.fixture
9475
def get_invitation(client: GGClient):
9576
"""

tests/test_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1903,7 +1903,7 @@ def test_delete_team_sources(client: GGClient, get_team: Callable[[], Team]):
19031903
UpdateTeamSource(team.id, [], [source_to_delete.id])
19041904
)
19051905

1906-
assert result == 204
1906+
assert result is None
19071907

19081908
team_sources = client.list_team_sources(team.id)
19091909
assert isinstance(team_sources, CursorPaginatedResponse), team_sources
@@ -1927,7 +1927,7 @@ def test_add_team_sources(
19271927
UpdateTeamSource(team.id, [source.id], []),
19281928
)
19291929

1930-
assert result == 204
1930+
assert result is None
19311931

19321932
team_sources = client.list_team_sources(
19331933
team.id, TeamSourceParameters(type="azure_devops")

0 commit comments

Comments
 (0)