def test1_finish(self): mock_finish_function = MagicMock() download = Download("test_url", "test_save_location", finish_func=mock_finish_function) download.finish() exp = 2 obs = len(mock_finish_function.mock_calls) self.assertEqual(exp, obs)
def test2_finish(self): mock_finish_function = MagicMock() mock_finish_function.side_effect = FileNotFoundError( Mock(status="Connection Error")) mock_cancel_function = MagicMock() download = Download("test_url", "test_save_location", finish_func=mock_finish_function, cancel_func=mock_cancel_function) download.finish() exp = 2 obs = len(mock_cancel_function.mock_calls) self.assertEqual(exp, obs)