'Testing a create'

@mock.patch('oc_adm_router.locate_oc_binary')
@mock.patch('oc_adm_router.Utils._write')
@mock.patch('oc_adm_router.Utils.create_tmpfile_copy')
@mock.patch('oc_adm_router.Router._run')
def test_state_present(self, mock_cmd, mock_tmpfile_copy, mock_write, mock_oc_binary):

    params = {'state': 'present', 'debug': False, 'namespace': 'default', 'name': 'router', 'default_cert': None, 'cert_file': None, 'key_file': None, 'cacert_file': None, 'labels': {'router': 'router', 'another-label': 'val'}, 'ports': ['80:80', '443:443'], 'images': None, 'latest_images': None, 'clusterip': None, 'portalip': None, 'session_affinity': None, 'service_type': None, 'kubeconfig': '/etc/origin/master/admin.kubeconfig', 'replicas': 2, 'selector': 'type=infra', 'service_account': 'router', 'router_type': None, 'host_network': None, 'external_host': None, 'external_host_vserver': None, 'external_host_insecure': False, 'external_host_partition_path': None, 'external_host_username': None, 'external_host_password': None, 'external_host_private_key': None, 'expose_metrics': False, 'metrics_image': None, 'stats_user': None, 'stats_password': None, 'stats_port': 1936, 'edits': []}
    mock_cmd.side_effect = [(1, '', 'Error    from    server    (NotFound):    deploymentconfigs    "router"    not    found'), (1, '', 'Error    from    server    (NotFound):    service    "router"    not    found'), (1, '', 'Error    from    server    (NotFound):    serviceaccount    "router"    not    found'), (1, '', 'Error    from    server    (NotFound):    secret    "router-certs"    not    found'), (1, '', 'Error    from    server    (NotFound):    clsuterrolebinding    "router-router-role"    not    found'), (0, RouterTest.dry_run, ''), (0, '', ''), (0, '', ''), (0, '', ''), (0, '', ''), (0, '', '')]
    mock_tmpfile_copy.side_effect = ['/tmp/mocked_kubeconfig']
    mock_oc_binary.side_effect = ['oc']
    results = Router.run_ansible(params, False)
    self.assertTrue(results['changed'])
    for result in results['results']['results']:
        self.assertEqual(result['returncode'], 0)
    mock_cmd.assert_has_calls([mock.call(['oc', 'get', 'dc', 'router', '-o', 'json', '-n', 'default'], None), mock.call(['oc', 'get', 'svc', 'router', '-o', 'json', '-n', 'default'], None), mock.call(['oc', 'get', 'sa', 'router', '-o', 'json', '-n', 'default'], None), mock.call(['oc', 'get', 'secret', 'router-certs', '-o', 'json', '-n', 'default'], None), mock.call(['oc', 'get', 'clusterrolebinding', 'router-router-role', '-o', 'json', '-n', 'default'], None), mock.call(['oc', 'adm', 'router', 'router', '--expose-metrics=False', '--external-host-insecure=False', '--labels=another-label=val,router=router', '--ports=80:80,443:443', '--replicas=2', '--selector=type=infra', '--service-account=router', '--stats-port=1936', '--dry-run=True', '-o', 'json', '-n', 'default'], None), mock.call(['oc', 'create', '-f', mock.ANY, '-n', 'default'], None), mock.call(['oc', 'create', '-f', mock.ANY, '-n', 'default'], None), mock.call(['oc', 'create', '-f', mock.ANY, '-n', 'default'], None), mock.call(['oc', 'create', '-f', mock.ANY, '-n', 'default'], None)])
