Пример #1
0
 def test_job_live(self):
     job = MagicMock()
     for live_value in ('pending', 'running'):
         job.metadata.__getitem__.return_value = live_value
         self.assertTrue(utils.job_live(job))
     for dead_value in ('finished', 'deleted'):
         job.metadata.__getitem__.return_value = dead_value
         self.assertFalse(utils.job_live(job))
Пример #2
0
 def test_job_live(self):
     job = MagicMock()
     for live_value in ('pending', 'running'):
         job.metadata.__getitem__.return_value = live_value
         self.assertTrue(utils.job_live(job))
     for dead_value in ('finished', 'deleted'):
         job.metadata.__getitem__.return_value = dead_value
         self.assertFalse(utils.job_live(job))
Пример #3
0
 def test_job_live_updates_metadata(self):
     job = MagicMock(spec=['metadata'])
     with patch('shub.utils.time.time') as mock_time:
         mock_time.return_value = 0
         utils.job_live(job)
         mock_time.return_value = 10
         utils.job_live(job, refresh_meta_after=20)
         self.assertFalse(job.metadata.expire.called)
         utils.job_live(job, refresh_meta_after=5)
         self.assertTrue(job.metadata.expire.called)
         job.metadata.expire.reset_mock()
         utils.job_live(job, refresh_meta_after=5)
         self.assertFalse(job.metadata.expire.called)
Пример #4
0
 def test_job_live_updates_metadata(self):
     job = MagicMock(spec=['metadata'])
     with patch('shub.utils.time.time') as mock_time:
         mock_time.return_value = 0
         utils.job_live(job)
         mock_time.return_value = 10
         utils.job_live(job, refresh_meta_after=20)
         self.assertFalse(job.metadata.expire.called)
         utils.job_live(job, refresh_meta_after=5)
         self.assertTrue(job.metadata.expire.called)
         job.metadata.expire.reset_mock()
         utils.job_live(job, refresh_meta_after=5)
         self.assertFalse(job.metadata.expire.called)