Exemple #1
0
    def testMarkDeletedAfterExceptionChange(self):
        state = State(self.tempdir, 'repo')
        state._gmtime = lambda: (2012, 8, 13, 12, 15, 0, 0, 0, 0)
        state.markStarted()
        try:
            raise ValueError("whatever")
        except:
            exType, exValue, exTraceback = exc_info()
            state.markException(exType, exValue, "9999/9999/9999/9999")
        state.close()
        self.assertEquals({"changedate": "2012-08-13 12:15:00", "status": "Error", "message": "whatever"}, jsonLoad(open(join(self.tempdir, 'repo.running'))))

        state = State(self.tempdir, 'repo')
        state._gmtime = lambda: (2012, 8, 13, 12, 17, 0, 0, 0, 0)
        state.markStarted()
        state.markDeleted()
        state.close()
        self.assertEquals({"changedate": "2012-08-13 12:17:00", "status": "Ok", "message": ""}, jsonLoad(open(join(self.tempdir, 'repo.running'))))
Exemple #2
0
    def testMarkDeleted(self):
        state = State(self.tempdir, 'repo')
        state._gmtime = lambda: (2012, 8, 13, 12, 15, 0, 0, 0, 0)
        state.markStarted()
        state.markHarvested("9999/9999/9999/9999", "resumptionToken", "2012-08-13T12:14:00")
        state.close()

        self.assertEquals('Started: 2012-08-13 12:15:00, Harvested/Uploaded/Deleted/Total: 9999/9999/9999/9999, Done: 2012-08-13 12:15:00, ResumptionToken: resumptionToken\n', open(join(self.tempdir, 'repo.stats')).read())
        self.assertEquals('{"from": "2012-08-13T12:14:00", "resumptionToken": "resumptionToken"}', open(join(self.tempdir, 'repo.next')).read())

        self.assertEquals({"changedate": "2012-08-13 12:15:00", "status": "Ok", "message": ""}, jsonLoad(open(join(self.tempdir, 'repo.running'))))

        state = State(self.tempdir, 'repo')
        state._gmtime = lambda: (2012, 8, 13, 12, 17, 0, 0, 0, 0)
        state.markDeleted()
        state.close()

        self.assertEquals("""Started: 2012-08-13 12:15:00, Harvested/Uploaded/Deleted/Total: 9999/9999/9999/9999, Done: 2012-08-13 12:15:00, ResumptionToken: resumptionToken
Started: 2012-08-13 12:17:00, Harvested/Uploaded/Deleted/Total: 0/0/0/0, Done: Deleted all ids.
""", open(join(self.tempdir, 'repo.stats')).read())
        self.assertEquals('{"from": "", "resumptionToken": ""}', open(join(self.tempdir, 'repo.next')).read())
        self.assertEquals({"changedate": "2012-08-13 12:15:00", "status": "Ok", "message": ""}, jsonLoad(open(join(self.tempdir, 'repo.running'))))