当前位置: 首页>>代码示例>>Python>>正文


Python client.RemoteDocumentClient类代码示例

本文整理汇总了Python中nxdrive.client.RemoteDocumentClient的典型用法代码示例。如果您正苦于以下问题:Python RemoteDocumentClient类的具体用法?Python RemoteDocumentClient怎么用?Python RemoteDocumentClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了RemoteDocumentClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_register_sync_root_parent

    def test_register_sync_root_parent(self):
        remote = RemoteDocumentClient(self.nuxeo_url, self.user_1, u'nxdrive-test-device-1', self.version,
                                      password=self.password_1, upload_tmp_dir=self.upload_tmp_dir)
        local = self.local_root_client_1

        # First unregister test Workspace
        remote.unregister_as_root(self.workspace)

        # Create a child folder and register it as a synchronization root
        child = remote.make_folder(self.workspace, 'child')
        remote.make_file(child, 'aFile.txt', u'My content')
        remote.register_as_root(child)

        # Start engine and wait for synchronization
        self.engine_1.start()
        self.wait_sync(wait_for_async=True)
        self.assertFalse(local.exists('/Nuxeo Drive Test Workspace'))
        self.assertTrue(local.exists('/child'))
        self.assertTrue(local.exists('/child/aFile.txt'))

        # Register parent folder
        remote.register_as_root(self.workspace)

        # Start engine and wait for synchronization
        self.wait_sync(wait_for_async=True)
        self.assertFalse(local.exists('/child'))
        self.assertTrue(local.exists('/Nuxeo Drive Test Workspace'))
        self.assertTrue(local.exists('/Nuxeo Drive Test Workspace/child'))
        self.assertTrue(local.exists('/Nuxeo Drive Test Workspace/child/aFile.txt'))
开发者ID:Bindupriya,项目名称:nuxeo-drive,代码行数:29,代码来源:test_sync_roots.py

示例2: test_local_rename_sync_root_folder

    def test_local_rename_sync_root_folder(self):
        sb, ctl = self.sb_1, self.controller_1
        # Use the Administrator to be able to introspect the container of the
        # test workspace.
        remote_client = RemoteDocumentClient(
            self.nuxeo_url, self.admin_user,
            'nxdrive-test-administrator-device',
            self.password, base_folder=self.workspace)

        folder_1_uid = remote_client.get_info(u'/Original Folder 1').uid

        # Create new clients to be able to introspect the test sync root
        toplevel_local_client = LocalClient(self.local_nxdrive_folder_1)

        toplevel_local_client.rename('/' + self.workspace_title,
            'Renamed Nuxeo Drive Test Workspace')
        self.assertEquals(ctl.synchronizer.update_synchronize_server(sb), 1)

        workspace_info = remote_client.get_info(self.workspace)
        self.assertEquals(workspace_info.name,
            u"Renamed Nuxeo Drive Test Workspace")

        folder_1_info = remote_client.get_info(folder_1_uid)
        self.assertEquals(folder_1_info.name, u"Original Folder 1")
        self.assertEquals(folder_1_info.parent_uid, self.workspace)

    # TODO: implement me once canDelete is checked in the synchronizer
    # def test_local_move_sync_root_folder(self):
    #    pass
开发者ID:nicolas-raoul,项目名称:nuxeo-drive,代码行数:29,代码来源:test_integration_move_and_rename.py

示例3: test_local_rename_sync_root_folder

    def test_local_rename_sync_root_folder(self):
        if sys.platform.startswith('linux'):
            raise SkipTest("WIP in https://jira.nuxeo.com/browse/NXDRIVE-170")
        # Use the Administrator to be able to introspect the container of the
        # test workspace.
        remote_client = RemoteDocumentClient(
            self.nuxeo_url, self.admin_user,
            'nxdrive-test-administrator-device', self.version,
            password=self.password, base_folder=self.workspace)

        folder_1_uid = remote_client.get_info(u'/Original Folder 1').uid

        # Create new clients to be able to introspect the test sync root
        toplevel_local_client = LocalClient(self.local_nxdrive_folder_1)

        toplevel_local_client.rename('/' + self.workspace_title,
            'Renamed Nuxeo Drive Test Workspace')
        self.wait_sync()

        workspace_info = remote_client.get_info(self.workspace)
        self.assertEquals(workspace_info.name,
            u"Renamed Nuxeo Drive Test Workspace")

        folder_1_info = remote_client.get_info(folder_1_uid)
        self.assertEquals(folder_1_info.name, u"Original Folder 1")
        self.assertEquals(folder_1_info.parent_uid, self.workspace)
开发者ID:bdineshssdi,项目名称:nuxeo-drive,代码行数:26,代码来源:test_local_move_and_rename.py

示例4: test_local_rename_sync_root_folder

    def test_local_rename_sync_root_folder(self):
        # Use the Administrator to be able to introspect the container of the
        # test workspace.
        remote_client = RemoteDocumentClient(
            self.nuxeo_url, self.admin_user,
            'nxdrive-test-administrator-device', self.version,
            password=self.password, base_folder=self.workspace)

        folder_1_uid = remote_client.get_info(u'/Original Folder 1').uid

        # Create new clients to be able to introspect the test sync root
        toplevel_local_client = LocalClient(self.local_nxdrive_folder_1)

        toplevel_local_client.rename('/' + self.workspace_title,
                                     'Renamed Nuxeo Drive Test Workspace')
        self.wait_sync()

        workspace_info = remote_client.get_info(self.workspace)
        self.assertEquals(workspace_info.name,
                          u"Renamed Nuxeo Drive Test Workspace")

        folder_1_info = remote_client.get_info(folder_1_uid)
        self.assertEquals(folder_1_info.name, u"Original Folder 1")
        self.assertEquals(folder_1_info.parent_uid, self.workspace)
        self.assertEqual(len(remote_client.get_children_info(self.workspace_1)), 4)
