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_containers.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_containers.py')
-rw-r--r-- | test/varlink/test_containers.py | 94 |
1 files changed, 42 insertions, 52 deletions
diff --git a/test/varlink/test_containers.py b/test/varlink/test_containers.py index 651461d55..de2f8bbd7 100644 --- a/test/varlink/test_containers.py +++ b/test/varlink/test_containers.py @@ -1,99 +1,89 @@ 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 ContainersAPI(unittest.TestCase): +class TestContainersAPI(PodmanTestCase): def test_ListContainers(self): - podman = client.open("io.projectatomic.podman") - self.assertTrue(runErrorTest(podman.ListContainers)) + with self.assertRaisesRegex(VarlinkError, MethodNotImplemented): + self.podman.ListContainers() def test_CreateContainer(self): - podman = client.open("io.projectatomic.podman") - self.assertTrue(runErrorTest(podman.CreateContainer)) + with self.assertRaisesRegex(VarlinkError, MethodNotImplemented): + self.podman.CreateContainer() def test_InspecContainer(self): - podman = client.open("io.projectatomic.podman") - self.assertTrue(runErrorTest(podman.InspectContainer)) + with self.assertRaisesRegex(VarlinkError, MethodNotImplemented): + self.podman.InspectContainer() def test_ListContainerProcesses(self): - podman = client.open("io.projectatomic.podman") - self.assertTrue(runErrorTest(podman.ListContainerProcesses)) + with self.assertRaisesRegex(VarlinkError, MethodNotImplemented): + self.podman.ListContainerProcesses() def test_GetContainerLogs(self): - podman = client.open("io.projectatomic.podman") - self.assertTrue(runErrorTest(podman.GetContainerLogs)) + with self.assertRaisesRegex(VarlinkError, MethodNotImplemented): + self.podman.GetContainerLogs() def test_ListContainerChanges(self): - podman = client.open("io.projectatomic.podman") - self.assertTrue(runErrorTest(podman.ListContainerChanges)) + with self.assertRaisesRegex(VarlinkError, MethodNotImplemented): + self.podman.ListContainerChanges() def test_ExportContainer(self): - podman = client.open("io.projectatomic.podman") - self.assertTrue(runErrorTest(podman.ExportContainer)) + with self.assertRaisesRegex(VarlinkError, MethodNotImplemented): + self.podman.ExportContainer() def test_GetContainerStats(self): - podman = client.open("io.projectatomic.podman") - self.assertTrue(runErrorTest(podman.GetContainerStats)) + with self.assertRaisesRegex(VarlinkError, MethodNotImplemented): + self.podman.GetContainerStats() def test_ResizeContainerTty(self): - podman = client.open("io.projectatomic.podman") - self.assertTrue(runErrorTest(podman.ResizeContainerTty)) + with self.assertRaisesRegex(VarlinkError, MethodNotImplemented): + self.podman.ResizeContainerTty() def test_StartContainer(self): - podman = client.open("io.projectatomic.podman") - self.assertTrue(runErrorTest(podman.StartContainer)) + with self.assertRaisesRegex(VarlinkError, MethodNotImplemented): + self.podman.StartContainer() def test_RestartContainer(self): - podman = client.open("io.projectatomic.podman") - self.assertTrue(runErrorTest(podman.RestartContainer)) + with self.assertRaisesRegex(VarlinkError, MethodNotImplemented): + self.podman.RestartContainer() def test_KillContainer(self): - podman = client.open("io.projectatomic.podman") - self.assertTrue(runErrorTest(podman.KillContainer)) + with self.assertRaisesRegex(VarlinkError, MethodNotImplemented): + self.podman.KillContainer() def test_UpdateContainer(self): - podman = client.open("io.projectatomic.podman") - self.assertTrue(runErrorTest(podman.UpdateContainer)) + with self.assertRaisesRegex(VarlinkError, MethodNotImplemented): + self.podman.UpdateContainer() def test_RenameContainer(self): - podman = client.open("io.projectatomic.podman") - self.assertTrue(runErrorTest(podman.RenameContainer)) + with self.assertRaisesRegex(VarlinkError, MethodNotImplemented): + self.podman.RenameContainer() def test_PauseContainer(self): - podman = client.open("io.projectatomic.podman") - self.assertTrue(runErrorTest(podman.PauseContainer)) + with self.assertRaisesRegex(VarlinkError, MethodNotImplemented): + self.podman.PauseContainer() def test_UnpauseContainer(self): - podman = client.open("io.projectatomic.podman") - self.assertTrue(runErrorTest(podman.UnpauseContainer)) + with self.assertRaisesRegex(VarlinkError, MethodNotImplemented): + self.podman.UnpauseContainer() def test_AttachToContainer(self): - podman = client.open("io.projectatomic.podman") - self.assertTrue(runErrorTest(podman.AttachToContainer)) + with self.assertRaisesRegex(VarlinkError, MethodNotImplemented): + self.podman.AttachToContainer() def test_WaitContainer(self): - podman = client.open("io.projectatomic.podman") - self.assertTrue(runErrorTest(podman.WaitContainer)) + with self.assertRaisesRegex(VarlinkError, MethodNotImplemented): + self.podman.WaitContainer() def test_RemoveContainer(self): - podman = client.open("io.projectatomic.podman") - self.assertTrue(runErrorTest(podman.RemoveContainer)) + with self.assertRaisesRegex(VarlinkError, MethodNotImplemented): + self.podman.RemoveContainer() - def test_DeleteContainer(self): - podman = client.open("io.projectatomic.podman") - self.assertTrue(runErrorTest(podman.DeleteContainer)) if __name__ == '__main__': unittest.main() |