diff options
author | Jhon Honce <jhonce@redhat.com> | 2018-04-24 18:42:59 -0700 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-04-27 14:11:13 +0000 |
commit | 32db403b5e4fdb96e727e8cda3922d235ad63aa4 (patch) | |
tree | e8a397d1c221a4c9cc1a66ffa9b7742c4474b5cb /test/varlink/test_images.py | |
parent | 37619de39abea9f6802b0f42e2be7dd142c516ed (diff) | |
download | podman-32db403b5e4fdb96e727e8cda3922d235ad63aa4.tar.gz podman-32db403b5e4fdb96e727e8cda3922d235ad63aa4.tar.bz2 podman-32db403b5e4fdb96e727e8cda3922d235ad63aa4.zip |
Refactor unittest for varlink component
- Allow unittest's to run as normal user
- Refactor tests to use unittest features
- Refactor tests to use fixtures to track resources
- Update test runner script to clean up on failure
Signed-off-by: Jhon Honce <jhonce@redhat.com>
Closes: #683
Approved by: rhatdan
Diffstat (limited to 'test/varlink/test_images.py')
-rw-r--r-- | test/varlink/test_images.py | 68 |
1 files changed, 31 insertions, 37 deletions
diff --git a/test/varlink/test_images.py b/test/varlink/test_images.py index ef1ab1088..3c53f164e 100644 --- a/test/varlink/test_images.py +++ b/test/varlink/test_images.py @@ -1,71 +1,65 @@ import unittest -from varlink import (Client, VarlinkError) +from varlink import VarlinkError -address = "unix:/run/podman/io.projectatomic.podman" -client = Client(address=address) +from podman_testcase import PodmanTestCase +MethodNotImplemented = 'org.varlink.service.MethodNotImplemented' -def runErrorTest(tfunc): - try: - tfunc() - except VarlinkError as e: - return e.error() == "org.varlink.service.MethodNotImplemented" - return False - -class ImagesAPI(unittest.TestCase): +class TestImagesAPI(PodmanTestCase): def test_ListImages(self): - podman = client.open("io.projectatomic.podman") - self.assertTrue(runErrorTest(podman.ListImages)) + with self.assertRaisesRegex(VarlinkError, MethodNotImplemented): + self.podman.ListImages() def test_BuildImage(self): - podman = client.open("io.projectatomic.podman") - self.assertTrue(runErrorTest(podman.BuildImage)) + with self.assertRaisesRegex(VarlinkError, MethodNotImplemented): + self.podman.BuildImage() def test_CreateImage(self): - podman = client.open("io.projectatomic.podman") - self.assertTrue(runErrorTest(podman.CreateImage)) + with self.assertRaisesRegex(VarlinkError, MethodNotImplemented): + self.podman.CreateImage() def test_InspectImage(self): - podman = client.open("io.projectatomic.podman") - self.assertTrue(runErrorTest(podman.InspectImage)) + with self.assertRaisesRegex(VarlinkError, MethodNotImplemented): + self.podman.InspectImage() def test_HistoryImage(self): - podman = client.open("io.projectatomic.podman") - self.assertTrue(runErrorTest(podman.HistoryImage)) + with self.assertRaisesRegex(VarlinkError, MethodNotImplemented): + self.podman.HistoryImage() def test_PushImage(self): - podman = client.open("io.projectatomic.podman") - self.assertTrue(runErrorTest(podman.PushImage)) + with self.assertRaisesRegex(VarlinkError, MethodNotImplemented): + self.podman.PushImage() def test_TagImage(self): - podman = client.open("io.projectatomic.podman") - self.assertTrue(runErrorTest(podman.TagImage)) + with self.assertRaisesRegex(VarlinkError, MethodNotImplemented): + self.podman.TagImage() def test_RemoveImage(self): - podman = client.open("io.projectatomic.podman") - self.assertTrue(runErrorTest(podman.TagImage)) + with self.assertRaisesRegex(VarlinkError, MethodNotImplemented): + self.podman.TagImage() def test_SearchImage(self): - podman = client.open("io.projectatomic.podman") - self.assertTrue(runErrorTest(podman.SearchImage)) + with self.assertRaisesRegex(VarlinkError, MethodNotImplemented): + self.podman.SearchImage() def test_DeleteUnusedImages(self): - podman = client.open("io.projectatomic.podman") - self.assertTrue(runErrorTest(podman.DeleteUnusedImages)) + with self.assertRaisesRegex(VarlinkError, MethodNotImplemented): + self.podman.DeleteUnusedImages() def test_CreateFromContainer(self): - podman = client.open("io.projectatomic.podman") - self.assertTrue(runErrorTest(podman.CreateFromContainer)) + with self.assertRaisesRegex(VarlinkError, MethodNotImplemented): + self.podman.CreateFromContainer() def test_ImportImage(self): - podman = client.open("io.projectatomic.podman") - self.assertTrue(runErrorTest(podman.ImportImage)) + with self.assertRaisesRegex(VarlinkError, MethodNotImplemented): + self.podman.ImportImage() def test_ExportImage(self): - podman = client.open("io.projectatomic.podman") - self.assertTrue(runErrorTest(podman.ExportImage)) + with self.assertRaisesRegex(VarlinkError, MethodNotImplemented): + self.podman.ExportImage() + if __name__ == '__main__': unittest.main() |