Skip to content

Commit 15a242c

Browse files
fix(cli): project-merge-request-approval-rule
Using the CLI the command: gitlab project-merge-request-approval-rule list --mr-iid 1 --project-id foo/bar Would raise an exception. This was due to the fact that `_id_attr` and `_repr_attr` were set for keys which are not returned in the response. Add a unit test which shows the `repr` function now works. Before it did not. This is an EE feature so we can't functional test it. Closes: #2065
1 parent ae7d3b0 commit 15a242c

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

gitlab/v4/objects/merge_request_approvals.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,7 @@ def set_approvers(
165165

166166

167167
class ProjectMergeRequestApprovalRule(SaveMixin, ObjectDeleteMixin, RESTObject):
168-
_id_attr = "approval_rule_id"
169-
_repr_attr = "approval_rule"
168+
_repr_attr = "name"
170169
id: int
171170
approval_rule_id: int
172171
merge_request_iid: int

tests/unit/objects/test_project_merge_request_approvals.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ def test_list_merge_request_approval_rules(project, resp_mr_approval_rules):
168168
assert len(approval_rules) == 1
169169
assert approval_rules[0].name == approval_rule_name
170170
assert approval_rules[0].id == approval_rule_id
171+
repr(approval_rules) # ensure that `repr()` doesn't raise an exception
171172

172173

173174
def test_delete_merge_request_approval_rule(project, resp_delete_mr_approval_rule):

0 commit comments

Comments
 (0)