소스 검색

[desktop] Allow doc1 API tests to accommodate old and new editor modes

Jenny Kim 9 년 전
부모
커밋
446e05c
1개의 변경된 파일24개의 추가작업 그리고 24개의 파일을 삭제
  1. 24 24
      desktop/core/src/desktop/api_tests.py

+ 24 - 24
desktop/core/src/desktop/api_tests.py

@@ -20,17 +20,15 @@ import json
 
 from nose.tools import assert_true, assert_false, assert_equal, assert_not_equal, assert_raises
 
-from django.conf.urls import patterns, url
 from django.contrib.auth.models import User
-from django.core.urlresolvers import reverse
-from django.db.models import query, CharField, SmallIntegerField
 
+from beeswax.conf import USE_NEW_EDITOR
+from desktop.api import massaged_documents_for_json, _get_docs
 from desktop.lib.django_test_util import make_logged_in_client
 from desktop.lib.test_utils import grant_access
 from desktop.models import DocumentTag , Document
 from pig.models import PigScript
 from useradmin.models import get_default_user_group
-from desktop.api import massaged_documents_for_json, _get_docs
 
 
 class TestDocModelTags():
@@ -203,6 +201,8 @@ class TestDocModelPermissions():
     self.user = User.objects.get(username="perm_user")
     self.user_not_me = User.objects.get(username="not_perm_user")
 
+    self.old_home_path = '/home2' if USE_NEW_EDITOR.get() else '/home'
+
     grant_access(self.user.username, self.user.username, "desktop")
     grant_access(self.user_not_me.username, self.user_not_me.username, "desktop")
 
@@ -226,18 +226,18 @@ class TestDocModelPermissions():
 
   def test_share_document_permissions(self):
     # No doc
-    response = self.client.get('/home2')
+    response = self.client.get(self.old_home_path)
     assert_equal({}, json.loads(response.context['json_documents']))
-    response = self.client_not_me.get('/home2')
+    response = self.client_not_me.get(self.old_home_path)
     assert_equal({}, json.loads(response.context['json_documents']))
 
     # Add doc
     script, doc = self._add_doc('test_update_permissions')
     doc_id = '%s' % doc.id
 
-    response = self.client.get('/home2')
+    response = self.client.get(self.old_home_path)
     assert_true(doc_id in json.loads(response.context['json_documents']))
-    response = self.client_not_me.get('/home2')
+    response = self.client_not_me.get(self.old_home_path)
     assert_false(doc_id in json.loads(response.context['json_documents']))
 
     assert_true(doc.can_read(self.user))
@@ -270,9 +270,9 @@ class TestDocModelPermissions():
     assert_true(doc.can_read(self.user_not_me))
     assert_false(doc.can_write(self.user_not_me))
 
-    response = self.client.get('/home2')
+    response = self.client.get(self.old_home_path)
     assert_true(doc_id in json.loads(response.context['json_documents']))
-    response = self.client_not_me.get('/home2')
+    response = self.client_not_me.get(self.old_home_path)
     assert_true(doc_id in json.loads(response.context['json_documents']))
 
     # Un-share
@@ -299,9 +299,9 @@ class TestDocModelPermissions():
     assert_false(doc.can_read(self.user_not_me))
     assert_false(doc.can_write(self.user_not_me))
 
-    response = self.client.get('/home2')
+    response = self.client.get(self.old_home_path)
     assert_true(doc_id in json.loads(response.context['json_documents']))
-    response = self.client_not_me.get('/home2')
+    response = self.client_not_me.get(self.old_home_path)
     assert_false(doc_id in json.loads(response.context['json_documents']))
 
     # Share by group
@@ -332,9 +332,9 @@ class TestDocModelPermissions():
     assert_true(doc.can_read(self.user_not_me))
     assert_false(doc.can_write(self.user_not_me))
 
-    response = self.client.get('/home2')
+    response = self.client.get(self.old_home_path)
     assert_true(doc_id in json.loads(response.context['json_documents']))
-    response = self.client_not_me.get('/home2')
+    response = self.client_not_me.get(self.old_home_path)
     assert_true(doc_id in json.loads(response.context['json_documents']))
 
     # Un-share
@@ -361,9 +361,9 @@ class TestDocModelPermissions():
     assert_false(doc.can_read(self.user_not_me))
     assert_false(doc.can_write(self.user_not_me))
 
-    response = self.client.get('/home2')
+    response = self.client.get(self.old_home_path)
     assert_true(doc_id in json.loads(response.context['json_documents']))
-    response = self.client_not_me.get('/home2')
+    response = self.client_not_me.get(self.old_home_path)
     assert_false(doc_id in json.loads(response.context['json_documents']))
 
     # Modify by user
@@ -392,9 +392,9 @@ class TestDocModelPermissions():
     assert_true(doc.can_read(self.user_not_me))
     assert_true(doc.can_write(self.user_not_me))
 
-    response = self.client.get('/home2')
+    response = self.client.get(self.old_home_path)
     assert_true(doc_id in json.loads(response.context['json_documents']))
-    response = self.client_not_me.get('/home2')
+    response = self.client_not_me.get(self.old_home_path)
     assert_true(doc_id in json.loads(response.context['json_documents']))
 
     # Un-share
@@ -421,9 +421,9 @@ class TestDocModelPermissions():
     assert_false(doc.can_read(self.user_not_me))
     assert_false(doc.can_write(self.user_not_me))
 
-    response = self.client.get('/home2')
+    response = self.client.get(self.old_home_path)
     assert_true(doc_id in json.loads(response.context['json_documents']))
-    response = self.client_not_me.get('/home2')
+    response = self.client_not_me.get(self.old_home_path)
     assert_false(doc_id in json.loads(response.context['json_documents']))
 
     # Modify by group
@@ -452,9 +452,9 @@ class TestDocModelPermissions():
     assert_true(doc.can_read(self.user_not_me))
     assert_true(doc.can_write(self.user_not_me))
 
-    response = self.client.get('/home2')
+    response = self.client.get(self.old_home_path)
     assert_true(doc_id in json.loads(response.context['json_documents']))
-    response = self.client_not_me.get('/home2')
+    response = self.client_not_me.get(self.old_home_path)
     assert_true(doc_id in json.loads(response.context['json_documents']))
 
     # Un-share
@@ -481,9 +481,9 @@ class TestDocModelPermissions():
     assert_false(doc.can_read(self.user_not_me))
     assert_false(doc.can_write(self.user_not_me))
 
-    response = self.client.get('/home2')
+    response = self.client.get(self.old_home_path)
     assert_true(doc_id in json.loads(response.context['json_documents']))
-    response = self.client_not_me.get('/home2')
+    response = self.client_not_me.get(self.old_home_path)
     assert_false(doc_id in json.loads(response.context['json_documents']))
 
   def test_update_permissions_cannot_escalate_privileges(self):