Пример #1
0
    def testLoadNoneDone(self):
        self._operator.save()

        o = renamer.Operator(self._statePath, 'test')
        o.load()

        self.assertEqual(o._todo, self._operator._todo)
        self.assertEqual(o._done, [])
        os.unlink(self._source)
Пример #2
0
    def setUp(self):
        self._statePath = tempfile.mkdtemp(suffix='.whipper.renamer.operator')
        self._operator = renamer.Operator(self._statePath, 'test')

        (fd,
         self._source) = tempfile.mkstemp(suffix='.whipper.renamer.operator')
        os.write(fd, 'This is a test\nThis is another\n')
        os.close(fd)
        (fd, self._destination) = tempfile.mkstemp(
            suffix='.whipper.renamer.operator')
        os.close(fd)
        os.unlink(self._destination)
        self._operator.addOperation(
            renamer.RenameInFile(self._source, 'is is a', 'at was some'))
        self._operator.addOperation(
            renamer.RenameFile(self._source, self._destination))
Пример #3
0
    def testLoadOneDone(self):
        self.assertEqual(len(self._operator._done), 0)
        self._operator.save()
        next(self._operator)
        self.assertEqual(len(self._operator._done), 1)

        o = renamer.Operator(self._statePath, 'test')
        o.load()

        self.assertEqual(len(o._done), 1)
        self.assertEqual(o._todo, self._operator._todo)
        self.assertEqual(o._done, self._operator._done)

        # now continue
        next(o)
        self.assertEqual(len(o._done), 2)
        os.unlink(self._destination)
Пример #4
0
    def testLoadOneInterrupted(self):
        self.assertEqual(len(self._operator._done), 0)
        self._operator.save()

        # cheat by doing a task without saving
        self._operator._todo[0].do()

        self.assertEqual(len(self._operator._done), 0)

        o = renamer.Operator(self._statePath, 'test')
        o.load()

        self.assertEqual(len(o._done), 0)
        self.assertEqual(o._todo, self._operator._todo)
        self.assertEqual(o._done, self._operator._done)

        # now continue, resuming
        next(o)
        self.assertEqual(len(o._done), 1)
        next(o)
        self.assertEqual(len(o._done), 2)

        os.unlink(self._destination)