开发者ID:mkeshava,项目名称:nuxeo-drive,代码行数:25,代码来源:test_local_move_and_rename.py

示例5: setUpServer

    def setUpServer(self, server_profile=None):
        # Long timeout for the root client that is responsible for the test
        # environment set: this client is doing the first query on the Nuxeo
        # server and might need to wait for a long time without failing for
        # Nuxeo to finish initialize the repo on the first request after
        # startup
        self.root_remote_client = RemoteDocumentClient(
            self.nuxeo_url, self.admin_user,
            u'nxdrive-test-administrator-device', self.version,
            password=self.password, base_folder=u'/', timeout=60)

        # Activate given profile if needed, eg. permission hierarchy
        if server_profile is not None:
            self.root_remote_client.activate_profile(server_profile)

        # Call the Nuxeo operation to setup the integration test environment
        credentials = self.root_remote_client.execute(
            "NuxeoDrive.SetupIntegrationTests",
            userNames="user_1, user_2", permission='ReadWrite')

        credentials = [c.strip().split(u":") for c in credentials.split(u",")]
        self.user_1, self.password_1 = credentials[0]
        self.user_2, self.password_2 = credentials[1]
        ws_info = self.root_remote_client.fetch(TEST_WORKSPACE_PATH)
        self.workspace = ws_info[u'uid']
        self.workspace_title = ws_info[u'title']
        self.workspace_1 = self.workspace
        self.workspace_2 = self.workspace
        self.workspace_title_1 = self.workspace_title
        self.workspace_title_2 = self.workspace_title
开发者ID:RajaDG-OpenSource,项目名称:nuxeo-drive,代码行数:30,代码来源:common_unit_test.py

示例6: test_sync_delete_root

    def test_sync_delete_root(self):
        user_workspace_uid = None
        try:
            # Get remote and local clients
            admin_remote_client = self.root_remote_client
            user_remote_client = RemoteDocumentClient(
                self.nuxeo_url, self.user_1, u'nxdrive-test-device-1',
                self.version, password=self.password_1,
                upload_tmp_dir=self.upload_tmp_dir)
            local_client = LocalClient(self.local_nxdrive_folder_1)

            # Make sure user workspace is created and fetch its uid
            user_workspace_uid = user_remote_client.make_file_in_user_workspace('File in user workspace',
                                                                                filename='USFile.txt')['parentRef']

            # Create test folder in user workspace as test user
            test_folder_uid = user_remote_client.make_folder(user_workspace_uid, 'test_folder')
            # Create a document in the test folder
            user_remote_client.make_file(test_folder_uid, 'test_file.txt', "Some content.")

            # Register test folder as a sync root
            user_remote_client.register_as_root(test_folder_uid)

            # Start engine
            self.engine_1.start()

            # Wait for synchronization
            self.wait_sync(wait_for_async=True)

            # Check locally synchronized content
            self.assertTrue(local_client.exists('/My Docs/test_folder'))
            self.assertTrue(local_client.exists('/My Docs/test_folder/test_file.txt'))

            # Delete test folder
            user_remote_client.delete(test_folder_uid)

            # Wait for synchronization
            self.wait_sync(wait_for_async=True)

            # Check locally synchronized content
            self.assertFalse(local_client.exists('/My Docs/test_folder'))
            self.assertEquals(len(local_client.get_children_info('/My Docs')), 0)
        finally:
            # Cleanup user workspace
            if user_workspace_uid is not None and admin_remote_client.exists(user_workspace_uid):
                admin_remote_client.delete(user_workspace_uid,
                                           use_trash=False)
开发者ID:hendrix513,项目名称:nuxeo-drive,代码行数:47,代码来源:test_permission_hierarchy.py

