'Testing a label list'

@mock.patch('oc_label.Utils.create_tmpfile_copy')
@mock.patch('oc_label.OCLabel._run')
def test_state_present(self, mock_cmd, mock_tmpfile_copy):

    params = {'name': 'default', 'namespace': 'default', 'labels': [{'key': 'awesomens', 'value': 'testinglabel'}, {'key': 'storage_pv_quota', 'value': 'False'}], 'state': 'present', 'kind': 'namespace', 'selector': None, 'kubeconfig': '/etc/origin/master/admin.kubeconfig', 'debug': False}
    ns = '{\n                                                "kind":    "Namespace",\n                                                "apiVersion":    "v1",\n                                                "metadata":    {\n                                                                "name":    "default",\n                                                                "selfLink":    "/api/v1/namespaces/default",\n                                                                "uid":    "c45b9547-e3d3-11e6-ba9c-0eece8f2ce22",\n                                                                "resourceVersion":    "403024",\n                                                                "creationTimestamp":    "2017-01-26T14:28:55Z",\n                                                                "labels":    {\n                                                                                "storage_pv_quota":    "False"\n                                                                },\n                                                                "annotations":    {\n                                                                                "openshift.io/node-selector":    "",\n                                                                                "openshift.io/sa.initialized-roles":    "true",\n                                                                                "openshift.io/sa.scc.mcs":    "s0:c1,c0",\n                                                                                "openshift.io/sa.scc.supplemental-groups":    "1000000000/10000",\n                                                                                "openshift.io/sa.scc.uid-range":    "1000000000/10000"\n                                                                }\n                                                },\n                                                "spec":    {\n                                                                "finalizers":    [\n                                                                                "kubernetes",\n                                                                                "openshift.io/origin"\n                                                                ]\n                                                },\n                                                "status":    {\n                                                                "phase":    "Active"\n                                                }\n                                }'
    ns1 = '{\n                                                "kind":    "Namespace",\n                                                "apiVersion":    "v1",\n                                                "metadata":    {\n                                                                "name":    "default",\n                                                                "selfLink":    "/api/v1/namespaces/default",\n                                                                "uid":    "c45b9547-e3d3-11e6-ba9c-0eece8f2ce22",\n                                                                "resourceVersion":    "403024",\n                                                                "creationTimestamp":    "2017-01-26T14:28:55Z",\n                                                                "labels":    {\n                                                                                "storage_pv_quota":    "False",\n                                                                                "awesomens":    "testinglabel"\n                                                                },\n                                                                "annotations":    {\n                                                                                "openshift.io/node-selector":    "",\n                                                                                "openshift.io/sa.initialized-roles":    "true",\n                                                                                "openshift.io/sa.scc.mcs":    "s0:c1,c0",\n                                                                                "openshift.io/sa.scc.supplemental-groups":    "1000000000/10000",\n                                                                                "openshift.io/sa.scc.uid-range":    "1000000000/10000"\n                                                                }\n                                                },\n                                                "spec":    {\n                                                                "finalizers":    [\n                                                                                "kubernetes",\n                                                                                "openshift.io/origin"\n                                                                ]\n                                                },\n                                                "status":    {\n                                                                "phase":    "Active"\n                                                }\n                                }'
    mock_cmd.side_effect = [(0, ns, ''), (0, '', ''), (0, ns1, '')]
    mock_tmpfile_copy.side_effect = ['/tmp/mocked_kubeconfig']
    results = OCLabel.run_ansible(params, False)
    self.assertTrue(results['changed'])
    self.assertTrue((results['results']['results']['labels'][0] == {'storage_pv_quota': 'False', 'awesomens': 'testinglabel'}))
