Skip to content

Commit

Permalink
osctiny.models.request.Source model: add an optional 'repository' att…
Browse files Browse the repository at this point in the history
…ribute (fixes #190)
  • Loading branch information
oSoMoN committed Sep 24, 2024
1 parent 08e0925 commit 454dcca
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions osctiny/models/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class Source(typing.NamedTuple):
project: str
package: str
rev: typing.Optional[str] = None
repository: typing.Optional[str] = None

def asxml(self) -> ObjectifiedElement:
return E.source(**{field: getattr(self, field)
Expand Down
27 changes: 27 additions & 0 deletions osctiny/tests/test_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,33 @@ def test_create(self):
b"</request>",
)

with self.subTest(
"XML content, source with optional repository"
), mock.patch.object(
self.osc.session, "send", return_value=mock_response
) as mock_session:
self.osc.requests.create(
actions=[
Action(
type=ActionType.RELEASE,
source=Source(
project="Foo:Bar", package="p", repository="images"
),
target=Target(project="Baz:Qux"),
)
]
)
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="Baz:Qux"/>'
b'<source project="Foo:Bar" package="p" repository="images"/>'
b"</action>"
b"</request>",
)

with self.subTest(
"XML content, target with optional repository"
), mock.patch.object(
Expand Down

0 comments on commit 454dcca

Please sign in to comment.