Skip to content

Commit 4aab77f

Browse files
TimKnight-DWPJohnVillalovos
authored andcommitted
test: cover .get_id() paths
Signed-off-by: Tim Knight <tim.knight1@engineering.digital.dwp.gov.uk>
1 parent c6a1fc6 commit 4aab77f

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

gitlab/v4/objects/job_token_scope.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ def get_id(self) -> int:
4444
"""Returns the id of the resource. This override deals with
4545
the fact that either an `id` or a `target_project_id` attribute
4646
is returned by the server depending on the endpoint called."""
47-
project_id = cast(int, super().get_id())
48-
if project_id is not None:
49-
return project_id
47+
target_project_id = cast(int, super().get_id())
48+
if target_project_id is not None:
49+
return target_project_id
5050
return cast(int, self.id)
5151

5252

@@ -64,9 +64,9 @@ def get_id(self) -> int:
6464
"""Returns the id of the resource. This override deals with
6565
the fact that either an `id` or a `target_group_id` attribute
6666
is returned by the server depending on the endpoint called."""
67-
group_id = cast(int, super().get_id())
68-
if group_id is not None:
69-
return group_id
67+
target_group_id = cast(int, super().get_id())
68+
if target_group_id is not None:
69+
return target_group_id
7070
return cast(int, self.id)
7171

7272

tests/unit/objects/test_job_token_scope.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ def test_get_projects_allowlist(job_token_scope, resp_get_allowlist):
174174

175175
allowlist_content = allowlist.list()
176176
assert isinstance(allowlist_content, list)
177+
assert allowlist_content[0].get_id() == 4
177178

178179

179180
def test_add_project_to_allowlist(job_token_scope, resp_add_to_allowlist):
@@ -190,6 +191,7 @@ def test_get_groups_allowlist(job_token_scope, resp_get_groups_allowlist):
190191

191192
allowlist_content = allowlist.list()
192193
assert isinstance(allowlist_content, list)
194+
assert allowlist_content[0].get_id() == 4
193195

194196

195197
def test_add_group_to_allowlist(job_token_scope, resp_add_to_groups_allowlist):

0 commit comments

Comments
 (0)