Beispiel #1
0
    class MachineDriverBaseTest(unittest.TestCase):
        def __init__(self, machine_name, driver=None, driver_config={}, *args, **kwargs):
            unittest.TestCase.__init__(self, *args, **kwargs)

            self.machine_name = machine_name
            self.driver = driver
            self.driver_config = driver_config

            self.machine = Machine(self.machine_name)
            self.assertFalse(self.machine.exists())
            self.assertEqual(self.machine.create(), self.machine)
            self.assertTrue(self.machine.exists())

        def setUp(self):
            super(BaseTestCases.MachineDriverBaseTest, self).setUp()
            self.machine = Machine(self.machine_name)

        def test_version(self):
            version_info = self.machine.docker_machine_version()
            self.assertIsNotNone(version_info.version_number)
            self.assertIsNotNone(version_info.version_hash)

        def test_active_docker_machine(self):
            self.assertIsNone(Machine.active_docker_machine())

        def test_all_docker_machines(self):
            self.assertEqual(self.machine, Machine.all_docker_machines()[0])

        def test_url(self):
            self.assertEqual(self.machine.url(), self.machine.driver.url)

        def test_status(self):
            self.assertEqual(self.machine.status(), Status.running)

        def test_running(self):
            self.assertTrue(self.machine.running())

        def test_paused(self):
            self.assertFalse(self.machine.paused())

        def test_stopped(self):
            self.assertFalse(self.machine.stopped())

        def test_stopping(self):
            self.assertFalse(self.machine.stopping())

        def test_starting(self):
            self.assertFalse(self.machine.starting())

        def test_error(self):
            self.assertFalse(self.machine.error())

        def test_timeout(self):
            self.assertFalse(self.machine.timeout())

        def test_runningish(self):
            self.assertTrue(self.machine.runningish())

        def test_stoppedish(self):
            self.assertFalse(self.machine.stoppedish())

        def test_errorish(self):
            self.assertFalse(self.machine.errorish())

        def tearDown(self):
            try:
                self.machine.rm(force=True)
            except CLIError:
                pass