'Command execution through Docker'

def test_command_execution(self):

    self.mocks.configure_mock('docker_client', {'exec_create.return_value': {'Id': 'container-foobar'}, 'exec_start.return_value': 'This    is    the    return', 'exec_inspect.return_value': {'ExitCode': 1}})
    build_env = DockerEnvironment(version=self.version, project=self.project, build={'id': DUMMY_BUILD_ID})
    with build_env:
        build_env.run('echo    test', cwd='/tmp')
    self.mocks.docker_client.exec_create.assert_called_with(container='build-123-project-6-pip', cmd="/bin/sh    -c    'cd    /tmp    &&    echo\\    test'", stderr=True, stdout=True)
    self.assertEqual(build_env.commands[0].exit_code, 1)
    self.assertEqual(build_env.commands[0].output, u'This    is    the    return')
    self.assertEqual(build_env.commands[0].error, None)
    self.assertTrue(build_env.failed)
    self.assertFalse(self.mocks.api()(DUMMY_BUILD_ID).put.called)
