Skip to content

Commit

Permalink
Fixed return value of Request.cmd (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
crazyscientist authored Dec 12, 2022
1 parent 777fde4 commit da774fd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
6 changes: 1 addition & 5 deletions osctiny/extensions/bs_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,7 @@ def cmd(self, request_id, cmd="diff", **kwargs):
"""
kwargs["cmd"] = cmd
request_id = self._validate_id(request_id)
response = self.update(request_id=request_id, **kwargs)

if kwargs.get("view", "plain") == "xml":
return self.osc.get_objectified_xml(response)
return response.text
return self.update(request_id=request_id, **kwargs)

def add_comment(self, request_id, comment, parent_id=None):
"""
Expand Down
17 changes: 9 additions & 8 deletions osctiny/tests/test_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,14 +373,15 @@ def test_get(self):

@responses.activate
def test_update(self):
with self.subTest("cmd=diff, plain"):
response = self.osc.requests.update(30902, cmd="diff")
self.assertTrue(isinstance(response, str))
self.assertIn("changes files:", response)
self.assertIn("+++ perl-XML-DOM-XPath.changes", response)
with self.subTest("cmd=diff, xml"):
response = self.osc.requests.update(30902, cmd="diff", view="xml")
self.assertTrue(isinstance(response, ObjectifiedElement))
for method in (self.osc.requests.update, self.osc.requests.cmd):
with self.subTest(f"{method}, cmd=diff, plain"):
response = method(30902, cmd="diff")
self.assertTrue(isinstance(response, str))
self.assertIn("changes files:", response)
self.assertIn("+++ perl-XML-DOM-XPath.changes", response)
with self.subTest(f"{method}, cmd=diff, xml"):
response = method(30902, cmd="diff", view="xml")
self.assertTrue(isinstance(response, ObjectifiedElement))

@responses.activate
def test_comment(self):
Expand Down

0 comments on commit da774fd

Please sign in to comment.