Exemple #1
0
 def test_read_file(self, mock_path):
     mock_path().is_file.return_value = True
     read_result = mock.MagicMock()
     mock_path().open().__enter__().read.return_value = read_result
     log_content = CondorBase.read_file('File')
     mock_path().open().__enter__().read.assert_called_once()
     self.assertEqual(log_content, read_result)
Exemple #2
0
 def test_read_file_exception(self, mock_path, mock_log):
     mock_path().is_file.side_effect = Exception()
     log_content = CondorBase.read_file('File')
     expected_result = 'There was an error while reading File'
     self.assertEqual(expected_result, log_content)
     mock_log.exception.assert_called_once()
Exemple #3
0
 def test_read_file_no_file(self, mock_path):
     mock_path().is_file.return_value = False
     log_content = CondorBase.read_file('File')
     expected_result = 'File does not exist'
     self.assertEqual(expected_result, log_content)