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


Python model_managers.WorkspaceManager類代碼示例

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


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

示例1: testOpenWorkspaceChangesAndReportManagerWatch

    def testOpenWorkspaceChangesAndReportManagerWatch(self):
        reportManager = mock()

        dbManager = mock()
        mappersManager = mock()
        dbConnector = mock()
        mappers = mock()
        changesController = mock()
        workspaceMapper = mock()

        workspace = Workspace('test_workspace', 'a desc')

        when(dbManager).getAllDbNames().thenReturn(['test_workspace'])
        when(dbManager).getConnector('test_workspace').thenReturn(dbConnector)
        when(mappersManager).createMappers(dbConnector).thenReturn(True)
        when(mappersManager).getMapper(Workspace.__name__).thenReturn(workspaceMapper)
        when(workspaceMapper).find('test_workspace').thenReturn(workspace)

        workspace_manager = WorkspaceManager(dbManager,
                                mappersManager,
                                changesController,
                                reportManager)


        opened_workspace = workspace_manager.openWorkspace('test_workspace')

        verify(reportManager).watch('test_workspace')
        verify(changesController).watch(mappersManager, dbConnector)
        self.assertEquals(opened_workspace.getName(), 'test_workspace')
開發者ID:BecomingMore,項目名稱:faraday,代碼行數:29,代碼來源:workspace_manager.py

示例2: testCreateWorkspaceDBManagerInteract

    def testCreateWorkspaceDBManagerInteract(self):
        dbManager = mock()
        dbConnector = mock()
        changesController = mock()

        when(dbManager).createDb('test_workspace', DBTYPE.FS).thenReturn(dbConnector)
        workspace_manager = WorkspaceManager(dbManager, mock(), changesController, mock())
        workspace_manager.createWorkspace('test_workspace', 'a test workspace',
                                        DBTYPE.FS)
        verify(dbManager).createDb('test_workspace', DBTYPE.FS)
開發者ID:BecomingMore,項目名稱:faraday,代碼行數:10,代碼來源:workspace_manager.py

示例3: testGetWorkspaceTypeFS

    def testGetWorkspaceTypeFS(self):
        work = Workspace('testname')
        dbManager = mock()
        mappersManager = mock()
        changesController = mock()
        when(dbManager).getDbType('testname').thenReturn(DBTYPE.FS)
        workspace_manager = WorkspaceManager(dbManager, mappersManager, changesController, mock())

        wtype = workspace_manager.getWorkspaceType(work.getName())
        self.assertEquals(wtype, 'FS', 'Workspace type not returning correct value')
開發者ID:BecomingMore,項目名稱:faraday,代碼行數:10,代碼來源:workspace_manager.py

示例4: testGetAvailableWorkspaceTypes

    def testGetAvailableWorkspaceTypes(self): 
        dbManager = mock()
        workspace_manager = WorkspaceManager(dbManager,
                                                mock(),
                                                mock(),
                                                mock())
        when(dbManager).getAvailableDBs().thenReturn([DBTYPE.COUCHDB, DBTYPE.FS])
        retrievedTypes = workspace_manager.getAvailableWorkspaceTypes()

        self.assertListEqual(['CouchDB', 'FS'], retrievedTypes, 
                                    "Workspaces available Types not set")
開發者ID:BecomingMore,項目名稱:faraday,代碼行數:11,代碼來源:workspace_manager.py

示例5: testSetActiveWorkspace

    def testSetActiveWorkspace(self):
        work = Workspace('testname')
        dbManager = mock()
        mappersManager = mock()
        changesController = mock()
        workspace_manager = WorkspaceManager(dbManager, mappersManager, changesController, mock())

        workspace_manager.setActiveWorkspace(work)

        self.assertEquals(workspace_manager.active_workspace, work,
                'active workspace not set')
        self.assertTrue(workspace_manager.isActive(work.getName()),
                'could not retrive as active workspace')
開發者ID:BecomingMore,項目名稱:faraday,代碼行數:13,代碼來源:workspace_manager.py

示例6: testCloseWorkspace

    def testCloseWorkspace(self):
        dbManager = mock()
        mappersManager = mock()
        changesController = mock()
        reportManager = mock()


        workspace_manager = WorkspaceManager(dbManager,
                                                mappersManager,
                                                changesController,
                                                reportManager)

        workspace_manager.closeWorkspace()
        verify(changesController).unwatch()
開發者ID:BecomingMore,項目名稱:faraday,代碼行數:14,代碼來源:workspace_manager.py

示例7: testResourceManager

    def testResourceManager(self):
        dbManager = mock()
        mappersManager = mock()
        changesController = mock()
        reportManager = mock()


        workspace_manager = WorkspaceManager(dbManager,
                                                mappersManager,
                                                changesController,
                                                reportManager)

        workspace_manager.resource()

        verify(dbManager).reloadConfig()