示例7: test_remote_move_to_non_sync_root

    def test_remote_move_to_non_sync_root(self):
        sb, ctl = self.sb_1, self.controller_1
        session = ctl.get_session()

        # Grant ReadWrite permission on Workspaces for test user
        workspaces_path = u'/default-domain/workspaces'
        op_input = "doc:" + workspaces_path
        self.root_remote_client.execute("Document.SetACE",
            op_input=op_input,
            user="nuxeoDriveTestUser_user_1",
            permission="ReadWrite",
            grant="true")

        workspaces_info = self.root_remote_client.fetch(workspaces_path)
        workspaces = workspaces_info[u'uid']

        # Get remote client with Workspaces as base folder and local client
        remote_client = RemoteDocumentClient(
            self.nuxeo_url, self.user_1, u'nxdrive-test-device-1',
            self.version,
            password=self.password_1, base_folder=workspaces,
            upload_tmp_dir=self.upload_tmp_dir)
        local_client = self.local_client_1

        # Create a non synchronized folder
        remote_client.make_folder(u'/', u'Non synchronized folder')

        # Move Original Folder 1 to Non synchronized folder
        remote_client.move(u'/nuxeo-drive-test-workspace/Original Folder 1',
                           u'/Non synchronized folder')
        self.assertFalse(remote_client.exists(
                            u'/nuxeo-drive-test-workspace/Original Folder 1'))
        self.assertTrue(remote_client.exists(
                            u'/Non synchronized folder/Original Folder 1'))

        # Synchronize: the folder move is detected as a deletion
        self.wait_audit_change_finder_if_needed()
        self.wait()
        self.assertEquals(ctl.synchronizer.update_synchronize_server(sb), 1)

        # Check local folder
        self.assertFalse(local_client.exists(u'/Original Folder 1'))
        # Check folder state
        folder_1_state = session.query(LastKnownState).filter_by(
            remote_name=u'Original Folder 1').all()
        self.assertEquals(len(folder_1_state), 0)

        # The more things change, the more they remain the same.
        self.wait_audit_change_finder_if_needed()
        self.wait()
        self.assertEquals(ctl.synchronizer.update_synchronize_server(sb), 0)
开发者ID:jowensla,项目名称:nuxeo-drive,代码行数:51,代码来源:test_integration_remote_move_and_rename.py

示例8: test_remote_move_to_non_sync_root

    def test_remote_move_to_non_sync_root(self):
        # Grant ReadWrite permission on Workspaces for test user
        workspaces_path = u'/default-domain/workspaces'
        op_input = "doc:" + workspaces_path
        self.root_remote_client.execute("Document.SetACE",
            op_input=op_input,
            user="nuxeoDriveTestUser_user_1",
            permission="ReadWrite",
            grant="true")

        workspaces_info = self.root_remote_client.fetch(workspaces_path)
        workspaces = workspaces_info[u'uid']

        # Get remote client with Workspaces as base folder and local client
        remote_client = RemoteDocumentClient(
            self.nuxeo_url, self.user_1, u'nxdrive-test-device-1',
            self.version,
            password=self.password_1, base_folder=workspaces,
            upload_tmp_dir=self.upload_tmp_dir)
        local_client = self.local_client_1

        # Create a non synchronized folder
        unsync_folder = remote_client.make_folder(u'/', u'Non synchronized folder')

        try:
            # Move Original Folder 1 to Non synchronized folder
            remote_client.move(u'/nuxeo-drive-test-workspace/Original Folder 1',
                               u'/Non synchronized folder')
            self.assertFalse(remote_client.exists(
                                u'/nuxeo-drive-test-workspace/Original Folder 1'))
            self.assertTrue(remote_client.exists(
                                u'/Non synchronized folder/Original Folder 1'))

            # Synchronize: the folder move is detected as a deletion
            self.wait_sync(wait_for_async=True)

            # Check local folder
            self.assertFalse(local_client.exists(u'/Original Folder 1'))
            # Check folder state
            folder_1_state = self._get_state(self.folder_1_id)
            self.assertEquals(folder_1_state, None)
        finally:
            # Clean the non synchronized folder
            remote_client.delete(unsync_folder, use_trash=False)
开发者ID:Bindupriya,项目名称:nuxeo-drive,代码行数:44,代码来源:test_remote_move_and_rename.py

