Ejemplo n.º 1
0
    def test_get_image_no_docker(self):
        '''get_image_command raises an exception if docker is not installed'''
        def mocked_run(args, real_run=subprocess.run, **kw):
            assert_equal(args[0], 'docker')
            args[0] = 'dockerZZZZ'
            return real_run(args, **kw)

        with mock.patch('subprocess.run', side_effect=mocked_run) as run_mock:
            with self.assertRaises(uut.DockerError):
                uut.get_image_command('n/a')
Ejemplo n.º 2
0
    def test__get_image_command__pulls_image_if_missing(self):
        '''get_image_command pulls an image if missing'''
        image = 'busybox:latest'

        # First remove the image
        subprocess.call(['docker', 'rmi', image])

        # Now try to get the image's Command
        result = uut.get_image_command(image)

        # Should return a non-empty string
        self.assertTrue(result)
Ejemplo n.º 3
0
    def test__get_image_command__pulls_image_if_missing(self):
        """get_image_command pulls an image if missing"""
        image = "busybox:latest"

        # First remove the image
        subprocess.call(["docker", "rmi", image])

        # Now try to get the image's Command
        result = uut.get_image_command(image)

        # Should return a non-empty string
        self.assertTrue(result)
Ejemplo n.º 4
0
 def test_get_image_command_success(self):
     '''get_image_command works'''
     assert_true(uut.get_image_command('debian:8.2'))
Ejemplo n.º 5
0
 def test_get_image_command_success(self):
     """get_image_command works"""
     assert_true(uut.get_image_command("debian:8.2"))
Ejemplo n.º 6
0
 def test_get_image_command_bad_image(self):
     '''get_image_command raises an exception for a bad image name'''
     with self.assertRaises(uut.DockerError):
         uut.get_image_command('nosuchimageZZZZZZZZ')