Example #1
0
 def test_cmd_serialization(self):
     import time
     cmd = CommandRunInformation(**{
         'workspace': 'fakews',
         'itime': time.time(),
         'command': "ping",
         'params': "127.0.0.1"})
     cmdserialized = self.mapper.serialize(cmd)
     # if serialization fails, returns None
     self.assertNotEqual(
         cmdserialized,
         None,
         "Serialized cmd shouldn't be None")
     # we check the cmd attributes
     self.assertEquals(
         cmdserialized.get("_id"),
         cmd.getID(),
         "Serialized ID is not the same as cmd ID")
     self.assertEquals(
         cmdserialized.get("command"),
         cmd.__getattribute__("command"),
         "Serialized name is not the same as cmd command")
     self.assertEquals(
         cmdserialized.get("params"),
         cmd.__getattribute__("params"),
         "Serialized name is not the same as cmd params")
Example #2
0
    def test_cmd_creation(self):
        import time
        cmd = CommandRunInformation(
            **{
                'workspace': 'fakews',
                'itime': time.time(),
                'command': "ping",
                'params': "127.0.0.1"
            })

        self.mapper.save(cmd)
        c = self.mapper.find(cmd.getID())
        self.assertEquals(c, cmd,
                          "Cmd retrieved should be the same as persisted")
        self.assertEquals(
            c.getID(), cmd.getID(),
            "Cmd retrieved's Id should be the same as persisted's Id")
Example #3
0
    def test_cmd_creation(self):
        import time
        cmd = CommandRunInformation(**{
            'workspace': 'fakews',
            'itime': time.time(),
            'command': "ping",
            'params': "127.0.0.1"})

        self.mapper.save(cmd)
        c = self.mapper.find(cmd.getID())
        self.assertEquals(
            c,
            cmd,
            "Cmd retrieved should be the same as persisted")
        self.assertEquals(
            c.getID(),
            cmd.getID(),
            "Cmd retrieved's Id should be the same as persisted's Id")
Example #4
0
    def processReport(self, plugin, filepath):

        cmd_info = CommandRunInformation(
            **{'workspace': model.api.getActiveWorkspace().name,
                'itime': time.time(),
                'command': 'Import %s:' % plugin,
                'params': filepath})
        self._mapper_manager.save(cmd_info)

        if plugin in self._plugins:
            self.processOutput(self._plugins[plugin], filepath, cmd_info.getID(), True )
            cmd_info.duration = time.time() - cmd_info.itime
            self._mapper_manager.update(cmd_info)
            return True
        return False
Example #5
0
    def processReport(self, plugin, filepath):

        cmd_info = CommandRunInformation(
            **{
                'workspace': model.api.getActiveWorkspace().name,
                'itime': time.time(),
                'command': 'Import %s:' % plugin,
                'params': filepath
            })
        self._mapper_manager.save(cmd_info)

        if plugin in self._plugins:
            self.processOutput(self._plugins[plugin], filepath,
                               cmd_info.getID(), True)
            cmd_info.duration = time.time() - cmd_info.itime
            self._mapper_manager.update(cmd_info)
            return True
        return False
Example #6
0
    def test_cmd_create_and_delete(self):
        import time
        cmd = CommandRunInformation(
            **{
                'workspace': 'fakews',
                'itime': time.time(),
                'command': "ping",
                'params': "127.0.0.1"
            })

        self.mapper.save(cmd)
        cmd_id = cmd.getID()

        self.assertNotEquals(self.mapper.load(cmd_id), None,
                             "Command should be saved")

        self.mapper.delete(cmd_id)

        self.assertEquals(self.mapper.find(cmd_id), None,
                          "Command shouldn't exist anymore")
Example #7
0
    def test_cmd_create_and_delete(self):
        import time
        cmd = CommandRunInformation(**{
            'workspace': 'fakews',
            'itime': time.time(),
            'command': "ping",
            'params': "127.0.0.1"})

        self.mapper.save(cmd)
        cmd_id = cmd.getID()

        self.assertNotEquals(
            self.mapper.load(cmd_id),
            None,
            "Command should be saved")

        self.mapper.delete(cmd_id)

        self.assertEquals(
            self.mapper.find(cmd_id),
            None,
            "Command shouldn't exist anymore")