Browse Source

[raz_adls] Add append and flush operation mapping

- Required when creating file with data and also when uploading
Harshg999 4 years ago
parent
commit
eec293cade

+ 3 - 0
desktop/core/src/desktop/lib/raz/raz_client.py

@@ -203,6 +203,9 @@ class RazClient(object):
     if method == 'HEAD':
       access_type = 'get-status' if params.get('action') == 'getStatus' else ''
 
+    if method == 'PATCH':
+      access_type = 'write' if params.get('action') == 'append' or params.get('action') == 'flush' else ''
+
     if method == 'DELETE':
       access_type = 'delete-recursive' if params.get('recursive') == 'true' else 'delete'
     

+ 38 - 18
desktop/core/src/desktop/lib/raz/raz_client_test.py

@@ -203,15 +203,25 @@ class RazClientTest(unittest.TestCase):
     assert_equal(response['access_type'], 'get-status')
     assert_equal(response['relative_path'], '/user/csso_hueuser')
 
-    # Create file
-    method = 'PUT'
-    relative_path = '/user/csso_hueuser/customers.csv'
-    url_params = {'resource': 'file'}
+    # Delete path
+    method = 'DELETE'
+    relative_path = '/user/csso_hueuser/test_dir/customer.csv'
+    url_params = {}
 
     response = client.handle_adls_req_mapping(method, url_params, relative_path)
 
-    assert_equal(response['access_type'], 'create-file')
-    assert_equal(response['relative_path'], '/user/csso_hueuser/customers.csv')
+    assert_equal(response['access_type'], 'delete')
+    assert_equal(response['relative_path'], '/user/csso_hueuser/test_dir/customer.csv')
+
+    # Delete with recursive as true
+    method = 'DELETE'
+    relative_path = '/user/csso_hueuser/test_dir'
+    url_params = {'recursive': 'true'}
+
+    response = client.handle_adls_req_mapping(method, url_params, relative_path)
+
+    assert_equal(response['access_type'], 'delete-recursive')
+    assert_equal(response['relative_path'], '/user/csso_hueuser/test_dir')
 
     # Create directory
     method = 'PUT'
@@ -223,25 +233,35 @@ class RazClientTest(unittest.TestCase):
     assert_equal(response['access_type'], 'create-directory')
     assert_equal(response['relative_path'], '/user/csso_hueuser/test_dir')
 
-    # Delete path
-    method = 'DELETE'
-    relative_path = '/user/csso_hueuser/test_dir/customer.csv'
-    url_params = {}
+    # Create file
+    method = 'PUT'
+    relative_path = '/user/csso_hueuser/customers.csv'
+    url_params = {'resource': 'file'}
 
     response = client.handle_adls_req_mapping(method, url_params, relative_path)
 
-    assert_equal(response['access_type'], 'delete')
-    assert_equal(response['relative_path'], '/user/csso_hueuser/test_dir/customer.csv')
+    assert_equal(response['access_type'], 'create-file')
+    assert_equal(response['relative_path'], '/user/csso_hueuser/customers.csv')
 
-    # Delete with recursive as true
-    method = 'DELETE'
-    relative_path = '/user/csso_hueuser/test_dir'
-    url_params = {'recursive': 'true'}
+    # Append
+    method = 'PATCH'
+    relative_path = '/user/csso_hueuser/customers.csv'
+    url_params = {'action': 'append'}
 
     response = client.handle_adls_req_mapping(method, url_params, relative_path)
 
-    assert_equal(response['access_type'], 'delete-recursive')
-    assert_equal(response['relative_path'], '/user/csso_hueuser/test_dir')
+    assert_equal(response['access_type'], 'write')
+    assert_equal(response['relative_path'], '/user/csso_hueuser/customers.csv')
+
+    # Flush
+    method = 'PATCH'
+    relative_path = '/user/csso_hueuser/customers.csv'
+    url_params = {'action': 'flush'}
+
+    response = client.handle_adls_req_mapping(method, url_params, relative_path)
+
+    assert_equal(response['access_type'], 'write')
+    assert_equal(response['relative_path'], '/user/csso_hueuser/customers.csv')
 
 
   def test_get_raz_client_s3(self):