def test_scheduled(self, takeSnapshot, sleep): # first run without timestamp takeSnapshot.return_value = [True, False] self.assertTrue(self.sn.backup(force=False)) self.assertTrue(takeSnapshot.called) takeSnapshot.reset_mock() # second run doesn't use an anacron-like schedule tools.writeTimeStamp(self.cfg.anacronSpoolFile()) self.assertTrue(self.sn.backup(force=False)) self.assertTrue(takeSnapshot.called) takeSnapshot.reset_mock() # third run uses anacron-like schedule so it should not run self.cfg.setScheduleMode(self.cfg.REPEATEDLY) self.assertFalse(self.sn.backup(force=False)) self.assertFalse(takeSnapshot.called) # finally force self.assertTrue(self.sn.backup(force=True)) self.assertTrue(takeSnapshot.called)
def test_scheduled(self, takeSnapshot, sleep): # first run without timestamp takeSnapshot.return_value = [True, False] self.assertTrue(self.sn.backup(force = False)) self.assertTrue(takeSnapshot.called) takeSnapshot.reset_mock() # second run doesn't use an anacron-like schedule tools.writeTimeStamp(self.cfg.anacronSpoolFile()) self.assertTrue(self.sn.backup(force = False)) self.assertTrue(takeSnapshot.called) takeSnapshot.reset_mock() # third run uses anacron-like schedule so it should not run self.cfg.setScheduleMode(self.cfg.REPEATEDLY) self.assertFalse(self.sn.backup(force = False)) self.assertFalse(takeSnapshot.called) # finally force self.assertTrue(self.sn.backup(force = True)) self.assertTrue(takeSnapshot.called)
def test_writeTimeStamp(self): with NamedTemporaryFile('rt') as f: tools.writeTimeStamp(f.name) s = f.read().strip('\n') self.assertTrue(s.replace(' ', '').isdigit()) self.assertEqual(len(s), 13)