From 8779cf672af1abd1a1f67afef20a61ae5876a724 Mon Sep 17 00:00:00 2001 From: "John L. Villalovos" Date: Tue, 18 Oct 2022 22:22:27 -0700 Subject: [PATCH] test: fix `test_project_push_rules` test Make the `test_project_push_rules` test work. --- tests/functional/api/test_push_rules.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/functional/api/test_push_rules.py b/tests/functional/api/test_push_rules.py index f82a87336..15a31403c 100644 --- a/tests/functional/api/test_push_rules.py +++ b/tests/functional/api/test_push_rules.py @@ -1,11 +1,14 @@ import pytest +import gitlab + @pytest.mark.gitlab_premium -@pytest.mark.xfail(reason="need to relax RESTObject init for non-dict responses") def test_project_push_rules(project): - push_rules = project.pushrules.get() - assert not push_rules + with pytest.raises(gitlab.GitlabParsingError): + # when no rules are defined the API call returns back `None` which + # causes a gitlab.GitlabParsingError in RESTObject.__init__() + project.pushrules.get() push_rules = project.pushrules.create({"deny_delete_tag": True}) assert push_rules.deny_delete_tag @@ -18,4 +21,6 @@ def test_project_push_rules(project): assert not push_rules.deny_delete_tag push_rules.delete() - assert not push_rules + + with pytest.raises(gitlab.GitlabParsingError): + project.pushrules.get()