'Testing a process with no create'

@mock.patch('oc_process.Utils.create_tmpfile_copy')
@mock.patch('oc_process.OCProcess._run')
def test_process_no_create(self, mock_cmd, mock_tmpfile_copy):

    params = {'template_name': 'mysql-ephermeral', 'namespace': 'test', 'content': None, 'state': 'present', 'reconcile': False, 'create': False, 'params': {'NAMESPACE': 'test', 'DATABASE_SERVICE_NAME': 'testdb'}, 'kubeconfig': '/etc/origin/master/admin.kubeconfig', 'debug': False}
    mysqlproc = '{\n                "kind":    "List",\n                "apiVersion":    "v1",\n                "metadata":    {},\n                "items":    [\n                                {\n                                                "apiVersion":    "v1",\n                                                "kind":    "Service",\n                                                "metadata":    {\n                                                                "creationTimestamp":    null,\n                                                                "labels":    {\n                                                                                "template":    "mysql-ephemeral-template"\n                                                                },\n                                                                "name":    "testdb"\n                                                },\n                                                "spec":    {\n                                                                "ports":    [\n                                                                                {\n                                                                                                "name":    "mysql",\n                                                                                                "nodePort":    0,\n                                                                                                "port":    3306,\n                                                                                                "protocol":    "TCP",\n                                                                                                "targetPort":    3306\n                                                                                }\n                                                                ],\n                                                                "selector":    {\n                                                                                "name":    "testdb"\n                                                                },\n                                                                "sessionAffinity":    "None",\n                                                                "type":    "ClusterIP"\n                                                },\n                                                "status":    {\n                                                                "loadBalancer":    {}\n                                                }\n                                },\n                                {\n                                                "apiVersion":    "v1",\n                                                "kind":    "DeploymentConfig",\n                                                "metadata":    {\n                                                                "creationTimestamp":    null,\n                                                                "labels":    {\n                                                                                "template":    "mysql-ephemeral-template"\n                                                                },\n                                                                "name":    "testdb"\n                                                },\n                                                "spec":    {\n                                                                "replicas":    1,\n                                                                "selector":    {\n                                                                                "name":    "testdb"\n                                                                },\n                                                                "strategy":    {\n                                                                                "type":    "Recreate"\n                                                                },\n                                                                "template":    {\n                                                                                "metadata":    {\n                                                                                                "creationTimestamp":    null,\n                                                                                                "labels":    {\n                                                                                                                "name":    "testdb"\n                                                                                                }\n                                                                                },\n                                                                                "spec":    {\n                                                                                                "containers":    [\n                                                                                                                {\n                                                                                                                                "capabilities":    {},\n                                                                                                                                "env":    [\n                                                                                                                                                {\n                                                                                                                                                                "name":    "MYSQL_USER",\n                                                                                                                                                                "value":    "userHJJ"\n                                                                                                                                                },\n                                                                                                                                                {\n                                                                                                                                                                "name":    "MYSQL_PASSWORD",\n                                                                                                                                                                "value":    "GITOAduAMaV6k688"\n                                                                                                                                                },\n                                                                                                                                                {\n                                                                                                                                                                "name":    "MYSQL_DATABASE",\n                                                                                                                                                                "value":    "sampledb"\n                                                                                                                                                }\n                                                                                                                                ],\n                                                                                                                                "image":    "    ",\n                                                                                                                                "imagePullPolicy":    "IfNotPresent",\n                                                                                                                                "livenessProbe":    {\n                                                                                                                                                "initialDelaySeconds":    30,\n                                                                                                                                                "tcpSocket":    {\n                                                                                                                                                                "port":    3306\n                                                                                                                                                },\n                                                                                                                                                "timeoutSeconds":    1\n                                                                                                                                },\n                                                                                                                                "name":    "mysql",\n                                                                                                                                "ports":    [\n                                                                                                                                                {\n                                                                                                                                                                "containerPort":    3306,\n                                                                                                                                                                "protocol":    "TCP"\n                                                                                                                                                }\n                                                                                                                                ],\n                                                                                                                                "readinessProbe":    {\n                                                                                                                                                "exec":    {\n                                                                                                                                                                "command":    [\n                                                                                                                                                                                "/bin/sh",\n                                                                                                                                                                                "-i",\n                                                                                                                                                                                "-c",\n                                                                                                                                                                                "MYSQL_PWD=$MYSQL_PASSWORD    mysql    -h    127.0.0.1    -u    $MYSQL_USER    -D    $MYSQL_DATABASE    -e    \'SELECT    1\'"\n                                                                                                                                                                ]\n                                                                                                                                                },\n                                                                                                                                                "initialDelaySeconds":    5,\n                                                                                                                                                "timeoutSeconds":    1\n                                                                                                                                },\n                                                                                                                                "resources":    {\n                                                                                                                                                "limits":    {\n                                                                                                                                                                "memory":    "512Mi"\n                                                                                                                                                }\n                                                                                                                                },\n                                                                                                                                "securityContext":    {\n                                                                                                                                                "capabilities":    {},\n                                                                                                                                                "privileged":    false\n                                                                                                                                },\n                                                                                                                                "terminationMessagePath":    "/dev/termination-log",\n                                                                                                                                "volumeMounts":    [\n                                                                                                                                                {\n                                                                                                                                                                "mountPath":    "/var/lib/mysql/data",\n                                                                                                                                                                "name":    "testdb-data"\n                                                                                                                                                }\n                                                                                                                                ]\n                                                                                                                }\n                                                                                                ],\n                                                                                                "dnsPolicy":    "ClusterFirst",\n                                                                                                "restartPolicy":    "Always",\n                                                                                                "volumes":    [\n                                                                                                                {\n                                                                                                                                "emptyDir":    {\n                                                                                                                                                "medium":    ""\n                                                                                                                                },\n                                                                                                                                "name":    "testdb-data"\n                                                                                                                }\n                                                                                                ]\n                                                                                }\n                                                                },\n                                                                "triggers":    [\n                                                                                {\n                                                                                                "imageChangeParams":    {\n                                                                                                                "automatic":    true,\n                                                                                                                "containerNames":    [\n                                                                                                                                "mysql"\n                                                                                                                ],\n                                                                                                                "from":    {\n                                                                                                                                "kind":    "ImageStreamTag",\n                                                                                                                                "name":    "mysql:5.6",\n                                                                                                                                "namespace":    "test"\n                                                                                                                },\n                                                                                                                "lastTriggeredImage":    ""\n                                                                                                },\n                                                                                                "type":    "ImageChange"\n                                                                                },\n                                                                                {\n                                                                                                "type":    "ConfigChange"\n                                                                                }\n                                                                ]\n                                                }\n                                }\n                ]\n}'
    mock_cmd.side_effect = [(0, OCProcessTest.mysql, ''), (0, OCProcessTest.mysql, ''), (0, mysqlproc, '')]
    mock_tmpfile_copy.side_effect = ['/tmp/mock_kubeconfig']
    results = OCProcess.run_ansible(params, False)
    self.assertFalse(results['changed'])
    self.assertEqual(results['results']['results']['items'][0]['metadata']['name'], 'testdb')
