def test_update_last_clean_date_writes(self): """Test that the current date is stored""" with mock.patch('clean_sentinel.pickle.dump') as p_save, \ mock.patch('clean_sentinel.open') as pFile, \ mock.patch.dict('os.environ', {'WORKSPACE': '/scratch/trilinos/foo/bar'}): self.assertEqual(None, update_last_clean_date()) p_save.assert_called_once() pFile.assert_called_once()
def test_update_last_clean_date_writes(self): """Test that the current date is stored""" with mock.patch('clean_sentinel.pickle.dump') as p_save, \ mock.patch('clean_sentinel.open') as pFile, \ mock.patch.dict('os.environ', {'WORKSPACE': '/scratch/trilinos/foo/bar'}): self.assertEqual(None, update_last_clean_date()) p_save.assert_called_once() pFile.assert_called_once()
def test_update_last_clean_date_writes(self): """Test that the current date is stored""" with mock.patch('clean_sentinel.pickle.dump') as p_save, \ mock.patch('clean_sentinel.datetime') as dt, \ mock.patch('clean_sentinel.open') as pFile, \ mock.patch.dict('os.environ', {'WORKSPACE': '/scratch/trilinos/foo/bar'}): self.assertEqual(None, update_last_clean_date()) p_save.assert_called_once_with(dt.now(), pFile.return_value.__enter__()) pFile.assert_called_once_with( '/scratch/trilinos/foo/bar/lastCleanDate', 'w')
def clean_space_by_date(self): if last_clean_date() < clean_reference_date(): print("Cleaning directory {clean_dir} due to newer reference date". format(clean_dir=self.args.dir)) self.force_clean_space() update_last_clean_date()
def test_update_last_clean_date_raises_with_no_file(self): """Test that the current date is stored""" with mock.patch.dict('os.environ', {'WORKSPACE': '/scratch/trilinos/foo/bar'}): with self.assertRaises(IOError): update_last_clean_date()
def clean_space_by_date(self): if last_clean_date() < clean_reference_date(): print("Cleaning directory {clean_dir} due to newer reference date".format(clean_dir=self.args.dir)) self.force_clean_space() update_last_clean_date()
def test_update_last_clean_date_raises_with_no_file(self): """Test that the current date is stored""" with mock.patch.dict('os.environ', {'WORKSPACE': '/scratch/trilinos/foo/bar'}): with self.assertRaises(IOError): update_last_clean_date()