desc stringlengths 3 26.7k | decl stringlengths 11 7.89k | bodies stringlengths 8 553k |
|---|---|---|
'secret constructor'
| def __init__(self, content):
| super(Secret, self).__init__(content=content)
self._secrets = None
|
'secret property getter'
| @property
def secrets(self):
| if (self._secrets is None):
self._secrets = self.get_secrets()
return self._secrets
|
'secret property setter'
| @secrets.setter
def secrets(self):
| if (self._secrets is None):
self._secrets = self.get_secrets()
return self._secrets
|
'returns all of the defined secrets'
| def get_secrets(self):
| return (self.get(Secret.secret_path) or {})
|
'add a secret'
| def add_secret(self, key, value):
| if self.secrets:
self.secrets[key] = value
else:
self.put(Secret.secret_path, {key: value})
return True
|
'delete secret'
| def delete_secret(self, key):
| try:
del self.secrets[key]
except KeyError as _:
return False
return True
|
'find secret'
| def find_secret(self, key):
| rval = None
try:
rval = self.secrets[key]
except KeyError as _:
return None
return {'key': key, 'value': rval}
|
'update a secret'
| def update_secret(self, key, value):
| if (key in self.secrets):
self.secrets[key] = value
else:
self.add_secret(key, value)
return True
|
'property for verbs'
| @property
def verbs(self):
| if (self.__verbs is None):
return []
return self.__verbs
|
'setter for verbs'
| @verbs.setter
def verbs(self, data):
| self.__verbs = data
|
'property for api_groups'
| @property
def api_groups(self):
| if (self.__api_groups is None):
return []
return self.__api_groups
|
'setter for api_groups'
| @api_groups.setter
def api_groups(self, data):
| self.__api_groups = data
|
'property for resources'
| @property
def resources(self):
| if (self.__resources is None):
return []
return self.__resources
|
'setter for resources'
| @resources.setter
def resources(self, data):
| self.__resources = data
|
'property for attribute_restrictions'
| @property
def attribute_restrictions(self):
| return self.__attribute_restrictions
|
'setter for attribute_restrictions'
| @attribute_restrictions.setter
def attribute_restrictions(self, data):
| self.__attribute_restrictions = data
|
'add a verb to the verbs array'
| def add_verb(self, inc_verb):
| self.verbs.append(inc_verb)
|
'add an api_group to the api_groups array'
| def add_api_group(self, inc_apigroup):
| self.api_groups.append(inc_apigroup)
|
'add an resource to the resources array'
| def add_resource(self, inc_resource):
| self.resources.append(inc_resource)
|
'add a verb to the verbs array'
| def remove_verb(self, inc_verb):
| try:
self.verbs.remove(inc_verb)
return True
except ValueError:
pass
return False
|
'add a verb to the verbs array'
| def remove_api_group(self, inc_api_group):
| try:
self.api_groups.remove(inc_api_group)
return True
except ValueError:
pass
return False
|
'add a verb to the verbs array'
| def remove_resource(self, inc_resource):
| try:
self.resources.remove(inc_resource)
return True
except ValueError:
pass
return False
|
'return whether rules are equal'
| def __eq__(self, other):
| return ((self.attribute_restrictions == other.attribute_restrictions) and (self.api_groups == other.api_groups) and (self.resources == other.resources) and (self.verbs == other.verbs))
|
'create rules from an array'
| @staticmethod
def parse_rules(inc_rules):
| results = []
for rule in inc_rules:
results.append(Rule(rule.get('apiGroups', ['']), rule.get('attributeRestrictions', None), rule.get('resources', []), rule.get('verbs', [])))
return results
|
'Given a dict of labels/values, return list of key: <key> value: <value> pairs
These are only used in integration testing.'
| @staticmethod
def label_dict_to_key_value_list(label_dict):
| label_list = []
for key in label_dict:
label_list.append({'key': key, 'value': label_dict[key]})
return label_list
|
'returns a mapping of filters to methods'
| def filters(self):
| return {'label_dict_to_key_value_list': self.label_dict_to_key_value_list}
|
'Testing a get'
| @mock.patch('oc_version.Utils.create_tmpfile_copy')
@mock.patch('oc_version.OCVersion.openshift_cmd')
def test_get(self, mock_openshift_cmd, mock_tmpfile_copy):
| params = {'kubeconfig': '/etc/origin/master/admin.kubeconfig', 'state': 'list', 'debug': False}
mock_openshift_cmd.side_effect = [{'cmd': 'oc version', 'results': (((('oc v3.4.0.39\nkubernetes v1.4.0+776c994\n' + 'features: Basic-Auth GSSAPI Kerberos SPNEGO\n\n') + 'Server https://intern... |
'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 label list'
| @mock.patch('oc_image.Utils.create_tmpfile_copy')
@mock.patch('oc_image.OCImage._run')
def test_state_list(self, mock_cmd, mock_tmpfile_copy):
| params = {'registry_url': 'registry.ops.openshift.com', 'image_name': 'oso-rhel7-zagg-web', 'image_tag': 'int', 'namespace': 'default', 'state': 'list', 'kubeconfig': '/etc/origin/master/admin.kubeconfig', 'debug': False}
istream = '{\n "kind": "ImageStream",\n ... |
'Testing a image present'
| @mock.patch('oc_image.Utils.create_tmpfile_copy')
@mock.patch('oc_image.OCImage._run')
def test_state_present(self, mock_cmd, mock_tmpfile_copy):
| params = {'registry_url': 'registry.ops.openshift.com', 'image_name': 'oso-rhel7-zagg-web', 'image_tag': 'int', 'namespace': 'default', 'state': 'present', 'kubeconfig': '/etc/origin/master/admin.kubeconfig', 'debug': False}
istream = '{\n "kind": "ImageStream",... |
'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 listing all environment variables from a dc'
| @mock.patch('oc_env.locate_oc_binary')
@mock.patch('oc_env.Utils.create_tmpfile_copy')
@mock.patch('oc_env.OCEnv._run')
def test_listing_all_env_vars(self, mock_cmd, mock_tmpfile_copy, mock_oc_binary):
| params = {'state': 'list', 'namespace': 'default', 'name': 'router', 'kind': 'dc', 'env_vars': None, 'kubeconfig': '/etc/origin/master/admin.kubeconfig', 'debug': False}
dc_results = '{\n "apiVersion": "v1",\n "kind... |
'Test add environment variables to a dc'
| @mock.patch('oc_env.locate_oc_binary')
@mock.patch('oc_env.Utils.create_tmpfile_copy')
@mock.patch('oc_env.OCEnv._run')
def test_adding_env_vars(self, mock_cmd, mock_tmpfile_copy, mock_oc_binary):
| params = {'state': 'present', 'namespace': 'default', 'name': 'router', 'kind': 'dc', 'kubeconfig': '/etc/origin/master/admin.kubeconfig', 'debug': False, 'env_vars': {'SOMEKEY': 'SOMEVALUE'}}
dc_results = '{\n "apiVersion": "v1",\n ... |
'Test add environment variables to a dc'
| @mock.patch('oc_env.locate_oc_binary')
@mock.patch('oc_env.Utils.create_tmpfile_copy')
@mock.patch('oc_env.OCEnv._run')
def test_removing_env_vars(self, mock_cmd, mock_tmpfile_copy, mock_oc_binary):
| params = {'state': 'absent', 'namespace': 'default', 'name': 'router', 'kind': 'dc', 'kubeconfig': '/etc/origin/master/admin.kubeconfig', 'debug': False, 'env_vars': {'SOMEKEY': 'SOMEVALUE'}}
dc_results_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 adding a serviceaccount'
| @mock.patch('oc_serviceaccount.locate_oc_binary')
@mock.patch('oc_serviceaccount.Utils.create_tmpfile_copy')
@mock.patch('oc_serviceaccount.OCServiceAccount._run')
def test_adding_a_serviceaccount(self, mock_cmd, mock_tmpfile_copy, mock_oc_binary):
| params = {'kubeconfig': '/etc/origin/master/admin.kubeconfig', 'state': 'present', 'debug': False, 'name': 'testserviceaccountname', 'namespace': 'default', 'secrets': None, 'image_pull_secrets': None}
valid_result_json = '{\n "kind": "ServiceAccount",\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 adding a project'
| @mock.patch('oc_clusterrole.locate_oc_binary')
@mock.patch('oc_clusterrole.Utils.create_tmpfile_copy')
@mock.patch('oc_clusterrole.Utils._write')
@mock.patch('oc_clusterrole.OCClusterRole._run')
def test_adding_a_clusterrole(self, mock_cmd, mock_write, mock_tmpfile_copy, mock_loc_binary):
| params = copy.deepcopy(OCClusterRoleTest.params)
clusterrole = '{\n "apiVersion": "v1",\n "kind": "ClusterRole",\n "metadata": {\n ... |
'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, 'po... |
'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_scale.Utils.create_tmpfile_copy')
@mock.patch('oc_scale.OCScale.openshift_cmd')
def test_state_list(self, mock_openshift_cmd, mock_tmpfile_copy):
| params = {'name': 'router', 'namespace': 'default', 'replicas': 2, 'state': 'list', 'kind': 'dc', 'kubeconfig': '/etc/origin/master/admin.kubeconfig', 'debug': False}
dc = '{"kind": "DeploymentConfig",\n "apiVersion": "v1",\n ... |
'Testing a get'
| @mock.patch('oc_scale.Utils.create_tmpfile_copy')
@mock.patch('oc_scale.OCScale.openshift_cmd')
def test_scale(self, mock_openshift_cmd, mock_tmpfile_copy):
| params = {'name': 'router', 'namespace': 'default', 'replicas': 3, 'state': 'list', 'kind': 'dc', 'kubeconfig': '/etc/origin/master/admin.kubeconfig', 'debug': False}
dc = '{"kind": "DeploymentConfig",\n "apiVersion": "v1",\n ... |
'Testing a get'
| @mock.patch('oc_scale.Utils.create_tmpfile_copy')
@mock.patch('oc_scale.OCScale.openshift_cmd')
def test_no_dc_scale(self, mock_openshift_cmd, mock_tmpfile_copy):
| params = {'name': 'not_there', 'namespace': 'default', 'replicas': 3, 'state': 'present', 'kind': 'dc', 'kubeconfig': '/etc/origin/master/admin.kubeconfig', 'debug': False}
mock_openshift_cmd.side_effect = [{'cmd': '/usr/bin/oc -n default get dc not_there -o json', 'results': [{}], 'returnc... |
'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 label list'
| @mock.patch('oc_volume.Utils.create_tmpfile_copy')
@mock.patch('oc_volume.OCVolume._run')
def test_create_pvc(self, mock_cmd, mock_tmpfile_copy):
| params = copy.deepcopy(OCVolumeTest.params)
dc = '{\n "kind": "DeploymentConfig",\n "apiVersion": "v1",\n "metadata":... |
'Testing a label list'
| @mock.patch('oc_volume.Utils.create_tmpfile_copy')
@mock.patch('oc_volume.OCVolume._run')
def test_create_configmap(self, mock_cmd, mock_tmpfile_copy):
| params = copy.deepcopy(OCVolumeTest.params)
params.update({'mount_path': '/configmap', 'mount_type': 'configmap', 'configmap_name': 'configtest', 'vol_name': 'configvol'})
dc = '{\n "kind": "DeploymentConfig",\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 state present'
| @mock.patch('oc_adm_registry.locate_oc_binary')
@mock.patch('oc_adm_registry.Utils._write')
@mock.patch('oc_adm_registry.Utils.create_tmpfile_copy')
@mock.patch('oc_adm_registry.Registry._run')
def test_state_present(self, mock_cmd, mock_tmpfile_copy, mock_write, mock_oc_binary):
| params = {'state': 'present', 'debug': False, 'namespace': 'default', 'name': 'docker-registry', 'kubeconfig': '/etc/origin/master/admin.kubeconfig', 'images': None, 'latest_images': None, 'labels': {'docker-registry': 'default', 'another-label': 'val'}, 'ports': ['5000'], 'replicas': 1, 'selector': 'type=infra', '... |
'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)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.