def testCheckForInstalledBinaryOnPath(self): expected_path = os.path.join('/usr', 'bin', 'myexc') self.StartObjectPatch(files, 'FindExecutableOnPath', return_value=expected_path) self.assertEqual(expected_path, binary_operations.CheckForInstalledBinary('myexc'))
def __init__(self, gcp_account=None, impersonated=False): if not gcp_account: gcp_account = properties.VALUES.core.account.Get() self._export_service = bin_ops.CheckForInstalledBinary( 'config-connector', custom_message='config-connector tool not installed.') self._use_account_impersonation = impersonated self._account = gcp_account
def __init__(self, gcp_account=None, impersonated=False): if not gcp_account: gcp_account = properties.VALUES.core.account.Get() try: self._export_service = bin_ops.CheckForInstalledBinary(self.binary_name) except bin_ops.MissingExecutableException: self._export_service = bin_ops.InstallBinaryNoOverrides( self.binary_name, prompt=self.binary_prompt) self._use_account_impersonation = impersonated self._account = gcp_account
def testCheckForInstalledBinaryMissing(self): self.StartObjectPatch(files, 'FindExecutableOnPath', return_value=None) with self.assertRaisesRegex( binary_operations.MissingExecutableException, r'Not Found!!'): binary_operations.CheckForInstalledBinary('myexc', 'Not Found!!')
def testCheckForInstalledBinaryAsComponent(self): component = binary_operations.CheckForInstalledBinary('foo') expected = os.path.join(self.bin_path, component) self.assertEqual(expected, component)