當前位置: 首頁>>代碼示例>>Python>>正文


Python WorkspaceManager.getActiveWorkspace方法代碼示例

本文整理匯總了Python中managers.model_managers.WorkspaceManager.getActiveWorkspace方法的典型用法代碼示例。如果您正苦於以下問題:Python WorkspaceManager.getActiveWorkspace方法的具體用法?Python WorkspaceManager.getActiveWorkspace怎麽用?Python WorkspaceManager.getActiveWorkspace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在managers.model_managers.WorkspaceManager的用法示例。


在下文中一共展示了WorkspaceManager.getActiveWorkspace方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: TestWorkspacesManagement

# 需要導入模塊: from managers.model_managers import WorkspaceManager [as 別名]
# 或者: from managers.model_managers.WorkspaceManager import getActiveWorkspace [as 別名]

#.........這裏部分代碼省略.........
        # FS
        self.wm.createWorkspace(wnamefs, 'a desc', DBTYPE.FS)
        # Couch
        self.wm.createWorkspace(wnamecouch, 'a desc', DBTYPE.COUCHDB)

        self.assertIn(wnamefs, self.wm.getWorkspacesNames(), 'FS Workspace not loaded')
        self.assertIn(wnamecouch, self.wm.getWorkspacesNames(), 'Couch Workspace not loaded')

        self.assertEquals(self.wm.getWorkspaceType(wnamecouch), 'CouchDB', 'Workspace type bad defined' )
        self.assertEquals(self.wm.getWorkspaceType(wnamefs), 'FS', 'Workspace type bad defined') 


    def test_get_workspace(self):
        """ Create a workspace, now ask for it """
        
        # When
        wname = self.new_random_workspace_name()
        workspace = self.wm.createWorkspace(wname, 'a desc', DBTYPE.FS)

        added_workspace = self.wm.openWorkspace(wname)

        # Then
        self.assertIsNotNone(workspace, 'Workspace added should not be none')
        self.assertEquals(workspace, added_workspace, 'Workspace created and added diffier')

    def _test_get_existent_couch_workspace(self): # Deprecate
        """ Create a workspace in the backend, now ask for it """
        
        # When
        wname = self.new_random_workspace_name()
        workspace = self.cdm.addWorkspace(wname)

        added_workspace = self.wm.getWorkspace(wname)

        # Then
        self.assertIsNotNone(added_workspace, 'Workspace added should not be none')

    def _test_get_existent_fs_workspace(self): # Deprecate
        """ Create a workspace in the backend, now ask for it """
        
        # When
        wname = self.new_random_workspace_name()
        workspace = self.fsm.addWorkspace(wname)
        self.wm.loadWorkspaces()

        added_workspace = self.wm.getWorkspace(wname)

        # Then
        self.assertIsNotNone(added_workspace, 'Workspace added should not be none')

    def test_get_non_existent_workspace(self):
        """ Retrieve a non existent workspace """
        
        added_workspace = self.wm.openWorkspace('inventado')

        # Then
        self.assertIsNone(added_workspace, 'Workspace added should not be none') 

    def test_set_active_workspace(self):
        ''' create a workspace through the backend, then set it as active '''

        wname = self.new_random_workspace_name()
        workspace = self.wm.createWorkspace(wname, 'desc', DBTYPE.FS)

        # when
        self.wm.setActiveWorkspace(workspace)

        self.assertEquals(workspace, self.wm.getActiveWorkspace(),
                    'Active workspace diffiers with expected workspace')

        self.assertTrue(self.wm.isActive(workspace.name),
                'Workspace is active flag not set')

    def test_remove_fs_workspace(self):
        # First
        wname = self.new_random_workspace_name()
        added_workspace = self.wm.createWorkspace(wname, 'desc', DBTYPE.FS)

        # When
        self.wm.removeWorkspace(wname) 

        # Then
        self.assertNotIn(wname, self.wm.getWorkspacesNames())
        wpath = os.path.expanduser("~/.faraday/persistence/%s" % wname)
        self.assertFalse(os.path.exists(wpath))

    def test_remove_couch_workspace(self):
        # First
        wname = self.new_random_workspace_name()
        added_workspace = self.wm.createWorkspace(wname, 'desc', DBTYPE.COUCHDB)

        # When
        self.wm.removeWorkspace(wname) 

        # Then
        self.assertNotIn(wname, self.wm.getWorkspacesNames())

    def test_remove_non_existent_workspace(self):
        # When
        self.wm.removeWorkspace('invented') 
開發者ID:BwRy,項目名稱:faraday,代碼行數:104,代碼來源:workspace.py


注:本文中的managers.model_managers.WorkspaceManager.getActiveWorkspace方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。