desc stringlengths 3 26.7k | decl stringlengths 11 7.89k | bodies stringlengths 8 553k |
|---|---|---|
'Testing binary lookup in ~/bin'
| @unittest.skipIf(six.PY3, 'py2 test only')
@mock.patch('os.path.exists')
@mock.patch('os.environ.get')
def test_binary_lookup_in_home(self, mock_env_get, mock_path_exists):
| oc_bin = os.path.expanduser('~/bin/oc')
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_path_exists.side_effect = (lambda f: (f == oc_bin))
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing binary lookup fallback'
| @unittest.skipIf(six.PY2, 'py3 test only')
@mock.patch('shutil.which')
@mock.patch('os.environ.get')
def test_binary_lookup_fallback_py3(self, mock_env_get, mock_shutil_which):
| mock_env_get.side_effect = (lambda _v, _d: '')
mock_shutil_which.side_effect = (lambda _f, path=None: None)
self.assertEqual(locate_oc_binary(), 'oc')
|
'Testing binary lookup in path'
| @unittest.skipIf(six.PY2, 'py3 test only')
@mock.patch('shutil.which')
@mock.patch('os.environ.get')
def test_binary_lookup_in_path_py3(self, mock_env_get, mock_shutil_which):
| oc_bin = '/usr/bin/oc'
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_shutil_which.side_effect = (lambda _f, path=None: oc_bin)
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing binary lookup in /usr/local/bin'
| @unittest.skipIf(six.PY2, 'py3 test only')
@mock.patch('shutil.which')
@mock.patch('os.environ.get')
def test_binary_lookup_in_usr_local_py3(self, mock_env_get, mock_shutil_which):
| oc_bin = '/usr/local/bin/oc'
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_shutil_which.side_effect = (lambda _f, path=None: oc_bin)
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing binary lookup in ~/bin'
| @unittest.skipIf(six.PY2, 'py3 test only')
@mock.patch('shutil.which')
@mock.patch('os.environ.get')
def test_binary_lookup_in_home_py3(self, mock_env_get, mock_shutil_which):
| oc_bin = os.path.expanduser('~/bin/oc')
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_shutil_which.side_effect = (lambda _f, path=None: oc_bin)
self.assertEqual(locate_oc_binary(), oc_bin)
|
'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_con... |
'Testing getting a route'
| @mock.patch('oc_route.locate_oc_binary')
@mock.patch('oc_route.Utils.create_tmpfile_copy')
@mock.patch('oc_route.Yedit._write')
@mock.patch('oc_route.OCRoute._run')
def test_create_route(self, mock_cmd, mock_write, mock_tmpfile_copy, mock_oc_binary):
| params = {'kubeconfig': '/etc/origin/master/admin.kubeconfig', 'state': 'present', 'debug': False, 'name': 'test', 'namespace': 'default', 'tls_termination': 'edge', 'dest_cacert_path': None, 'cacert_path': None, 'cert_path': None, 'key_path': None, 'dest_cacert_content': None, 'cacert_content': 'testing', 'cert_co... |
'Testing binary lookup fallback'
| @unittest.skipIf(six.PY3, 'py2 test only')
@mock.patch('os.path.exists')
@mock.patch('os.environ.get')
def test_binary_lookup_fallback(self, mock_env_get, mock_path_exists):
| mock_env_get.side_effect = (lambda _v, _d: '')
mock_path_exists.side_effect = (lambda _: False)
self.assertEqual(locate_oc_binary(), 'oc')
|
'Testing binary lookup in path'
| @unittest.skipIf(six.PY3, 'py2 test only')
@mock.patch('os.path.exists')
@mock.patch('os.environ.get')
def test_binary_lookup_in_path(self, mock_env_get, mock_path_exists):
| oc_bin = '/usr/bin/oc'
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_path_exists.side_effect = (lambda f: (f == oc_bin))
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing binary lookup in /usr/local/bin'
| @unittest.skipIf(six.PY3, 'py2 test only')
@mock.patch('os.path.exists')
@mock.patch('os.environ.get')
def test_binary_lookup_in_usr_local(self, mock_env_get, mock_path_exists):
| oc_bin = '/usr/local/bin/oc'
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_path_exists.side_effect = (lambda f: (f == oc_bin))
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing binary lookup in ~/bin'
| @unittest.skipIf(six.PY3, 'py2 test only')
@mock.patch('os.path.exists')
@mock.patch('os.environ.get')
def test_binary_lookup_in_home(self, mock_env_get, mock_path_exists):
| oc_bin = os.path.expanduser('~/bin/oc')
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_path_exists.side_effect = (lambda f: (f == oc_bin))
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing binary lookup fallback'
| @unittest.skipIf(six.PY2, 'py3 test only')
@mock.patch('shutil.which')
@mock.patch('os.environ.get')
def test_binary_lookup_fallback_py3(self, mock_env_get, mock_shutil_which):
| mock_env_get.side_effect = (lambda _v, _d: '')
mock_shutil_which.side_effect = (lambda _f, path=None: None)
self.assertEqual(locate_oc_binary(), 'oc')
|
'Testing binary lookup in path'
| @unittest.skipIf(six.PY2, 'py3 test only')
@mock.patch('shutil.which')
@mock.patch('os.environ.get')
def test_binary_lookup_in_path_py3(self, mock_env_get, mock_shutil_which):
| oc_bin = '/usr/bin/oc'
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_shutil_which.side_effect = (lambda _f, path=None: oc_bin)
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing binary lookup in /usr/local/bin'
| @unittest.skipIf(six.PY2, 'py3 test only')
@mock.patch('shutil.which')
@mock.patch('os.environ.get')
def test_binary_lookup_in_usr_local_py3(self, mock_env_get, mock_shutil_which):
| oc_bin = '/usr/local/bin/oc'
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_shutil_which.side_effect = (lambda _f, path=None: oc_bin)
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing binary lookup in ~/bin'
| @unittest.skipIf(six.PY2, 'py3 test only')
@mock.patch('shutil.which')
@mock.patch('os.environ.get')
def test_binary_lookup_in_home_py3(self, mock_env_get, mock_shutil_which):
| oc_bin = os.path.expanduser('~/bin/oc')
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_shutil_which.side_effect = (lambda _f, path=None: oc_bin)
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing a pvc create'
| @mock.patch('oc_pvc.Utils.create_tmpfile_copy')
@mock.patch('oc_pvc.OCPVC._run')
def test_create_pvc(self, mock_run, mock_tmpfile_copy):
| params = copy.deepcopy(OCPVCTest.params)
pvc = '{"kind": "PersistentVolumeClaim",\n "apiVersion": "v1",\n "metadata": {\n ... |
'Testing a pvc create'
| @mock.patch('oc_pvc.Utils.create_tmpfile_copy')
@mock.patch('oc_pvc.OCPVC._run')
def test_update_pvc(self, mock_run, mock_tmpfile_copy):
| params = copy.deepcopy(OCPVCTest.params)
params['access_modes'] = 'ReadWriteMany'
pvc = '{"kind": "PersistentVolumeClaim",\n "apiVersion": "v1",\n "metadata": {\n ... |
'Testing a pvc create'
| @mock.patch('oc_pvc.Utils.create_tmpfile_copy')
@mock.patch('oc_pvc.OCPVC._run')
def test_delete_pvc(self, mock_run, mock_tmpfile_copy):
| params = copy.deepcopy(OCPVCTest.params)
params['state'] = 'absent'
pvc = '{"kind": "PersistentVolumeClaim",\n "apiVersion": "v1",\n "metadata": {\n ... |
'Testing binary lookup fallback'
| @unittest.skipIf(six.PY3, 'py2 test only')
@mock.patch('os.path.exists')
@mock.patch('os.environ.get')
def test_binary_lookup_fallback(self, mock_env_get, mock_path_exists):
| mock_env_get.side_effect = (lambda _v, _d: '')
mock_path_exists.side_effect = (lambda _: False)
self.assertEqual(locate_oc_binary(), 'oc')
|
'Testing binary lookup in path'
| @unittest.skipIf(six.PY3, 'py2 test only')
@mock.patch('os.path.exists')
@mock.patch('os.environ.get')
def test_binary_lookup_in_path(self, mock_env_get, mock_path_exists):
| oc_bin = '/usr/bin/oc'
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_path_exists.side_effect = (lambda f: (f == oc_bin))
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing binary lookup in /usr/local/bin'
| @unittest.skipIf(six.PY3, 'py2 test only')
@mock.patch('os.path.exists')
@mock.patch('os.environ.get')
def test_binary_lookup_in_usr_local(self, mock_env_get, mock_path_exists):
| oc_bin = '/usr/local/bin/oc'
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_path_exists.side_effect = (lambda f: (f == oc_bin))
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing binary lookup in ~/bin'
| @unittest.skipIf(six.PY3, 'py2 test only')
@mock.patch('os.path.exists')
@mock.patch('os.environ.get')
def test_binary_lookup_in_home(self, mock_env_get, mock_path_exists):
| oc_bin = os.path.expanduser('~/bin/oc')
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_path_exists.side_effect = (lambda f: (f == oc_bin))
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing binary lookup fallback'
| @unittest.skipIf(six.PY2, 'py3 test only')
@mock.patch('shutil.which')
@mock.patch('os.environ.get')
def test_binary_lookup_fallback_py3(self, mock_env_get, mock_shutil_which):
| mock_env_get.side_effect = (lambda _v, _d: '')
mock_shutil_which.side_effect = (lambda _f, path=None: None)
self.assertEqual(locate_oc_binary(), 'oc')
|
'Testing binary lookup in path'
| @unittest.skipIf(six.PY2, 'py3 test only')
@mock.patch('shutil.which')
@mock.patch('os.environ.get')
def test_binary_lookup_in_path_py3(self, mock_env_get, mock_shutil_which):
| oc_bin = '/usr/bin/oc'
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_shutil_which.side_effect = (lambda _f, path=None: oc_bin)
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing binary lookup in /usr/local/bin'
| @unittest.skipIf(six.PY2, 'py3 test only')
@mock.patch('shutil.which')
@mock.patch('os.environ.get')
def test_binary_lookup_in_usr_local_py3(self, mock_env_get, mock_shutil_which):
| oc_bin = '/usr/local/bin/oc'
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_shutil_which.side_effect = (lambda _f, path=None: oc_bin)
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing binary lookup in ~/bin'
| @unittest.skipIf(six.PY2, 'py3 test only')
@mock.patch('shutil.which')
@mock.patch('os.environ.get')
def test_binary_lookup_in_home_py3(self, mock_env_get, mock_shutil_which):
| oc_bin = os.path.expanduser('~/bin/oc')
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_shutil_which.side_effect = (lambda _f, path=None: oc_bin)
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing a configmap create'
| @mock.patch('oc_configmap.Utils._write')
@mock.patch('oc_configmap.Utils.create_tmpfile_copy')
@mock.patch('oc_configmap.OCConfigMap._run')
def test_create_configmap(self, mock_run, mock_tmpfile_copy, mock_write):
| return
params = copy.deepcopy(OCConfigMapTest.params)
params['from_file'] = {'test': '/root/file'}
params['from_literal'] = {'foo': 'bar'}
configmap = '{\n "apiVersion": "v1",\n ... |
'Testing a configmap create'
| @mock.patch('oc_configmap.Utils._write')
@mock.patch('oc_configmap.Utils.create_tmpfile_copy')
@mock.patch('oc_configmap.OCConfigMap._run')
def test_update_configmap(self, mock_run, mock_tmpfile_copy, mock_write):
| params = copy.deepcopy(OCConfigMapTest.params)
params['from_file'] = {'test': '/root/file'}
params['from_literal'] = {'foo': 'bar', 'deployment_type': 'online'}
configmap = '{\n "apiVersion": "v1",\n ... |
'Testing binary lookup fallback'
| @unittest.skipIf(six.PY3, 'py2 test only')
@mock.patch('os.path.exists')
@mock.patch('os.environ.get')
def test_binary_lookup_fallback(self, mock_env_get, mock_path_exists):
| mock_env_get.side_effect = (lambda _v, _d: '')
mock_path_exists.side_effect = (lambda _: False)
self.assertEqual(locate_oc_binary(), 'oc')
|
'Testing binary lookup in path'
| @unittest.skipIf(six.PY3, 'py2 test only')
@mock.patch('os.path.exists')
@mock.patch('os.environ.get')
def test_binary_lookup_in_path(self, mock_env_get, mock_path_exists):
| oc_bin = '/usr/bin/oc'
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_path_exists.side_effect = (lambda f: (f == oc_bin))
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing binary lookup in /usr/local/bin'
| @unittest.skipIf(six.PY3, 'py2 test only')
@mock.patch('os.path.exists')
@mock.patch('os.environ.get')
def test_binary_lookup_in_usr_local(self, mock_env_get, mock_path_exists):
| oc_bin = '/usr/local/bin/oc'
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_path_exists.side_effect = (lambda f: (f == oc_bin))
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing binary lookup in ~/bin'
| @unittest.skipIf(six.PY3, 'py2 test only')
@mock.patch('os.path.exists')
@mock.patch('os.environ.get')
def test_binary_lookup_in_home(self, mock_env_get, mock_path_exists):
| oc_bin = os.path.expanduser('~/bin/oc')
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_path_exists.side_effect = (lambda f: (f == oc_bin))
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing binary lookup fallback'
| @unittest.skipIf(six.PY2, 'py3 test only')
@mock.patch('shutil.which')
@mock.patch('os.environ.get')
def test_binary_lookup_fallback_py3(self, mock_env_get, mock_shutil_which):
| mock_env_get.side_effect = (lambda _v, _d: '')
mock_shutil_which.side_effect = (lambda _f, path=None: None)
self.assertEqual(locate_oc_binary(), 'oc')
|
'Testing binary lookup in path'
| @unittest.skipIf(six.PY2, 'py3 test only')
@mock.patch('shutil.which')
@mock.patch('os.environ.get')
def test_binary_lookup_in_path_py3(self, mock_env_get, mock_shutil_which):
| oc_bin = '/usr/bin/oc'
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_shutil_which.side_effect = (lambda _f, path=None: oc_bin)
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing binary lookup in /usr/local/bin'
| @unittest.skipIf(six.PY2, 'py3 test only')
@mock.patch('shutil.which')
@mock.patch('os.environ.get')
def test_binary_lookup_in_usr_local_py3(self, mock_env_get, mock_shutil_which):
| oc_bin = '/usr/local/bin/oc'
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_shutil_which.side_effect = (lambda _f, path=None: oc_bin)
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing binary lookup in ~/bin'
| @unittest.skipIf(six.PY2, 'py3 test only')
@mock.patch('shutil.which')
@mock.patch('os.environ.get')
def test_binary_lookup_in_home_py3(self, mock_env_get, mock_shutil_which):
| oc_bin = os.path.expanduser('~/bin/oc')
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_shutil_which.side_effect = (lambda _f, path=None: oc_bin)
self.assertEqual(locate_oc_binary(), oc_bin)
|
'setup method will create a file and set to known configuration'
| def setUp(self):
| pass
|
'Testing a user list'
| @mock.patch('oc_user.Utils.create_tmpfile_copy')
@mock.patch('oc_user.OCUser._run')
def test_state_list(self, mock_cmd, mock_tmpfile_copy):
| params = {'username': 'testuser@email.com', 'state': 'list', 'kubeconfig': '/etc/origin/master/admin.kubeconfig', 'full_name': None, 'groups': [], 'debug': False}
user = '{\n "kind": "User",\n ... |
'Testing a user list'
| @mock.patch('oc_user.Utils.create_tmpfile_copy')
@mock.patch('oc_user.OCUser._run')
def test_state_present(self, mock_cmd, mock_tmpfile_copy):
| params = {'username': 'testuser@email.com', 'state': 'present', 'kubeconfig': '/etc/origin/master/admin.kubeconfig', 'full_name': 'Test User', 'groups': [], 'debug': False}
created_user = '{\n "kind": "U... |
'TearDown method'
| def tearDown(self):
| pass
|
'Testing adding a secret to a service account'
| @mock.patch('oc_serviceaccount_secret.locate_oc_binary')
@mock.patch('oc_serviceaccount_secret.Utils.create_tmpfile_copy')
@mock.patch('oc_serviceaccount_secret.Yedit._write')
@mock.patch('oc_serviceaccount_secret.OCServiceAccountSecret._run')
def test_adding_a_secret_to_a_serviceaccount(self, mock_cmd, mock_write, moc... | params = {'state': 'present', 'namespace': 'default', 'secret': 'newsecret', 'service_account': 'builder', 'kubeconfig': '/etc/origin/master/admin.kubeconfig', 'debug': False}
oc_get_sa_before = '{\n "apiVersion": "v1",\n ... |
'Testing removing a secret to a service account'
| @mock.patch('oc_serviceaccount_secret.locate_oc_binary')
@mock.patch('oc_serviceaccount_secret.Utils.create_tmpfile_copy')
@mock.patch('oc_serviceaccount_secret.Yedit._write')
@mock.patch('oc_serviceaccount_secret.OCServiceAccountSecret._run')
def test_removing_a_secret_to_a_serviceaccount(self, mock_cmd, mock_write, m... | params = {'state': 'absent', 'namespace': 'default', 'secret': 'newsecret', 'service_account': 'builder', 'kubeconfig': '/etc/origin/master/admin.kubeconfig', 'debug': False}
oc_get_sa_before = '{\n "apiVersion": "v1",\n ... |
'Testing binary lookup fallback'
| @unittest.skipIf(six.PY3, 'py2 test only')
@mock.patch('os.path.exists')
@mock.patch('os.environ.get')
def test_binary_lookup_fallback(self, mock_env_get, mock_path_exists):
| mock_env_get.side_effect = (lambda _v, _d: '')
mock_path_exists.side_effect = (lambda _: False)
self.assertEqual(locate_oc_binary(), 'oc')
|
'Testing binary lookup in path'
| @unittest.skipIf(six.PY3, 'py2 test only')
@mock.patch('os.path.exists')
@mock.patch('os.environ.get')
def test_binary_lookup_in_path(self, mock_env_get, mock_path_exists):
| oc_bin = '/usr/bin/oc'
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_path_exists.side_effect = (lambda f: (f == oc_bin))
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing binary lookup in /usr/local/bin'
| @unittest.skipIf(six.PY3, 'py2 test only')
@mock.patch('os.path.exists')
@mock.patch('os.environ.get')
def test_binary_lookup_in_usr_local(self, mock_env_get, mock_path_exists):
| oc_bin = '/usr/local/bin/oc'
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_path_exists.side_effect = (lambda f: (f == oc_bin))
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing binary lookup in ~/bin'
| @unittest.skipIf(six.PY3, 'py2 test only')
@mock.patch('os.path.exists')
@mock.patch('os.environ.get')
def test_binary_lookup_in_home(self, mock_env_get, mock_path_exists):
| oc_bin = os.path.expanduser('~/bin/oc')
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_path_exists.side_effect = (lambda f: (f == oc_bin))
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing binary lookup fallback'
| @unittest.skipIf(six.PY2, 'py3 test only')
@mock.patch('shutil.which')
@mock.patch('os.environ.get')
def test_binary_lookup_fallback_py3(self, mock_env_get, mock_shutil_which):
| mock_env_get.side_effect = (lambda _v, _d: '')
mock_shutil_which.side_effect = (lambda _f, path=None: None)
self.assertEqual(locate_oc_binary(), 'oc')
|
'Testing binary lookup in path'
| @unittest.skipIf(six.PY2, 'py3 test only')
@mock.patch('shutil.which')
@mock.patch('os.environ.get')
def test_binary_lookup_in_path_py3(self, mock_env_get, mock_shutil_which):
| oc_bin = '/usr/bin/oc'
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_shutil_which.side_effect = (lambda _f, path=None: oc_bin)
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing binary lookup in /usr/local/bin'
| @unittest.skipIf(six.PY2, 'py3 test only')
@mock.patch('shutil.which')
@mock.patch('os.environ.get')
def test_binary_lookup_in_usr_local_py3(self, mock_env_get, mock_shutil_which):
| oc_bin = '/usr/local/bin/oc'
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_shutil_which.side_effect = (lambda _f, path=None: oc_bin)
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing binary lookup in ~/bin'
| @unittest.skipIf(six.PY2, 'py3 test only')
@mock.patch('shutil.which')
@mock.patch('os.environ.get')
def test_binary_lookup_in_home_py3(self, mock_env_get, mock_shutil_which):
| oc_bin = os.path.expanduser('~/bin/oc')
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_shutil_which.side_effect = (lambda _f, path=None: oc_bin)
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing a get'
| @mock.patch('oc_adm_manage_node.Utils.create_tmpfile_copy')
@mock.patch('oc_adm_manage_node.ManageNode.openshift_cmd')
def test_list_pods(self, mock_openshift_cmd, mock_tmpfile_copy):
| params = {'node': ['ip-172-31-49-140.ec2.internal'], 'schedulable': None, 'selector': None, 'pod_selector': None, 'list_pods': True, 'kubeconfig': '/etc/origin/master/admin.kubeconfig', 'evacuate': False, 'grace_period': False, 'dry_run': False, 'force': False}
pod_list = '{\n "metadata": {},\... |
'Testing a get'
| @mock.patch('oc_adm_manage_node.Utils.create_tmpfile_copy')
@mock.patch('oc_adm_manage_node.ManageNode.openshift_cmd')
def test_schedulable_false(self, mock_openshift_cmd, mock_tmpfile_copy):
| params = {'node': ['ip-172-31-49-140.ec2.internal'], 'schedulable': False, 'selector': None, 'pod_selector': None, 'list_pods': False, 'kubeconfig': '/etc/origin/master/admin.kubeconfig', 'evacuate': False, 'grace_period': False, 'dry_run': False, 'force': False}
node = [{'apiVersion': 'v1', 'kind': 'Node', 'me... |
'Testing binary lookup fallback'
| @unittest.skipIf(six.PY3, 'py2 test only')
@mock.patch('os.path.exists')
@mock.patch('os.environ.get')
def test_binary_lookup_fallback(self, mock_env_get, mock_path_exists):
| mock_env_get.side_effect = (lambda _v, _d: '')
mock_path_exists.side_effect = (lambda _: False)
self.assertEqual(locate_oc_binary(), 'oc')
|
'Testing binary lookup in path'
| @unittest.skipIf(six.PY2, 'py3 test only')
@mock.patch('shutil.which')
@mock.patch('os.environ.get')
def test_binary_lookup_in_path_py3(self, mock_env_get, mock_shutil_which):
| oc_bin = '/usr/bin/oc'
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_shutil_which.side_effect = (lambda _f, path=None: oc_bin)
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing binary lookup in path'
| @unittest.skipIf(six.PY3, 'py2 test only')
@mock.patch('os.path.exists')
@mock.patch('os.environ.get')
def test_binary_lookup_in_path(self, mock_env_get, mock_path_exists):
| oc_bin = '/usr/bin/oc'
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_path_exists.side_effect = (lambda f: (f == oc_bin))
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing binary lookup in /usr/local/bin'
| @unittest.skipIf(six.PY3, 'py2 test only')
@mock.patch('os.path.exists')
@mock.patch('os.environ.get')
def test_binary_lookup_in_usr_local(self, mock_env_get, mock_path_exists):
| oc_bin = '/usr/local/bin/oc'
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_path_exists.side_effect = (lambda f: (f == oc_bin))
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing binary lookup in ~/bin'
| @unittest.skipIf(six.PY3, 'py2 test only')
@mock.patch('os.path.exists')
@mock.patch('os.environ.get')
def test_binary_lookup_in_home(self, mock_env_get, mock_path_exists):
| oc_bin = os.path.expanduser('~/bin/oc')
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_path_exists.side_effect = (lambda f: (f == oc_bin))
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing binary lookup fallback'
| @unittest.skipIf(six.PY2, 'py3 test only')
@mock.patch('shutil.which')
@mock.patch('os.environ.get')
def test_binary_lookup_fallback_py3(self, mock_env_get, mock_shutil_which):
| mock_env_get.side_effect = (lambda _v, _d: '')
mock_shutil_which.side_effect = (lambda _f, path=None: None)
self.assertEqual(locate_oc_binary(), 'oc')
|
'Testing binary lookup in /usr/local/bin'
| @unittest.skipIf(six.PY2, 'py3 test only')
@mock.patch('shutil.which')
@mock.patch('os.environ.get')
def test_binary_lookup_in_usr_local_py3(self, mock_env_get, mock_shutil_which):
| oc_bin = '/usr/local/bin/oc'
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_shutil_which.side_effect = (lambda _f, path=None: oc_bin)
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing binary lookup in ~/bin'
| @unittest.skipIf(six.PY2, 'py3 test only')
@mock.patch('shutil.which')
@mock.patch('os.environ.get')
def test_binary_lookup_in_home_py3(self, mock_env_get, mock_shutil_which):
| oc_bin = os.path.expanduser('~/bin/oc')
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_shutil_which.side_effect = (lambda _f, path=None: oc_bin)
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing adding a storageclass'
| @mock.patch('oc_storageclass.locate_oc_binary')
@mock.patch('oc_storageclass.Utils.create_tmpfile_copy')
@mock.patch('oc_storageclass.OCStorageClass._run')
def test_adding_a_storageclass(self, mock_cmd, mock_tmpfile_copy, mock_oc_binary):
| valid_result_json = '{\n "kind": "StorageClass",\n "apiVersion": "v1",\n "metadata": {\n "name": "te... |
'Testing adding a project'
| @mock.patch('oc_project.locate_oc_binary')
@mock.patch('oc_project.Utils.create_tmpfile_copy')
@mock.patch('oc_project.Utils._write')
@mock.patch('oc_project.OCProject._run')
def test_adding_a_project(self, mock_cmd, mock_write, mock_tmpfile_copy, mock_loc_oc_bin):
| params = copy.deepcopy(OCProjectTest.params)
project_results = '{\n "kind": "Project",\n "apiVersion": "v1",\n "metadata": {\n ... |
'Testing adding a project'
| @mock.patch('oc_project.locate_oc_binary')
@mock.patch('oc_project.Utils.create_tmpfile_copy')
@mock.patch('oc_project.Utils._write')
@mock.patch('oc_project.OCProject._run')
def test_modifying_a_project_no_attributes(self, mock_cmd, mock_write, mock_tmpfile_copy, mock_loc_oc_bin):
| params = copy.deepcopy(self.params)
params['display_name'] = None
params['node_selector'] = None
params['description'] = None
project_results = '{\n "kind": "Project",\n "apiVersion": "v1",\n ... |
'Testing adding a project'
| @mock.patch('oc_project.locate_oc_binary')
@mock.patch('oc_project.Utils.create_tmpfile_copy')
@mock.patch('oc_project.Utils._write')
@mock.patch('oc_project.OCProject._run')
def test_modifying_project_attributes(self, mock_cmd, mock_write, mock_tmpfile_copy, mock_loc_oc_bin):
| params = copy.deepcopy(self.params)
params['display_name'] = 'updated display name'
params['node_selector'] = 'type=infra'
params['description'] = 'updated description'
project_results = '{\n "kind": "Project",\n ... |
'Testing a label list'
| @mock.patch('oc_label.Utils.create_tmpfile_copy')
@mock.patch('oc_label.OCLabel._run')
def test_state_list(self, mock_cmd, mock_tmpfile_copy):
| params = {'name': 'default', 'namespace': 'default', 'labels': None, 'state': 'list', 'kind': 'namespace', 'selector': None, 'kubeconfig': '/etc/origin/master/admin.kubeconfig', 'debug': False}
ns = '{\n "kind": "Namespace",\n ... |
'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 ... |
'Testing binary lookup fallback'
| @unittest.skipIf(six.PY3, 'py2 test only')
@mock.patch('os.path.exists')
@mock.patch('os.environ.get')
def test_binary_lookup_fallback(self, mock_env_get, mock_path_exists):
| mock_env_get.side_effect = (lambda _v, _d: '')
mock_path_exists.side_effect = (lambda _: False)
self.assertEqual(locate_oc_binary(), 'oc')
|
'Testing binary lookup in path'
| @unittest.skipIf(six.PY3, 'py2 test only')
@mock.patch('os.path.exists')
@mock.patch('os.environ.get')
def test_binary_lookup_in_path(self, mock_env_get, mock_path_exists):
| oc_bin = '/usr/bin/oc'
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_path_exists.side_effect = (lambda f: (f == oc_bin))
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing binary lookup in /usr/local/bin'
| @unittest.skipIf(six.PY3, 'py2 test only')
@mock.patch('os.path.exists')
@mock.patch('os.environ.get')
def test_binary_lookup_in_usr_local(self, mock_env_get, mock_path_exists):
| oc_bin = '/usr/local/bin/oc'
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_path_exists.side_effect = (lambda f: (f == oc_bin))
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing binary lookup in ~/bin'
| @unittest.skipIf(six.PY3, 'py2 test only')
@mock.patch('os.path.exists')
@mock.patch('os.environ.get')
def test_binary_lookup_in_home(self, mock_env_get, mock_path_exists):
| oc_bin = os.path.expanduser('~/bin/oc')
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_path_exists.side_effect = (lambda f: (f == oc_bin))
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing binary lookup fallback'
| @unittest.skipIf(six.PY2, 'py3 test only')
@mock.patch('shutil.which')
@mock.patch('os.environ.get')
def test_binary_lookup_fallback_py3(self, mock_env_get, mock_shutil_which):
| mock_env_get.side_effect = (lambda _v, _d: '')
mock_shutil_which.side_effect = (lambda _f, path=None: None)
self.assertEqual(locate_oc_binary(), 'oc')
|
'Testing binary lookup in path'
| @unittest.skipIf(six.PY2, 'py3 test only')
@mock.patch('shutil.which')
@mock.patch('os.environ.get')
def test_binary_lookup_in_path_py3(self, mock_env_get, mock_shutil_which):
| oc_bin = '/usr/bin/oc'
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_shutil_which.side_effect = (lambda _f, path=None: oc_bin)
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing binary lookup in /usr/local/bin'
| @unittest.skipIf(six.PY2, 'py3 test only')
@mock.patch('shutil.which')
@mock.patch('os.environ.get')
def test_binary_lookup_in_usr_local_py3(self, mock_env_get, mock_shutil_which):
| oc_bin = '/usr/local/bin/oc'
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_shutil_which.side_effect = (lambda _f, path=None: oc_bin)
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing binary lookup in ~/bin'
| @unittest.skipIf(six.PY2, 'py3 test only')
@mock.patch('shutil.which')
@mock.patch('os.environ.get')
def test_binary_lookup_in_home_py3(self, mock_env_get, mock_shutil_which):
| oc_bin = os.path.expanduser('~/bin/oc')
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_shutil_which.side_effect = (lambda _f, path=None: oc_bin)
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing a group create'
| @mock.patch('oc_group.Utils.create_tmpfile_copy')
@mock.patch('oc_group.OCGroup._run')
def test_create_group(self, mock_run, mock_tmpfile_copy):
| params = copy.deepcopy(OCGroupTest.params)
group = '{\n "kind": "Group",\n "apiVersion": "v1",\n "metadata": {\n ... |
'Testing a group create'
| @mock.patch('oc_group.Utils.create_tmpfile_copy')
@mock.patch('oc_group.OCGroup._run')
def test_failed_get_group(self, mock_run, mock_tmpfile_copy):
| params = copy.deepcopy(OCGroupTest.params)
params['state'] = 'list'
params['name'] = 'noexist'
mock_run.side_effect = [(1, '', 'Error from server: groups "acme" not found')]
mock_tmpfile_copy.side_effect = ['/tmp/mocked_kubeconfig']
results = OCGroup.run_ansible(params, False)
... |
'Testing a group create'
| @mock.patch('oc_group.Utils.create_tmpfile_copy')
@mock.patch('oc_group.OCGroup._run')
def test_delete_group(self, mock_run, mock_tmpfile_copy):
| params = copy.deepcopy(OCGroupTest.params)
params['state'] = 'absent'
group = '{\n "kind": "Group",\n "apiVersion": "v1",\n "metadata": {\n ... |
'Testing a group create'
| @mock.patch('oc_group.Utils.create_tmpfile_copy')
@mock.patch('oc_group.OCGroup._run')
def test_get_group(self, mock_run, mock_tmpfile_copy):
| params = copy.deepcopy(OCGroupTest.params)
params['state'] = 'list'
group = '{\n "kind": "Group",\n "apiVersion": "v1",\n "metadata": {\n ... |
'Testing binary lookup fallback'
| @unittest.skipIf(six.PY3, 'py2 test only')
@mock.patch('os.path.exists')
@mock.patch('os.environ.get')
def test_binary_lookup_fallback(self, mock_env_get, mock_path_exists):
| mock_env_get.side_effect = (lambda _v, _d: '')
mock_path_exists.side_effect = (lambda _: False)
self.assertEqual(locate_oc_binary(), 'oc')
|
'Testing binary lookup in path'
| @unittest.skipIf(six.PY3, 'py2 test only')
@mock.patch('os.path.exists')
@mock.patch('os.environ.get')
def test_binary_lookup_in_path(self, mock_env_get, mock_path_exists):
| oc_bin = '/usr/bin/oc'
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_path_exists.side_effect = (lambda f: (f == oc_bin))
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing binary lookup in /usr/local/bin'
| @unittest.skipIf(six.PY3, 'py2 test only')
@mock.patch('os.path.exists')
@mock.patch('os.environ.get')
def test_binary_lookup_in_usr_local(self, mock_env_get, mock_path_exists):
| oc_bin = '/usr/local/bin/oc'
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_path_exists.side_effect = (lambda f: (f == oc_bin))
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing binary lookup in ~/bin'
| @unittest.skipIf(six.PY3, 'py2 test only')
@mock.patch('os.path.exists')
@mock.patch('os.environ.get')
def test_binary_lookup_in_home(self, mock_env_get, mock_path_exists):
| oc_bin = os.path.expanduser('~/bin/oc')
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_path_exists.side_effect = (lambda f: (f == oc_bin))
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing binary lookup fallback'
| @unittest.skipIf(six.PY2, 'py3 test only')
@mock.patch('shutil.which')
@mock.patch('os.environ.get')
def test_binary_lookup_fallback_py3(self, mock_env_get, mock_shutil_which):
| mock_env_get.side_effect = (lambda _v, _d: '')
mock_shutil_which.side_effect = (lambda _f, path=None: None)
self.assertEqual(locate_oc_binary(), 'oc')
|
'Testing binary lookup in path'
| @unittest.skipIf(six.PY2, 'py3 test only')
@mock.patch('shutil.which')
@mock.patch('os.environ.get')
def test_binary_lookup_in_path_py3(self, mock_env_get, mock_shutil_which):
| oc_bin = '/usr/bin/oc'
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_shutil_which.side_effect = (lambda _f, path=None: oc_bin)
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing binary lookup in /usr/local/bin'
| @unittest.skipIf(six.PY2, 'py3 test only')
@mock.patch('shutil.which')
@mock.patch('os.environ.get')
def test_binary_lookup_in_usr_local_py3(self, mock_env_get, mock_shutil_which):
| oc_bin = '/usr/local/bin/oc'
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_shutil_which.side_effect = (lambda _f, path=None: oc_bin)
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing binary lookup in ~/bin'
| @unittest.skipIf(six.PY2, 'py3 test only')
@mock.patch('shutil.which')
@mock.patch('os.environ.get')
def test_binary_lookup_in_home_py3(self, mock_env_get, mock_shutil_which):
| oc_bin = os.path.expanduser('~/bin/oc')
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_shutil_which.side_effect = (lambda _f, path=None: oc_bin)
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing when both all objects are empty'
| @mock.patch('oc_objectvalidator.locate_oc_binary')
@mock.patch('oc_objectvalidator.Utils.create_tmpfile_copy')
@mock.patch('oc_objectvalidator.OCObjectValidator._run')
def test_no_data(self, mock_cmd, mock_tmpfile_copy, mock_oc_binary):
| params = {'kubeconfig': '/etc/origin/master/admin.kubeconfig'}
empty = '{\n "apiVersion": "v1",\n "items": [],\n "kind": "List",\n "metadata": {},\n "resourceVersion": "",\n "selfLink": ""\n}'
mock_cm... |
'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... |
'Testing when both all objects are valid'
| @mock.patch('oc_objectvalidator.locate_oc_binary')
@mock.patch('oc_objectvalidator.Utils.create_tmpfile_copy')
@mock.patch('oc_objectvalidator.OCObjectValidator._run')
def test_valid_both(self, mock_cmd, mock_tmpfile_copy, mock_oc_binary):
| params = {'kubeconfig': '/etc/origin/master/admin.kubeconfig'}
valid_hostsubnet = '{\n "apiVersion": "v1",\n "items": [\n {\n "apiVersion": "v1",\n ... |
'Testing when all objects are invalid'
| @mock.patch('oc_objectvalidator.locate_oc_binary')
@mock.patch('oc_objectvalidator.Utils.create_tmpfile_copy')
@mock.patch('oc_objectvalidator.OCObjectValidator._run')
def test_invalid_both(self, mock_cmd, mock_tmpfile_copy, mock_oc_binary):
| params = {'kubeconfig': '/etc/origin/master/admin.kubeconfig'}
invalid_hostsubnet = '{\n "apiVersion": "v1",\n "items": [\n {\n "apiVersion": "v1",\n ... |
'Testing a get'
| @mock.patch('oc_service.Utils.create_tmpfile_copy')
@mock.patch('oc_service.OCService._run')
def test_state_list(self, mock_cmd, mock_tmpfile_copy):
| params = {'name': 'router', 'namespace': 'default', 'ports': None, 'state': 'list', 'labels': None, 'clusterip': None, 'portalip': None, 'selector': None, 'session_affinity': None, 'service_type': None, 'external_ips': None, 'kubeconfig': '/etc/origin/master/admin.kubeconfig', 'debug': False}
service = '{\n ... |
'Testing a create service'
| @mock.patch('oc_service.Utils.create_tmpfile_copy')
@mock.patch('oc_service.OCService._run')
def test_create(self, mock_cmd, mock_tmpfile_copy):
| params = {'name': 'router', 'namespace': 'default', 'ports': {'name': '9000-tcp', 'port': 9000, 'protocol': 'TCP', 'targetPOrt': 9000}, 'state': 'present', 'labels': None, 'clusterip': None, 'portalip': None, 'selector': {'router': 'router'}, 'session_affinity': 'ClientIP', 'service_type': 'ClusterIP', 'external_ip... |
'Testing binary lookup fallback'
| @unittest.skipIf(six.PY3, 'py2 test only')
@mock.patch('os.path.exists')
@mock.patch('os.environ.get')
def test_binary_lookup_fallback(self, mock_env_get, mock_path_exists):
| mock_env_get.side_effect = (lambda _v, _d: '')
mock_path_exists.side_effect = (lambda _: False)
self.assertEqual(locate_oc_binary(), 'oc')
|
'Testing binary lookup in path'
| @unittest.skipIf(six.PY3, 'py2 test only')
@mock.patch('os.path.exists')
@mock.patch('os.environ.get')
def test_binary_lookup_in_path(self, mock_env_get, mock_path_exists):
| oc_bin = '/usr/bin/oc'
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_path_exists.side_effect = (lambda f: (f == oc_bin))
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing binary lookup in /usr/local/bin'
| @unittest.skipIf(six.PY3, 'py2 test only')
@mock.patch('os.path.exists')
@mock.patch('os.environ.get')
def test_binary_lookup_in_usr_local(self, mock_env_get, mock_path_exists):
| oc_bin = '/usr/local/bin/oc'
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_path_exists.side_effect = (lambda f: (f == oc_bin))
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing binary lookup in ~/bin'
| @unittest.skipIf(six.PY3, 'py2 test only')
@mock.patch('os.path.exists')
@mock.patch('os.environ.get')
def test_binary_lookup_in_home(self, mock_env_get, mock_path_exists):
| oc_bin = os.path.expanduser('~/bin/oc')
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_path_exists.side_effect = (lambda f: (f == oc_bin))
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing binary lookup fallback'
| @unittest.skipIf(six.PY2, 'py3 test only')
@mock.patch('shutil.which')
@mock.patch('os.environ.get')
def test_binary_lookup_fallback_py3(self, mock_env_get, mock_shutil_which):
| mock_env_get.side_effect = (lambda _v, _d: '')
mock_shutil_which.side_effect = (lambda _f, path=None: None)
self.assertEqual(locate_oc_binary(), 'oc')
|
'Testing binary lookup in path'
| @unittest.skipIf(six.PY2, 'py3 test only')
@mock.patch('shutil.which')
@mock.patch('os.environ.get')
def test_binary_lookup_in_path_py3(self, mock_env_get, mock_shutil_which):
| oc_bin = '/usr/bin/oc'
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_shutil_which.side_effect = (lambda _f, path=None: oc_bin)
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing binary lookup in /usr/local/bin'
| @unittest.skipIf(six.PY2, 'py3 test only')
@mock.patch('shutil.which')
@mock.patch('os.environ.get')
def test_binary_lookup_in_usr_local_py3(self, mock_env_get, mock_shutil_which):
| oc_bin = '/usr/local/bin/oc'
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_shutil_which.side_effect = (lambda _f, path=None: oc_bin)
self.assertEqual(locate_oc_binary(), oc_bin)
|
'Testing binary lookup in ~/bin'
| @unittest.skipIf(six.PY2, 'py3 test only')
@mock.patch('shutil.which')
@mock.patch('os.environ.get')
def test_binary_lookup_in_home_py3(self, mock_env_get, mock_shutil_which):
| oc_bin = os.path.expanduser('~/bin/oc')
mock_env_get.side_effect = (lambda _v, _d: '/bin:/usr/bin')
mock_shutil_which.side_effect = (lambda _f, path=None: oc_bin)
self.assertEqual(locate_oc_binary(), oc_bin)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.