def image(self): """podman.domain.images.Image: Returns Image object used to create Container.""" if "Image" in self.attrs: image_id = self.attrs["Image"] return ImagesManager(client=self.client).get(image_id) return Image()
def test_save(self, mock): tarball = b'Yet another weird tarball...' body = io.BytesIO(tarball) adapter = mock.get( tests.LIBPOD_URL + "/images/326dd9d7add24646a325e8eaa82125294027db2332e49c5828d96312c5d773ab/get", body=body, ) image = Image(attrs=FIRST_IMAGE, client=self.client.api) with io.BytesIO() as fd: for chunk in image.save(): fd.write(chunk) self.assertEqual(fd.getbuffer(), tarball) self.assertTrue(adapter.called_once)
def image(self) -> Image: """Returns Image object used to create Container.""" if "Image" in self.attrs: image_id = self.attrs["Image"] if ":" in image_id: image_id = image_id.split(":")[1] return ImagesManager(client=self.client).get(image_id) return Image()
def test_history(self, mock): adapter = mock.get( tests.LIBPOD_URL + "/images/326dd9d7add24646a325e8eaa82125294027db2332e49c5828d96312c5d773ab/history", json=[{ "Id": "326dd9d7add24646a325e8eaa82125294027db2332e49c5828d96312c5d773ab", "Comment": "", "Created": 1614208404, "CreatedBy": "2021-02-24T23:13:24+00:00", "Tags": ["latest"], "Size": 1024, }], ) image = Image(attrs=FIRST_IMAGE, client=self.client.api) history = image.history() self.assertEqual(history[0]["Id"], image.id) self.assertTrue(adapter.called_once)