def test_defaults_do_not_clean(self):
     """The default dates should result in no clean action"""
     cleanerInst = Cleaner()
     with mock.patch.dict('os.environ',
                          {'WORKSPACE': '/scratch/Trilinos/foo/bar'}):
         with mock.patch('clean_workspace.Cleaner.force_clean_space') as force_clean, \
              mock.patch('clean_workspace.update_last_clean_date') as update:
             cleanerInst.clean_space_by_date()
         force_clean.assert_not_called()
         update.assert_not_called()
Example #2
0
 def test_defaults_do_not_clean(self):
     """The default dates should result in no clean action"""
     cleanerInst = Cleaner()
     with mock.patch.dict('os.environ',
                          {'WORKSPACE': '/scratch/Trilinos/foo/bar'}):
         with mock.patch('clean_workspace.Cleaner.force_clean_space') as force_clean, \
              mock.patch('clean_workspace.update_last_clean_date') as update:
             cleanerInst.clean_space_by_date()
         force_clean.assert_not_called()
         update.assert_not_called()
 def test_older_date_does_clean(self):
     """The default dates should result in no clean action"""
     testDate = datetime(2019, 2, 4, hour=10, minute=0)
     test_args = Namespace()
     setattr(test_args, "dir", os.path.join(os.path.sep, "dev", "null", "will_clean"))
     with mock.patch('clean_workspace.last_clean_date', return_value=testDate):
         cleanerInst = Cleaner()
         cleanerInst.args = test_args
         with mock.patch('clean_workspace.Cleaner.force_clean_space') as force_clean, \
              mock.patch('clean_workspace.update_last_clean_date') as update, \
              mock.patch('clean_workspace.print') as m_print:
             cleanerInst.clean_space_by_date()
         force_clean.assert_called_once()
         update.assert_called_once()
         m_print.assert_called_once_with("Cleaning directory /dev/null/will_clean "
                                         "due to newer reference date")
Example #4
0
 def test_older_date_does_clean(self):
     """The default dates should result in no clean action"""
     testDate = datetime(2019, 2, 4, hour=10, minute=0)
     test_args = Namespace()
     setattr(test_args, "dir", os.path.join(os.path.sep, "dev", "null", "will_clean"))
     with mock.patch('clean_workspace.last_clean_date', return_value=testDate):
         cleanerInst = Cleaner()
         cleanerInst.args = test_args
         with mock.patch('clean_workspace.Cleaner.force_clean_space') as force_clean, \
              mock.patch('clean_workspace.update_last_clean_date') as update, \
              mock.patch('clean_workspace.print') as m_print, \
              mock.patch("clean_sentinel.open", side_effect=IOError):
             cleanerInst.clean_space_by_date()
         force_clean.assert_called_once_with()
         update.assert_called_once_with()
         m_print.assert_called_once_with("Cleaning directory /dev/null/will_clean "
                                         "due to newer reference date")
Example #5
0
 def test_newer_reference_does_clean(self):
     """The default dates should result in no clean action"""
     testDate = datetime(2019, 2, 4, hour=10, minute=48)
     test_args = Namespace()
     setattr(test_args, "dir", os.path.join(os.path.sep, "dev", "null", "fake_directory"))
     with mock.patch('clean_workspace.clean_reference_date', return_value=testDate):
         cleanerInst = Cleaner()
         cleanerInst.args = test_args
         with mock.patch.dict('os.environ',
                              {'WORKSPACE': '/scratch/Trilinos/foo/bar'}):
             with mock.patch('clean_workspace.Cleaner.force_clean_space') as force_clean, \
                  mock.patch('clean_workspace.update_last_clean_date') as update, \
                  mock.patch('clean_workspace.print') as m_print:
                 cleanerInst.clean_space_by_date()
             force_clean.assert_called_once_with()
             update.assert_called_once_with()
             m_print.assert_called_once_with("Cleaning directory /dev/null/fake_directory "
                                             "due to newer reference date")
 def test_newer_reference_does_clean(self):
     """The default dates should result in no clean action"""
     testDate = datetime(2019, 2, 4, hour=10, minute=48)
     test_args = Namespace()
     setattr(test_args, "dir", os.path.join(os.path.sep, "dev", "null", "fake_directory"))
     with mock.patch('clean_workspace.clean_reference_date', return_value=testDate):
         cleanerInst = Cleaner()
         cleanerInst.args = test_args
         with mock.patch.dict('os.environ',
                              {'WORKSPACE': '/scratch/Trilinos/foo/bar'}):
             with mock.patch('clean_workspace.Cleaner.force_clean_space') as force_clean, \
                  mock.patch('clean_workspace.update_last_clean_date') as update, \
                  mock.patch('clean_workspace.print') as m_print:
                 cleanerInst.clean_space_by_date()
             force_clean.assert_called_once()
             update.assert_called_once()
             m_print.assert_called_once_with("Cleaning directory /dev/null/fake_directory "
                                             "due to newer reference date")