示例9: setUpApp

    def setUpApp(self, server_profile=None):
        # Check the Nuxeo server test environment
        self.nuxeo_url = os.environ.get('NXDRIVE_TEST_NUXEO_URL')
        self.admin_user = os.environ.get('NXDRIVE_TEST_USER')
        self.password = os.environ.get('NXDRIVE_TEST_PASSWORD')
        self.build_workspace = os.environ.get('WORKSPACE')
        self.result = None
        self.tearedDown = False

        # Take default parameter if none has been set
        if self.nuxeo_url is None:
            self.nuxeo_url = "http://localhost:8080/nuxeo"
        if self.admin_user is None:
            self.admin_user = "Administrator"
        if self.password is None:
            self.password = "Administrator"
        self.tmpdir = None
        if self.build_workspace is not None:
            self.tmpdir = os.path.join(self.build_workspace, "tmp")
            if not os.path.isdir(self.tmpdir):
                os.makedirs(self.tmpdir)
        self.upload_tmp_dir = tempfile.mkdtemp(u'-nxdrive-uploads', dir=self.tmpdir)

        if None in (self.nuxeo_url, self.admin_user, self.password):
            raise unittest.SkipTest(
                "No integration server configuration found in environment.")

        # Check the local filesystem test environment
        self.local_test_folder_1 = tempfile.mkdtemp(u'-nxdrive-tests-user-1', dir=self.tmpdir)
        self.local_test_folder_2 = tempfile.mkdtemp(u'-nxdrive-tests-user-2', dir=self.tmpdir)

        self.local_nxdrive_folder_1 = os.path.join(
            self.local_test_folder_1, u'Nuxeo Drive')
        os.mkdir(self.local_nxdrive_folder_1)
        self.local_nxdrive_folder_2 = os.path.join(
            self.local_test_folder_2, u'Nuxeo Drive')
        os.mkdir(self.local_nxdrive_folder_2)

        self.nxdrive_conf_folder_1 = os.path.join(
            self.local_test_folder_1, u'nuxeo-drive-conf')
        os.mkdir(self.nxdrive_conf_folder_1)
        self.nxdrive_conf_folder_2 = os.path.join(
            self.local_test_folder_2, u'nuxeo-drive-conf')
        os.mkdir(self.nxdrive_conf_folder_2)

        from mock import Mock
        options = Mock()
        options.debug = False
        options.delay = TEST_DEFAULT_DELAY
        options.force_locale = None
        options.proxy_server = None
        options.log_level_file = None
        options.update_site_url = None
        options.beta_update_site_url = None
        options.autolock_interval = 30
        options.nxdrive_home = self.nxdrive_conf_folder_1
        self.manager_1 = Manager(options)
        self.connected = False
        import nxdrive
        nxdrive_path = os.path.dirname(nxdrive.__file__)
        i18n_path = os.path.join(nxdrive_path, 'tests', 'resources', "i18n.js")
        Translator(self.manager_1, i18n_path)
        options.nxdrive_home = self.nxdrive_conf_folder_2
        Manager._singleton = None
        self.manager_2 = Manager(options)
        self.version = __version__
        url = self.nuxeo_url
        log.debug("Will use %s as url", url)
        if '#' in url:
            # Remove the engine type for the rest of the test
            self.nuxeo_url = url.split('#')[0]
        self.setUpServer(server_profile)

        self.engine_1 = self.manager_1.bind_server(self.local_nxdrive_folder_1, url, self.user_1,
                                                   self.password_1, start_engine=False)
        self.engine_2 = self.manager_2.bind_server(self.local_nxdrive_folder_2, url, self.user_2,
                                                   self.password_2, start_engine=False)
        self.engine_1.syncCompleted.connect(self.app.sync_completed)
        self.engine_1.get_remote_watcher().remoteScanFinished.connect(self.app.remote_scan_completed)
        self.engine_1.get_remote_watcher().changesFound.connect(self.app.remote_changes_found)
        self.engine_1.get_remote_watcher().noChangesFound.connect(self.app.no_remote_changes_found)
        self.engine_2.syncCompleted.connect(self.app.sync_completed)
        self.engine_2.get_remote_watcher().remoteScanFinished.connect(self.app.remote_scan_completed)
        self.engine_2.get_remote_watcher().changesFound.connect(self.app.remote_changes_found)
        self.engine_2.get_remote_watcher().noChangesFound.connect(self.app.no_remote_changes_found)
        self.queue_manager_1 = self.engine_1.get_queue_manager()
        self.queue_manager_2 = self.engine_2.get_queue_manager()

        self.sync_root_folder_1 = os.path.join(self.local_nxdrive_folder_1, self.workspace_title_1)
        self.sync_root_folder_2 = os.path.join(self.local_nxdrive_folder_2, self.workspace_title_2)

        self.local_root_client_1 = self.engine_1.get_local_client()
        self.local_root_client_2 = self.engine_2.get_local_client()
        self.local_client_1 = LocalClient(os.path.join(self.local_nxdrive_folder_1, self.workspace_title_1))
        self.local_client_2 = LocalClient(os.path.join(self.local_nxdrive_folder_2, self.workspace_title_2))

        # Document client to be used to create remote test documents
        # and folders
        remote_document_client_1 = RemoteDocumentClient(
            self.nuxeo_url, self.user_1, u'nxdrive-test-device-1',
#.........这里部分代码省略.........
开发者ID:RajaDG-OpenSource,项目名称:nuxeo-drive,代码行数:101,代码来源:common_unit_test.py

示例10: UnitTestCase

class UnitTestCase(unittest.TestCase):

    def setUpServer(self, server_profile=None):
        # Long timeout for the root client that is responsible for the test
        # environment set: this client is doing the first query on the Nuxeo
        # server and might need to wait for a long time without failing for
        # Nuxeo to finish initialize the repo on the first request after
        # startup
        self.root_remote_client = RemoteDocumentClient(
            self.nuxeo_url, self.admin_user,
            u'nxdrive-test-administrator-device', self.version,
            password=self.password, base_folder=u'/', timeout=60)

        # Activate given profile if needed, eg. permission hierarchy
        if server_profile is not None:
            self.root_remote_client.activate_profile(server_profile)

        # Call the Nuxeo operation to setup the integration test environment
        credentials = self.root_remote_client.execute(
            "NuxeoDrive.SetupIntegrationTests",
            userNames="user_1, user_2", permission='ReadWrite')

        credentials = [c.strip().split(u":") for c in credentials.split(u",")]
        self.user_1, self.password_1 = credentials[0]
        self.user_2, self.password_2 = credentials[1]
        ws_info = self.root_remote_client.fetch(TEST_WORKSPACE_PATH)
        self.workspace = ws_info[u'uid']
        self.workspace_title = ws_info[u'title']
        self.workspace_1 = self.workspace
        self.workspace_2 = self.workspace
        self.workspace_title_1 = self.workspace_title
        self.workspace_title_2 = self.workspace_title

    def tearDownServer(self, server_profile=None):
        # Don't need to revoke tokens for the file system remote clients
        # since they use the same users as the remote document clients
        self.root_remote_client.execute("NuxeoDrive.TearDownIntegrationTests")

        # Deactivate given profile if needed, eg. permission hierarchy
        if server_profile is not None:
            self.root_remote_client.deactivate_profile(server_profile)

    def setUpApp(self, server_profile=None):
        # Check the Nuxeo server test environment
        self.nuxeo_url = os.environ.get('NXDRIVE_TEST_NUXEO_URL')
        self.admin_user = os.environ.get('NXDRIVE_TEST_USER')
        self.password = os.environ.get('NXDRIVE_TEST_PASSWORD')
        self.build_workspace = os.environ.get('WORKSPACE')
        self.result = None
        self.tearedDown = False

        # Take default parameter if none has been set
        if self.nuxeo_url is None:
            self.nuxeo_url = "http://localhost:8080/nuxeo"
        if self.admin_user is None:
            self.admin_user = "Administrator"
        if self.password is None:
            self.password = "Administrator"
        self.tmpdir = None
        if self.build_workspace is not None:
            self.tmpdir = os.path.join(self.build_workspace, "tmp")
            if not os.path.isdir(self.tmpdir):
                os.makedirs(self.tmpdir)
        self.upload_tmp_dir = tempfile.mkdtemp(u'-nxdrive-uploads', dir=self.tmpdir)

        if None in (self.nuxeo_url, self.admin_user, self.password):
            raise unittest.SkipTest(
                "No integration server configuration found in environment.")

        # Check the local filesystem test environment
        self.local_test_folder_1 = tempfile.mkdtemp(u'-nxdrive-tests-user-1', dir=self.tmpdir)
        self.local_test_folder_2 = tempfile.mkdtemp(u'-nxdrive-tests-user-2', dir=self.tmpdir)

        self.local_nxdrive_folder_1 = os.path.join(
            self.local_test_folder_1, u'Nuxeo Drive')
        os.mkdir(self.local_nxdrive_folder_1)
        self.local_nxdrive_folder_2 = os.path.join(
            self.local_test_folder_2, u'Nuxeo Drive')
        os.mkdir(self.local_nxdrive_folder_2)

        self.nxdrive_conf_folder_1 = os.path.join(
            self.local_test_folder_1, u'nuxeo-drive-conf')
        os.mkdir(self.nxdrive_conf_folder_1)
        self.nxdrive_conf_folder_2 = os.path.join(
            self.local_test_folder_2, u'nuxeo-drive-conf')
        os.mkdir(self.nxdrive_conf_folder_2)

        from mock import Mock
        options = Mock()
        options.debug = False
        options.delay = TEST_DEFAULT_DELAY
        options.force_locale = None
        options.proxy_server = None
        options.log_level_file = None
        options.update_site_url = None
        options.beta_update_site_url = None
        options.autolock_interval = 30
        options.nxdrive_home = self.nxdrive_conf_folder_1
        self.manager_1 = Manager(options)
        self.connected = False
#.........这里部分代码省略.........
开发者ID:RajaDG-OpenSource,项目名称:nuxeo-drive,代码行数:101,代码来源:common_unit_test.py

示例11: test_sync_delete_shared_folder

    def test_sync_delete_shared_folder(self):
        user_workspaces_path = '/default-domain/UserWorkspaces/'
        user1_workspace_title = 'nuxeoDriveTestUser-user-1'
        user1_workspace_path = user_workspaces_path + user1_workspace_title
        try:
            # Get remote and local clients
            admin_remote_client = self.root_remote_client
            user1_remote_client = RemoteDocumentClient(
                self.nuxeo_url, self.user_1, u'nxdrive-test-device-1',
                self.version, password=self.password_1,
                upload_tmp_dir=self.upload_tmp_dir)
            user2_remote_client = RemoteDocumentClient(
                self.nuxeo_url, self.user_2, u'nxdrive-test-device-2',
                self.version, password=self.password_2,
                upload_tmp_dir=self.upload_tmp_dir)
            local_client_1 = LocalClient(self.local_nxdrive_folder_1)

            # Activate permission hierarchy profile as Administrator
            admin_remote_client.activate_profile('permission')

            # Make sure user1 workspace is created
            user1_remote_client.make_file_in_user_workspace(
                                                    'File in user workspace',
                                                    filename='USFile.txt')

            # Register user workspace as a sync root for user1
            user1_remote_client.register_as_root(user1_workspace_path)

            # Bind server for user1
            ctl_1 = self.controller_1
            ctl_1.bind_server(self.local_nxdrive_folder_1, self.nuxeo_url,
                            self.user_1, self.password_1)
            syn_1 = ctl_1.synchronizer

            # Synchronize
            self._synchronize(syn_1)
            # Check locally synchronized content
            self.assertTrue(local_client_1.exists('/My Docs'))

            # Create test folder in user workspace as user1
            user1_remote_client.make_folder(user1_workspace_path,
                                            'test_folder')
            # Synchronize
            self._synchronize(syn_1)
            # Check locally synchronized content
            self.assertTrue(local_client_1.exists('/My Docs/test_folder'))

            # Grant ReadWrite permission to user2 on test folder
            test_folder_path = user1_workspace_path + '/test_folder'
            op_input = "doc:" + test_folder_path
            admin_remote_client.execute("Document.SetACE",
                op_input=op_input,
                user="nuxeoDriveTestUser_user_2",
                permission="ReadWrite",
                grant="true")

            # Register test folder as a sync root for user2
            user2_remote_client.register_as_root(test_folder_path)

            # Wait for a while:
            time.sleep(2.0)

            # Delete test folder
            user1_remote_client.delete(test_folder_path)

            # Synchronize
            self._synchronize(syn_1)
            # Check locally synchronized content
            self.assertFalse(local_client_1.exists('/My Docs/test_folder'))
            self.assertEquals(len(local_client_1.get_children_info(
                                                            '/My Docs')), 1)
        finally:
            # Cleanup user workspace
            if admin_remote_client.exists(user1_workspace_path):
                admin_remote_client.delete(user1_workspace_path,
                                           use_trash=False)
            # Deactivate permission hierarchy profile
            admin_remote_client.deactivate_profile('permission')
开发者ID:mzly84,项目名称:nuxeo-drive,代码行数:78,代码来源:test_integration_permission_hierarchy.py

示例12: setUp

    def setUp(self):
        # Check the Nuxeo server test environment
        self.nuxeo_url = os.environ.get('NXDRIVE_TEST_NUXEO_URL')
        self.admin_user = os.environ.get('NXDRIVE_TEST_USER')
        self.password = os.environ.get('NXDRIVE_TEST_PASSWORD')
        self.build_workspace = os.environ.get('WORKSPACE')

        # Take default parameter if none has been set
        if self.nuxeo_url is None:
            self.nuxeo_url = "http://localhost:8080/nuxeo"
        if self.admin_user is None:
            self.admin_user = "Administrator"
        if self.password is None:
            self.password = "Administrator"
        self.tmpdir = None
        if self.build_workspace is not None:
            self.tmpdir = os.path.join(self.build_workspace, "tmp")
            if not os.path.isdir(self.tmpdir):
                os.makedirs(self.tmpdir)

        if None in (self.nuxeo_url, self.admin_user, self.password):
            raise unittest.SkipTest(
                "No integration server configuration found in environment.")

        # Check the local filesystem test environment
        self.local_test_folder_1 = tempfile.mkdtemp(u'-nxdrive-tests-user-1', dir=self.tmpdir)
        self.local_test_folder_2 = tempfile.mkdtemp(u'-nxdrive-tests-user-2', dir=self.tmpdir)

        self.local_nxdrive_folder_1 = os.path.join(
            self.local_test_folder_1, u'Nuxeo Drive')
        os.mkdir(self.local_nxdrive_folder_1)
        self.local_nxdrive_folder_2 = os.path.join(
            self.local_test_folder_2, u'Nuxeo Drive')
        os.mkdir(self.local_nxdrive_folder_2)

        self.nxdrive_conf_folder_1 = os.path.join(
            self.local_test_folder_1, u'nuxeo-drive-conf')
        os.mkdir(self.nxdrive_conf_folder_1)

        self.nxdrive_conf_folder_2 = os.path.join(
            self.local_test_folder_2, u'nuxeo-drive-conf')
        os.mkdir(self.nxdrive_conf_folder_2)

        self.version = nxdrive.__version__

        # Long timeout for the root client that is responsible for the test
        # environment set: this client is doing the first query on the Nuxeo
        # server and might need to wait for a long time without failing for
        # Nuxeo to finish initialize the repo on the first request after
        # startup
        root_remote_client = RemoteDocumentClient(
            self.nuxeo_url, self.admin_user,
            u'nxdrive-test-administrator-device', self.version,
            password=self.password, base_folder=u'/', timeout=60)

        # Call the Nuxeo operation to setup the integration test environment
        credentials = root_remote_client.execute(
            "NuxeoDrive.SetupIntegrationTests",
            userNames="user_1, user_2", permission='ReadWrite')

        credentials = [c.strip().split(u":") for c in credentials.split(u",")]
        self.user_1, self.password_1 = credentials[0]
        self.user_2, self.password_2 = credentials[1]

        ws_info = root_remote_client.fetch(TEST_WORKSPACE_PATH)
        self.workspace = ws_info[u'uid']
        self.workspace_title = ws_info[u'title']

        # Document client to be used to create remote test documents
        # and folders
        self.upload_tmp_dir = tempfile.mkdtemp(u'-nxdrive-uploads', dir=self.tmpdir)
        remote_document_client_1 = RemoteDocumentClient(
            self.nuxeo_url, self.user_1, u'nxdrive-test-device-1',
            self.version,
            password=self.password_1, base_folder=self.workspace,
            upload_tmp_dir=self.upload_tmp_dir)

        remote_document_client_2 = RemoteDocumentClient(
            self.nuxeo_url, self.user_2, u'nxdrive-test-device-2',
            self.version,
            password=self.password_2, base_folder=self.workspace,
            upload_tmp_dir=self.upload_tmp_dir)

        # File system client to be used to create remote test documents
        # and folders
        remote_file_system_client_1 = RemoteFileSystemClient(
            self.nuxeo_url, self.user_1, u'nxdrive-test-device-1',
            self.version,
            password=self.password_1, upload_tmp_dir=self.upload_tmp_dir)

        remote_file_system_client_2 = RemoteFileSystemClient(
            self.nuxeo_url, self.user_2, u'nxdrive-test-device-2',
            self.version,
            password=self.password_2, upload_tmp_dir=self.upload_tmp_dir)

        self.root_remote_client = root_remote_client
        self.remote_document_client_1 = remote_document_client_1
        self.remote_document_client_2 = remote_document_client_2
        self.remote_file_system_client_1 = remote_file_system_client_1
        self.remote_file_system_client_2 = remote_file_system_client_2
#.........这里部分代码省略.........
开发者ID:mohgly,项目名称:nuxeo-drive,代码行数:101,代码来源:common.py

示例13: test_sync_unshared_folder

    def test_sync_unshared_folder(self):
        user_workspace_uid = None
        try:
            # Get remote and local clients
            admin_remote_client = self.root_remote_client
            user1_remote_client = RemoteDocumentClient(
                self.nuxeo_url, self.user_1, u'nxdrive-test-device-1',
                self.version, password=self.password_1,
                upload_tmp_dir=self.upload_tmp_dir)
            user2_remote_client = RemoteDocumentClient(
                self.nuxeo_url, self.user_2, u'nxdrive-test-device-2',
                self.version, password=self.password_2,
                upload_tmp_dir=self.upload_tmp_dir)
            local_client_1 = LocalClient(self.local_nxdrive_folder_1)
            local_client_2 = LocalClient(self.local_nxdrive_folder_2)

            # Make sure user1 workspace is created and fetch its uid
            user_workspace_uid = user1_remote_client.make_file_in_user_workspace('File in user workspace',
                                                                                 filename='USFile.txt')['parentRef']

            # Register user workspace as a sync root for user1
            user1_remote_client.register_as_root(user_workspace_uid)

            # Start engine
            self.engine_2.start()

            # Wait for synchronization
            self.wait_sync(wait_for_async=True, wait_for_engine_2=True, wait_for_engine_1=False)
            # Check locally synchronized content
            self.assertTrue(local_client_2.exists('/My Docs'))
            self.assertTrue(local_client_2.exists('/Other Docs'))

            # Create test folder in user workspace as user1
            test_folder_uid = user1_remote_client.make_folder(user_workspace_uid, 'Folder A')
            folder_b = user1_remote_client.make_folder(test_folder_uid, 'Folder B')
            folder_c = user1_remote_client.make_folder(folder_b, 'Folder C')
            folder_d = user1_remote_client.make_folder(folder_c, 'Folder D')
            folder_e = user1_remote_client.make_folder(folder_d, 'Folder E')

            # Grant ReadWrite permission to user2 on test folder
            op_input = "doc:" + test_folder_uid
            admin_remote_client.execute("Document.SetACE", op_input=op_input, user=self.user_2,
                                        permission="ReadWrite", grant="true")

            # Register test folder as a sync root for user2
            user2_remote_client.register_as_root(test_folder_uid)
            # Wait for synchronization
            self.wait_sync(wait_for_async=True, wait_for_engine_2=True, wait_for_engine_1=False)
            self.assertTrue(local_client_2.exists('/Other Docs/Folder A'))
            self.assertTrue(local_client_2.exists('/Other Docs/Folder A/Folder B/Folder C/Folder D/Folder E'))
            # Use for later get_fs_item checks
            folder_b_fs = local_client_2.get_remote_id('/Other Docs/Folder A/Folder B')
            folder_a_fs = local_client_2.get_remote_id('/Other Docs/Folder A')
            # Unshare Folder A and share Folder C
            admin_remote_client.execute("Document.RemoveACL", op_input=op_input, acl='local')
            op_input = "doc:" + folder_c
            admin_remote_client.execute("Document.SetACE", op_input=op_input, user=self.user_2,
                                        permission="Read", grant="true")
            user2_remote_client.register_as_root(folder_c)
            self.wait_sync(wait_for_async=True, wait_for_engine_2=True, wait_for_engine_1=False)
            self.assertFalse(local_client_2.exists('/Other Docs/Folder A'))
            self.assertTrue(local_client_2.exists('/Other Docs/Folder C'))
            self.assertTrue(local_client_2.exists('/Other Docs/Folder C/Folder D/Folder E'))

            # Verify that we dont have any 403 errors
            self.assertIsNone(self.remote_file_system_client_2.get_fs_item(folder_a_fs))
            self.assertIsNone(self.remote_file_system_client_2.get_fs_item(folder_b_fs))
        finally:
            # Cleanup user workspace
            if user_workspace_uid is not None and admin_remote_client.exists(user_workspace_uid):
                admin_remote_client.delete(user_workspace_uid,
                                           use_trash=False)
开发者ID:hendrix513,项目名称:nuxeo-drive,代码行数:72,代码来源:test_permission_hierarchy.py

示例14: test_sync_delete_root

    def test_sync_delete_root(self):
        try:
            user_workspaces_path = '/default-domain/UserWorkspaces/'
            user_workspace_title = 'nuxeoDriveTestUser_user_1'
            user_workspace_path = user_workspaces_path + user_workspace_title

            # Get remote and local clients
            admin_remote_client = self.root_remote_client
            user_remote_client = RemoteDocumentClient(
                self.nuxeo_url, self.user_1, u'nxdrive-test-device-1',
                self.version, password=self.password_1,
                upload_tmp_dir=self.upload_tmp_dir)
            local_client = LocalClient(self.local_nxdrive_folder_1)

            # Activate permission hierarchy profile as Administrator
            admin_remote_client.activate_profile('permission')

            # Bind server
            ctl = self.controller_1
            ctl.bind_server(self.local_nxdrive_folder_1, self.nuxeo_url,
                            self.user_1, self.password_1)
            syn = ctl.synchronizer

            # Create user workspace parent as Administrator if it doesn't exist
            if not admin_remote_client.exists(user_workspaces_path):
                admin_remote_client.make_folder('/default-domain',
                                                'UserWorkspaces',
                                                doc_type='UserWorkspacesRoot')

            # Create test user workspace as Administrator
            admin_remote_client.make_folder(user_workspaces_path,
                                           user_workspace_title,
                                           doc_type='Workspace')
            # Grant ReadWrite permission to test user on its workspace
            op_input = "doc:" + user_workspace_path
            admin_remote_client.execute("Document.SetACE",
                op_input=op_input,
                user="nuxeoDriveTestUser_user_1",
                permission="ReadWrite",
                grant="true")

            # Create test folder in user workspace as test user
            user_remote_client.make_folder(user_workspace_path, 'test_folder')
            test_folder_path = user_workspace_path + '/test_folder'
            # Create a document in the test folder
            user_remote_client.make_file(test_folder_path, 'test_file.txt',
                                        "Some content.")

            # Register test folder as a sync root
            user_remote_client.register_as_root(test_folder_path)

            # Synchronize
            self._synchronize(syn)

            # Check locally synchronized content
            self.assertTrue(local_client.exists('/My Docs/test_folder'))
            self.assertTrue(local_client.exists(
                                        '/My Docs/test_folder/test_file.txt'))

            # Delete test folder
            user_remote_client.delete(test_folder_path)

            # Synchronize
            self._synchronize(syn)

            # Check locally synchronized content
            self.assertFalse(local_client.exists('/My Docs/test_folder'))
            self.assertEquals(len(local_client.get_children_info('/My Docs')),
                              0)
        finally:
            # Cleanup user workspace
            if admin_remote_client.exists(user_workspace_path):
                admin_remote_client.delete(user_workspace_path,
                                           use_trash=False)
            # Deactivate permission hierarchy profile
            admin_remote_client.deactivate_profile('permission')
开发者ID:couade,项目名称:nuxeo-drive,代码行数:76,代码来源:test_integration_permission_hierarchy.py

示例15: test_migration_db_v1

    def test_migration_db_v1(self):
        # Initialize old DB
        db = open(self._get_db('test_manager_migration.db'), 'rb')
        old_db = os.path.join(self.test_folder, 'nxdrive.db')
        with open(old_db, 'wb') as f:
            f.write(db.read())
        db.close()

        # Update token with one acquired against the test server
        conn = sqlite3.connect(old_db)
        c = conn.cursor()
        device_id = c.execute("SELECT device_id FROM device_config LIMIT 1").fetchone()[0]
        remote_client = RemoteDocumentClient(self.nuxeo_url, self.admin_user, device_id, nxdrive.__version__,
                                             password=self.admin_password)
        token = remote_client.request_token()
        c.execute("UPDATE server_bindings SET remote_token='%s' WHERE local_folder='%s'" % (
            token, '/home/ataillefer/Nuxeo Drive'))

        # Update server URL with test server URL
        c.execute("UPDATE server_bindings SET server_url='%s' WHERE local_folder='%s'" % (
            self.nuxeo_url, '/home/ataillefer/Nuxeo Drive'))

        # Update local folder with test temp dir
        local_folder = os.path.join(self.test_folder, 'Nuxeo Drive')
        c.execute("UPDATE server_bindings SET local_folder='%s' WHERE local_folder='%s'" % (
            local_folder, '/home/ataillefer/Nuxeo Drive'))
        conn.commit()
        conn.close()

        # Create Manager with old DB migration
        manager = self._create_manager()
        dao = manager.get_dao()

        # Check Manager config
        self.assertEquals(dao.get_config('device_id'), device_id)
        self.assertEquals(dao.get_config('proxy_config'), 'Manual')
        self.assertEquals(dao.get_config('proxy_type'), 'http')
        self.assertEquals(dao.get_config('proxy_server'), 'proxy.server.com')
        self.assertEquals(dao.get_config('proxy_port'), '80')
        self.assertEquals(dao.get_config('proxy_authenticated'), '1')
        self.assertEquals(dao.get_config('proxy_username'), 'Administrator')
        self.assertEquals(dao.get_config('auto_update'), '1')
        self.assertEquals(dao.get_config('proxy_config'), 'Manual')

        # Check engine definition
        engines = dao.get_engines()
        self.assertEquals(len(engines), 1)
        engine = engines[0]
        self.assertEquals(engine.engine, 'NXDRIVE')
        self.assertEquals(engine.name, manager._get_engine_name(self.nuxeo_url))
        self.assertTrue(local_folder in engine.local_folder)

        # Check engine config
        engine_uid = engine.uid
        engine_db = os.path.join(self.test_folder, 'ndrive_%s.db' % engine_uid)
        engine_dao = EngineDAO(engine_db)
        self.assertEquals(engine_dao.get_config('server_url'), self.nuxeo_url)
        self.assertEquals(engine_dao.get_config('remote_user'), 'Administrator')
        self.assertEquals(engine_dao.get_config('remote_token'), token)

        engine_dao.dispose()
        manager.dispose_all()
开发者ID:mohgly,项目名称:nuxeo-drive,代码行数:62,代码来源:test_manager_dao.py


注:本文中的nxdrive.client.RemoteDocumentClient类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。