'Testing when we fail to get objects'

@mock.patch('oc_objectvalidator.locate_oc_binary')
@mock.patch('oc_objectvalidator.Utils.create_tmpfile_copy')
@mock.patch('oc_objectvalidator.OCObjectValidator._run')
def test_error_code(self, mock_cmd, mock_tmpfile_copy, mock_oc_binary):

    params = {'kubeconfig': '/etc/origin/master/admin.kubeconfig'}
    mock_cmd.side_effect = [(1, '', 'Error.')]
    mock_tmpfile_copy.side_effect = ['/tmp/mocked_kubeconfig']
    mock_oc_binary.side_effect = ['oc']
    error_results = {'returncode': 1, 'stderr': 'Error.', 'stdout': '', 'cmd': 'oc    get    hostsubnet    -o    json    -n    default', 'results': [{}]}
    results = OCObjectValidator.run_ansible(params)
    self.assertTrue(results['failed'])
    self.assertEqual(results['msg'], 'Failed    to    GET    hostsubnet.')
    self.assertEqual(results['state'], 'list')
    self.assertEqual(results['results'], error_results)
    mock_cmd.assert_has_calls([mock.call(['oc', 'get', 'hostsubnet', '-o', 'json', '-n', 'default'], None)])
