'Test add environment variables to a dc'

@mock.patch('oc_env.locate_oc_binary')
@mock.patch('oc_env.Utils.create_tmpfile_copy')
@mock.patch('oc_env.OCEnv._run')
def test_removing_env_vars(self, mock_cmd, mock_tmpfile_copy, mock_oc_binary):

    params = {'state': 'absent', 'namespace': 'default', 'name': 'router', 'kind': 'dc', 'kubeconfig': '/etc/origin/master/admin.kubeconfig', 'debug': False, 'env_vars': {'SOMEKEY': 'SOMEVALUE'}}
    dc_results_before = '{\n                                                "apiVersion":    "v1",\n                                                "kind":    "DeploymentConfig",\n                                                "metadata":    {\n                                                                "creationTimestamp":    "2017-02-02T15:58:49Z",\n                                                                "generation":    8,\n                                                                "labels":    {\n                                                                                "router":    "router"\n                                                                },\n                                                                "name":    "router",\n                                                                "namespace":    "default",\n                                                                "resourceVersion":    "513678"\n                                                },\n                                                "spec":    {\n                                                                "replicas":    2,\n                                                                "selector":    {\n                                                                                "router":    "router"\n                                                                },\n                                                                "template":    {\n                                                                                "metadata":    {\n                                                                                                "creationTimestamp":    null,\n                                                                                                "labels":    {\n                                                                                                                "router":    "router"\n                                                                                                }\n                                                                                },\n                                                                                "spec":    {\n                                                                                                "containers":    [\n                                                                                                                {\n                                                                                                                                "env":    [\n                                                                                                                                                {\n                                                                                                                                                                "name":    "DEFAULT_CERTIFICATE_DIR",\n                                                                                                                                                                "value":    "/etc/pki/tls/private"\n                                                                                                                                                },\n                                                                                                                                                {\n                                                                                                                                                                "name":    "DEFAULT_CERTIFICATE_PATH",\n                                                                                                                                                                "value":    "/etc/pki/tls/private/tls.crt"\n                                                                                                                                                },\n                                                                                                                                                {\n                                                                                                                                                                "name":    "ROUTER_EXTERNAL_HOST_HOSTNAME"\n                                                                                                                                                },\n                                                                                                                                                {\n                                                                                                                                                                "name":    "ROUTER_EXTERNAL_HOST_HTTPS_VSERVER"\n                                                                                                                                                },\n                                                                                                                                                {\n                                                                                                                                                                "name":    "ROUTER_EXTERNAL_HOST_HTTP_VSERVER"\n                                                                                                                                                },\n                                                                                                                                                {\n                                                                                                                                                                "name":    "ROUTER_EXTERNAL_HOST_INSECURE",\n                                                                                                                                                                "value":    "false"\n                                                                                                                                                },\n                                                                                                                                                {\n                                                                                                                                                                "name":    "SOMEKEY",\n                                                                                                                                                                "value":    "SOMEVALUE"\n                                                                                                                                                }\n                                                                                                                                ],\n                                                                                                                                "name":    "router"\n                                                                                                                }\n                                                                                                ]\n                                                                                }\n                                                                },\n                                                                "test":    false,\n                                                                "triggers":    [\n                                                                                {\n                                                                                                "type":    "ConfigChange"\n                                                                                }\n                                                                ]\n                                                }\n                                }'
    mock_cmd.side_effect = [(0, dc_results_before, ''), (0, dc_results_before, ''), (0, '', '')]
    mock_oc_binary.side_effect = ['oc']
    mock_tmpfile_copy.side_effect = ['/tmp/mock_adminkubeconfig']
    results = OCEnv.run_ansible(params, False)
    self.assertTrue(results['changed'])
    self.assertEqual(results['state'], 'absent')
    mock_cmd.assert_has_calls([mock.call(['oc', 'get', 'dc', 'router', '-o', 'json', '-n', 'default'], None)])
