Skip to content

Commit 16257d5

Browse files
committed
add test for push manifest
Signed-off-by: dklimpel <[email protected]>
1 parent 44abffd commit 16257d5

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

podman/tests/unit/test_imagesmanager.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ def test_prune_filters(self, mock):
181181
"""Unit test filters param for Images prune()."""
182182
mock.post(
183183
tests.LIBPOD_URL + "/images/prune?filters=%7B%22dangling%22%3A+%5B%22True%22%5D%7D",
184-
json=[
184+
params=[
185185
{
186186
"Id": "326dd9d7add24646a325e8eaa82125294027db2332e49c5828d96312c5d773ab",
187187
"Size": 1024,

podman/tests/unit/test_manifests.py

+35
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
import unittest
22

3+
import requests_mock
4+
35
from podman import PodmanClient, tests
46
from podman.domain.manifests import Manifest, ManifestsManager
57

8+
FIRST_MANIFEST = {
9+
"Id": "326dd9d7add24646a389e8eaa82125294027db2332e49c5828d96312c5d773ab",
10+
"names": "quay.io/fedora:latest",
11+
}
12+
613

714
class ManifestTestCase(unittest.TestCase):
815
def setUp(self) -> None:
@@ -23,6 +30,34 @@ def test_name(self):
2330
manifest = Manifest()
2431
self.assertIsNone(manifest.name)
2532

33+
@requests_mock.Mocker()
34+
def test_push(self, mock):
35+
adapter = mock.post(
36+
tests.LIBPOD_URL + "/manifests/quay.io%2Ffedora%3Alatest/registry/quay.io%2Ffedora%3Av1"
37+
)
38+
39+
manifest = Manifest(attrs=FIRST_MANIFEST, client=self.client.api)
40+
manifest.push(destination="quay.io/fedora:v1")
41+
42+
self.assertTrue(adapter.called_once)
43+
44+
@requests_mock.Mocker()
45+
def test_push_with_auth(self, mock):
46+
adapter = mock.post(
47+
tests.LIBPOD_URL
48+
+ "/manifests/quay.io%2Ffedora%3Alatest/registry/quay.io%2Ffedora%3Av1",
49+
request_headers={
50+
"X-Registry-Auth": b"eyJ1c2VybmFtZSI6ICJ1c2VyIiwgInBhc3N3b3JkIjogInBhc3MifQ=="
51+
},
52+
)
53+
54+
manifest = Manifest(attrs=FIRST_MANIFEST, client=self.client.api)
55+
manifest.push(
56+
destination="quay.io/fedora:v1", auth_config={"username": "user", "password": "pass"}
57+
)
58+
59+
self.assertTrue(adapter.called_once)
60+
2661

2762
if __name__ == '__main__':
2863
unittest.main()

0 commit comments

Comments
 (0)