浏览代码

[doc2] Add a create directory test

Romain Rigaux 9 年之前
父节点
当前提交
a3935ddd68

+ 1 - 1
desktop/core/src/desktop/api2.py

@@ -61,7 +61,7 @@ def api_error_handler(func):
 
 
 @api_error_handler
-def get_documents2(request):
+def get_documents(request):
   path = request.GET.get('path', '/') # Expects path to be a Directory for now
 
   try:

+ 1 - 1
desktop/core/src/desktop/static/desktop/js/assist/assistHelper.js

@@ -26,7 +26,7 @@
   var AUTOCOMPLETE_API_PREFIX = "/notebook/api/autocomplete/";
   var HDFS_API_PREFIX = "/filebrowser/view=";
   var HDFS_PARAMETERS = "?pagesize=100&format=json";
-  var DOCUMENTS_API = "/desktop/api2/docs2/";
+  var DOCUMENTS_API = "/desktop/api2/docs/";
 
 
   /**

+ 15 - 0
desktop/core/src/desktop/tests_doc2.py

@@ -16,6 +16,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+import json
+
 from nose.tools import assert_equal
 from django.contrib.auth.models import User
 
@@ -34,6 +36,12 @@ class TestDocument2(object):
     self.user = User.objects.get(username="doc2")
     grant_access("doc2", "doc2", "beeswax")
 
+    # Setup Home dir this way currently
+    response = self.client.get('/desktop/api2/docs/')
+    data = json.loads(response.content)
+
+    assert_equal('/', data['path'], data)
+
 
   def test_document_create(self):
     sql = 'SELECT * FROM sample_07'
@@ -68,3 +76,10 @@ class TestDocument2(object):
       assert_equal([], new_query_data['snippets'][0]['properties']['functions'])
     finally:
       old_query.delete()
+
+
+  def test_directory_create(self):
+    response = self.client.post('/desktop/api2/doc/mkdir', {'parent_path': json.dumps('/'), 'name': json.dumps('test_mkdir')})
+    data = json.loads(response.content)
+
+    assert_equal(0, data['status'], data)

+ 1 - 1
desktop/core/src/desktop/urls.py

@@ -99,7 +99,7 @@ dynamic_patterns += patterns('desktop.api',
 )
 
 dynamic_patterns += patterns('desktop.api2',
-  (r'^desktop/api2/docs2/?$', 'get_documents2'),
+  (r'^desktop/api2/docs/?$', 'get_documents'),
   (r'^desktop/api2/doc/get$', 'get_document'),
 
   (r'^desktop/api2/doc/move$', 'move_document'),