開發者ID:BecomingMore,項目名稱:faraday,代碼行數:15,代碼來源:workspace_manager.py

示例8: testRemoveWorkspace

    def testRemoveWorkspace(self):
        dbManager = mock()
        mappersManager = mock()
        dbConnector = mock()
        mappers = mock()
        changesController = mock()

        workspace = Workspace('test_workspace', 'a desc')
        when(dbManager).removeDb('test_workspace').thenReturn(True)
        when(dbManager).getAllDbNames().thenReturn(['test_workspace'])

        workspace_manager = WorkspaceManager(dbManager, mappersManager, changesController, mock())
        remove_ret = workspace_manager.removeWorkspace('test_workspace')

        verify(dbManager).removeDb('test_workspace')
        self.assertTrue(remove_ret, 'bbdd not removed')
開發者ID:BecomingMore,項目名稱:faraday,代碼行數:16,代碼來源:workspace_manager.py

示例9: testCreateWorkspaceSetsChangesCallback

    def testCreateWorkspaceSetsChangesCallback(self):
        dbManager = mock()
        mappersManager = mock()
        dbConnector = mock()
        mappers = mock()
        changesController = mock()

        when(mappersManager).save(any()).thenReturn(True) 
        when(dbManager).createDb('test_workspace', DBTYPE.FS).thenReturn(dbConnector)
        when(mappersManager).createMappers(dbConnector).thenReturn(True) 

        workspace_manager = WorkspaceManager(dbManager, mappersManager, changesController, mock())
        workspace = workspace_manager.createWorkspace('test_workspace', 'a test workspace',
                                        DBTYPE.FS)

        verify(changesController).watch(mappersManager, dbConnector)
開發者ID:BecomingMore,項目名稱:faraday,代碼行數:16,代碼來源:workspace_manager.py

示例10: __init__

    def __init__(self, args):
        self._original_excepthook = sys.excepthook

        self._configuration = CONF

        self._security_manager = SecurityManager()
        self._mappers_manager = MapperManager()
        self._changes_controller = ChangeController()
        self._db_manager = DbManager()

        self._model_controller = ModelController(self._security_manager, self._mappers_manager)

        self._plugin_manager = PluginManager(os.path.join(CONF.getConfigPath(), "plugins"), self._mappers_manager)

        self._reports_manager = ReportManager(10, self._plugin_manager.createController("ReportManager"))

        self._workspace_manager = WorkspaceManager(
            self._db_manager, self._mappers_manager, self._changes_controller, self._reports_manager
        )

        self.gui_app = UiFactory.create(self._model_controller, self._plugin_manager, self._workspace_manager, args.gui)

        self.gui_app.setSplashImage(os.path.join(CONF.getImagePath(), "splash2.png"))

        self.timer = TimerClass()
        self.timer.start()
開發者ID:diokhancze,項目名稱:faraday,代碼行數:26,代碼來源:application.py

示例11: testOpenWorkspaceNoneExisting

    def testOpenWorkspaceNoneExisting(self):
        dbManager = mock()
        mappersManager = mock()
        dbConnector = mock()
        mappers = mock()
        changesController = mock()

        workspace = Workspace('test_workspace', 'a desc') 
        when(dbManager).getAllDbNames().thenReturn([])

        workspace_manager = WorkspaceManager(dbManager, mappersManager, changesController, mock())
        opened_workspace = workspace_manager.openWorkspace('test_workspace')


        verify(mappersManager, times=0).createMappers(dbConnector)
        verify(mappersManager, times=0).find('test_workspace')
        self.assertFalse(opened_workspace, 'Workspace retrieved but non existing')
開發者ID:BecomingMore,項目名稱:faraday,代碼行數:17,代碼來源:workspace_manager.py

示例12: testCreateExistingWorkspaceReturnsFalse

    def testCreateExistingWorkspaceReturnsFalse(self):
        dbManager = mock()
        mappersManager = mock()
        dbConnector = mock()
        mappers = mock()
        changesController = mock()

        when(mappersManager).save(any()).thenReturn(True) 
        when(dbManager).createDb('test_workspace', DBTYPE.FS).thenReturn(False)
        when(mappersManager).createMappers(dbConnector).thenReturn(True) 

        workspace_manager = WorkspaceManager(dbManager, mappersManager, changesController, mock())
        workspace = workspace_manager.createWorkspace('test_workspace', 'a test workspace',
                                        DBTYPE.FS)

        verify(dbManager).createDb('test_workspace', DBTYPE.FS)
        verify(mappersManager, times=0).createMappers(dbConnector)
        verify(mappersManager, times=0).save(any())
開發者ID:BecomingMore,項目名稱:faraday,代碼行數:18,代碼來源:workspace_manager.py

