Skip to content

Commit 292be7d

Browse files
author
Greg Land
committed
Fixed description argument for create_from_mirror
* Fixed Snapshot.create_from_mirror. Description argument was not being set in the post. * Fixed test_create_from_mirror to check the post request fields to make sure they match expected values.
1 parent 71e19b4 commit 292be7d

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

aptly_api/parts/snapshots.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ def create_from_mirror(self, mirrorname: str, snapshotname: str, description: Op
5656
body = {
5757
"Name": snapshotname
5858
}
59+
if description is not None:
60+
body["Description"] = description
61+
5962
resp = self.do_post("api/mirrors/%s/snapshots" %
6063
quote(mirrorname), json=body)
6164
return self.snapshot_from_response(resp.json())

aptly_api/tests/test_snapshots.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ def test_create_from_packages(self, *, rmock: requests_mock.Mocker) -> None:
207207
)
208208

209209
def test_create_from_mirror(self, *, rmock: requests_mock.Mocker) -> None:
210+
expected = {'Name': 'aptly-mirror-snap', 'Description': 'Snapshot from local repo [aptly-repo]'}
210211
rmock.post("http://test/api/mirrors/aptly-mirror/snapshots",
211212
text='{"Name":"aptly-mirror-snap","CreatedAt":"2022-11-29T21:43:45.275605639Z",'
212213
'"Description":"Snapshot from local mirror [aptly-mirror]"}')
@@ -219,3 +220,4 @@ def test_create_from_mirror(self, *, rmock: requests_mock.Mocker) -> None:
219220
created_at=iso8601.parse_date('2022-11-29T21:43:45.275605639Z')
220221
)
221222
)
223+
self.assertEqual(rmock.request_history[0].json(), expected)

0 commit comments

Comments
 (0)