Skip to content

Commit

Permalink
osctiny.models.request.Target model: make the 'package' attribute opt…
Browse files Browse the repository at this point in the history
…ional (fixes #185) (#186)
  • Loading branch information
oSoMoN committed Sep 20, 2024
1 parent b6e4bb5 commit c998b4f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion osctiny/models/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class Target(typing.NamedTuple):
Target for an action
"""
project: str
package: str
package: typing.Optional[str] = None
releaseproject: typing.Optional[str] = None

def asxml(self) -> ObjectifiedElement:
Expand Down
20 changes: 20 additions & 0 deletions osctiny/tests/test_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,26 @@ def test_create(self):
b'</request>'
)

with self.subTest("XML content, target with no package"), mock.patch.object(
self.osc.session, "send", return_value=mock_response
) as mock_session:
self.osc.requests.create(
actions=[
Action(
type=ActionType.RELEASE,
target=Target(project="Foo:Bar"),
)
]
)
self.assertEqual(
mock_session.call_args[0][0].body,
b"<?xml version='1.0' encoding='utf-8'?>\n"
b"<request>"
b'<action type="release">'
b'<target project="Foo:Bar"/>'
b"</action>"
b"</request>",
)

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

0 comments on commit c998b4f

Please sign in to comment.