示例13: testOpenWorkspaceSetsChangesCallback

    def testOpenWorkspaceSetsChangesCallback(self):
        dbManager = mock()
        mappersManager = mock()
        dbConnector = mock()
        mappers = mock()
        changesController = mock()
        workspaceMapper = mock()

        workspace = Workspace('test_workspace', 'a desc')

        when(dbManager).getConnector('test_workspace').thenReturn(dbConnector)
        when(mappersManager).getMapper(Workspace.__name__).thenReturn(workspaceMapper)
        when(dbManager).getAllDbNames().thenReturn(['test_workspace'])
        when(mappersManager).createMappers(dbConnector).thenReturn(True)
        when(workspaceMapper).find('test_workspace').thenReturn(workspace)

        workspace_manager = WorkspaceManager(dbManager, mappersManager, changesController, mock())

        opened_workspace = workspace_manager.openWorkspace('test_workspace')

        verify(changesController).watch(mappersManager, dbConnector)
開發者ID:BecomingMore,項目名稱:faraday,代碼行數:21,代碼來源:workspace_manager.py

示例14: PluginsToModelControllerIntegration

class PluginsToModelControllerIntegration(unittest.TestCase):

    def setUp(self):
        """
        Generic test to verify that the object exists and can be
        instantiated without problems.
        """
        self.dbManager = mock()
        self.changesController = mock()
        self.reportManager = mock()

        self.dbManager = DbManager()
        self.mappersManager = MapperManager()

        self.model_controller = controller.ModelController(mock(), self.mappersManager)
        self.workspace_manager = WorkspaceManager(self.dbManager,
                                             self.mappersManager,
                                             self.changesController,
                                             self.reportManager)
        self.workspace_manager.createWorkspace('temp_workspace', 'desc', DBTYPE.FS)
        self.workspace_manager.openWorkspace('temp_workspace')

        self._plugin_controller = PluginControllerForApi("test", {"nmap": nmap_plugin.NmapPlugin(),
                                                                    "nessus": nessus_plugin.NessusPlugin()}, mock())

        api.setUpAPIs(self.model_controller, self.workspace_manager)

    def tearDown(self): 
        self.workspace_manager.removeWorkspace('temp_workspace')

    def test_nmap_scan_saves_host(self):
        output_file = open(os.path.join(os.getcwd(), 'test_cases/data/nmap_plugin_with_api.xml'))
        output = output_file.read()
        self._plugin_controller.processCommandInput("nmap localhost")
        self._plugin_controller.onCommandFinished("nmap localhost", output)
        self.model_controller.processAllPendingActions()
        self.assertEquals(len(self.model_controller.getAllHosts()), 1,
                "Not all hosts added to model")

        host = self.model_controller.getAllHosts()[0]
        self.assertEquals(len(host.getAllInterfaces()), 1,
            "Not all interfaces added to model")

        interface = host.getAllInterfaces()[0]
        self.assertEquals(len(interface.getAllServices()), 3,
            "Not all services added to model")

        services = interface.getAllServices()
        self.assertTrue(all( [ s.getStatus() == 'open' for s in services]),
                "Port status not saved correctly")


    def test_nessus_scan_saves_host(self):
        output_file = open(os.path.join(os.getcwd(), 'test_cases/data/nessus_plugin_with_api.nessus'))
        output = output_file.read() 
        self._plugin_controller.processCommandInput("./nessus report")
        self._plugin_controller.onCommandFinished("./nessus report", output)
        self.model_controller.processAllPendingActions()
        self.assertEquals(len(self.model_controller.getAllHosts()), 7,
                "Not all hosts added to model")
開發者ID:BecomingMore,項目名稱:faraday,代碼行數:60,代碼來源:plugins_controller_integration.py

示例15: testCreateWorkspaceCreateMappersAndWorkspace

    def testCreateWorkspaceCreateMappersAndWorkspace(self):
        dbManager = mock()
        mappersManager = mock()
        dbConnector = mock()
        mappers = mock()
        changesController = mock()
        workspaceMapper = mock()

        when(mappersManager).getMapper(Workspace.__name__).thenReturn(workspaceMapper)
        when(mappersManager).save(any()).thenReturn(True) 
        when(dbManager).createDb('test_workspace', DBTYPE.FS).thenReturn(dbConnector)
        when(mappersManager).createMappers(dbConnector).thenReturn(True) 

        workspace_manager = WorkspaceManager(dbManager, mappersManager, changesController, mock())
        workspace = workspace_manager.createWorkspace('test_workspace', 'a test workspace',
                                        DBTYPE.FS)

        verify(mappersManager).createMappers(dbConnector)
        verify(mappersManager).save(any())

        self.assertTrue(workspace, 'workspace not instantiated')
        self.assertEquals(workspace.name, 'test_workspace',
                            'Workspace name not set, is it valid?')
開發者ID:BecomingMore,項目名稱:faraday,代碼行數:23,代碼來源:workspace_manager.py


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