Ejemplo n.º 1
0
 def setUp(self):
     self.wm = WorkspaceManager(self.model_controller,
                                mock(plcore.PluginController))
     self.workspace = self.wm.createWorkspace(
         new_random_workspace_name(), workspaceClass=WorkspaceOnCouch)
     self.wm.setActiveWorkspace(self.workspace)
     WorkspacePersister.stopThreads()
Ejemplo n.º 2
0
 def setUp(self):
     self.couch_uri = CONF.getCouchURI()
     self.cdm = CouchdbManager(uri=self.couch_uri)
     wpath = os.path.expanduser("~/.faraday/persistence/")
     self.fsm = FSManager(wpath)
     self.wm = WorkspaceManager(mock(ModelController),
                                mock(PluginController))
     self._fs_workspaces = []
     self._couchdb_workspaces = []
Ejemplo n.º 3
0
    def setUpClass(cls):
        cls.model_controller = controller.ModelController(mock())
        api.setUpAPIs(cls.model_controller)
        cls.wm = WorkspaceManager(cls.model_controller,
                                  mock(plcore.PluginController))
        cls.temp_workspace = cls.wm.createWorkspace(
            test_utils.new_random_workspace_name(),
            workspaceClass=WorkspaceOnCouch)

        cls.wm.setActiveWorkspace(cls.temp_workspace)
        WorkspacePersister.stopThreads()
Ejemplo n.º 4
0
    def setUp(self):
        self.plugin_repo_path = os.path.join(os.getcwd(), "plugins", "repo")
        self.plugin_manager = PluginManager(self.plugin_repo_path)

        controller = ModelController(mock(SecurityManager))

        wm = WorkspaceManager(controller, mock(PluginController))
        work = wm.createWorkspace('default', workspaceClass=WorkspaceOnCouch)
        work.setModelController(controller)
        controller.setWorkspace(work)
        model.api.setUpAPIs(controller)

        class WorkspaceStub():
            def __init__(self):
                self.id = "test_space"

        self.controller = self.plugin_manager.createController(WorkspaceStub())
Ejemplo n.º 5
0
    def test_save_command_in_fs(self):
        """ Tests if command is saved in couch """
        wm = WorkspaceManager(mock(ModelController), mock(PluginController))

        command_info = self.getDefaultCommandInfo()
        command_info['workspace'] = 'new_workspace'
        exec_command = CommandRunInformation(**command_info)

        workspace = wm.createWorkspace(exec_command.workspace,
                                       workspaceClass=WorkspaceOnFS)
        wm.setActiveWorkspace(workspace)

        cm = CommandManager()

        res = cm.saveCommand(exec_command, workspace)

        self._manager = PersistenceManagerFactory.getInstance()
        # saved_doc = self._manager.getDocument(exec_command.workspace, res['id'])

        # After all
        wm.removeWorkspace(command_info['workspace'])
Ejemplo n.º 6
0
    def setUpClass(cls):
        cls.model_controller = mock(controller.ModelController)
        api.setUpAPIs(cls.model_controller)
        cls.couch_uri = CONF.getCouchURI()
        cls.cdm = CouchdbManager(uri=cls.couch_uri)

        class NotificationTest(NotificationCenter):
            def __init__(self, ui):
                self.changes = []

            def changeFromInstance(self, change):
                self.changes.append(change)

        cls.notifier = NotificationTest(None)
        model.guiapi.notification_center = cls.notifier
        cls._couchdb_workspaces = []
        cls.wm = WorkspaceManager(cls.model_controller,
                                  mock(plcore.PluginController))
        cls.workspace = cls.wm.createWorkspace(new_random_workspace_name(),
                                               workspaceClass=WorkspaceOnCouch)
        when(cls.workspace).load().thenReturn(True)
        cls._couchdb_workspaces.append(cls.workspace.name)
        cls.wm.setActiveWorkspace(cls.workspace)
Ejemplo n.º 7
0
    def test_save_command_in_couch(self):
        """ Tests if command is saved in couch """
        cm = CommandManager()

        exec_command = CommandRunInformation(**self.getDefaultCommandInfo())

        wm = WorkspaceManager(mock(ModelController), mock(PluginController))
        workspace = wm.createWorkspace(exec_command.workspace,
                                       workspaceClass=WorkspaceOnCouch)

        res = cm.saveCommand(exec_command, workspace)

        self._manager = PersistenceManagerFactory.getInstance()
        saved_doc = self._manager.getDocument(exec_command.workspace,
                                              res['id'])

        self.assertEquals(exec_command.command, saved_doc['command'],
                          'Saved command diffier')
        self.assertEquals(exec_command.parameters, saved_doc['parameters'],
                          'Saved command diffier')
        self.assertEquals(exec_command.itime, saved_doc['itime'],
                          'Saved command diffier')
        self.assertEquals(exec_command.duration, saved_doc['duration'],
                          'Saved command diffier')
Ejemplo n.º 8
0
 def setUp(self):
     self._couchdb_workspaces = []
     self.wm = WorkspaceManager(self.model_controller,
                                mock(plcore.PluginController))