'Testing getting a route'

@mock.patch('oc_route.locate_oc_binary')
@mock.patch('oc_route.Utils.create_tmpfile_copy')
@mock.patch('oc_route.OCRoute._run')
def test_list_route(self, mock_cmd, mock_tmpfile_copy, mock_oc_binary):

    params = {'kubeconfig': '/etc/origin/master/admin.kubeconfig', 'state': 'list', 'debug': False, 'name': 'test', 'namespace': 'default', 'tls_termination': 'passthrough', 'dest_cacert_path': None, 'cacert_path': None, 'cert_path': None, 'key_path': None, 'dest_cacert_content': None, 'cacert_content': None, 'cert_content': None, 'key_content': None, 'service_name': 'testservice', 'host': 'test.openshift.com', 'wildcard_policy': None, 'weight': None, 'port': None}
    route_result = '{\n                                                "kind":    "Route",\n                                                "apiVersion":    "v1",\n                                                "metadata":    {\n                                                                "name":    "test",\n                                                                "namespace":    "default",\n                                                                "selfLink":    "/oapi/v1/namespaces/default/routes/test",\n                                                                "uid":    "1b127c67-ecd9-11e6-96eb-0e0d9bdacd26",\n                                                                "resourceVersion":    "439182",\n                                                                "creationTimestamp":    "2017-02-07T01:59:48Z"\n                                                },\n                                                "spec":    {\n                                                                "host":    "test.example",\n                                                                "to":    {\n                                                                                "kind":    "Service",\n                                                                                "name":    "test",\n                                                                                "weight":    100\n                                                                },\n                                                                "port":    {\n                                                                                "targetPort":    8443\n                                                                },\n                                                                "tls":    {\n                                                                                "termination":    "passthrough"\n                                                                },\n                                                                "wildcardPolicy":    "None"\n                                                },\n                                                "status":    {\n                                                                "ingress":    [\n                                                                                {\n                                                                                                "host":    "test.example",\n                                                                                                "routerName":    "router",\n                                                                                                "conditions":    [\n                                                                                                                {\n                                                                                                                                "type":    "Admitted",\n                                                                                                                                "status":    "True",\n                                                                                                                                "lastTransitionTime":    "2017-02-07T01:59:48Z"\n                                                                                                                }\n                                                                                                ],\n                                                                                                "wildcardPolicy":    "None"\n                                                                                }\n                                                                ]\n                                                }\n                                }'
    mock_cmd.side_effect = [(0, route_result, '')]
    mock_oc_binary.side_effect = ['oc']
    mock_tmpfile_copy.side_effect = ['/tmp/mock.kubeconfig']
    results = OCRoute.run_ansible(params, False)
    self.assertFalse(results['changed'])
    self.assertEqual(results['state'], 'list')
    self.assertEqual(results['results'][0]['metadata']['name'], 'test')
    mock_cmd.assert_has_calls([mock.call(['oc', 'get', 'route', 'test', '-o', 'json', '-n', 'default'], None)])
