def test_close_duplicates(self, mock_load_config, mock_d, mock_u): """ This tests the 'close_duplicates' function where everything goes smoothly """ # Set up return values mock_load_config.return_value = self.mock_config mock_u.pagure_issues.return_value = ['mock_issue_github'] mock_u.github_issues.return_value = ['mock_issue_pagure'] # Call the function m.close_duplicates() # Assert everything was called correctly mock_load_config.assert_called_once() mock_u.pagure_issues.assert_called_with('key_pagure', self.mock_config) mock_u.github_issues.assert_called_with('key_github', self.mock_config) mock_d.close_duplicates.assert_any_call('mock_issue_github', self.mock_config) mock_d.close_duplicates.assert_any_call('mock_issue_pagure', self.mock_config)
def test_close_duplicates_errors(self, mock_load_config, mock_d, mock_u): """ This tests the 'close_duplicates' function where closing duplicates raises an exception """ # Set up return values mock_load_config.return_value = self.mock_config mock_u.pagure_issues.return_value = ['mock_issue'] mock_u.github_issues.return_value = ['mock_issue'] mock_d.close_duplicates.side_effect = Exception() # Call the function with self.assertRaises(Exception): m.close_duplicates() # Assert everything was called correctly mock_load_config.assert_called_once() mock_u.pagure_issues.assert_called_with('key_pagure', self.mock_config) mock_u.github_issues.assert_not_called() mock_d.close_duplicates.assert_called_with('mock_issue', self.mock_config)