def test_non_bucket_uri_raises(self): """Raise exception on invalid paths.""" test_path = '/some/local/path/file.ext' with self.assertRaises(api_errors.InvalidBucketPathError): storage.get_bucket_and_path_from(test_path) with self.assertRaises(api_errors.InvalidBucketPathError): storage.get_bucket_and_path_from(None)
def test_get_bucket_and_path_from(self): """Given a valid bucket object path, return the bucket and path.""" test_path = 'gs://{}/{}'.format(fake_storage.FAKE_BUCKET_NAME, fake_storage.FAKE_OBJECT_NAME) bucket, obj_name = storage.get_bucket_and_path_from(test_path) self.assertEqual(fake_storage.FAKE_BUCKET_NAME, bucket) self.assertEqual(fake_storage.FAKE_OBJECT_NAME, obj_name)
def test_get_bucket_and_path_from(self): """Given a valid bucket object path, return the bucket and path.""" expected_bucket = 'my-bucket' expected_obj_path = 'path/to/object' test_path = 'gs://{}/{}'.format(expected_bucket, expected_obj_path) client = storage.StorageClient() bucket, obj_path = storage.get_bucket_and_path_from(test_path) self.assertEqual(expected_bucket, bucket) self.assertEqual(expected_obj_path, obj_path)
def test_non_bucket_uri_raises(self, mock_base): """Given a valid bucket object path, return the bucket and path.""" test_path = '/some/local/path/file.ext' client = storage.StorageClient() with self.assertRaises(api_errors.InvalidBucketPathError): bucket, obj_path = storage.get_bucket_and_path_from(test_path)