def test_handle_pagure_message_bad_filter(self, mock_issue_from_pagure): """ This function tests 'handle_pagure_message' where comparing the actual vs. filter does not equate """ # Set up return values self.mock_pagure_message['msg']['issue']['filter1'] = 'filter2' # Call function response = u.handle_pagure_message( msg=self.mock_pagure_message, config=self.mock_config) # Assert that calls were made correctly mock_issue_from_pagure.assert_not_called() self.assertEqual(None, response)
def test_handle_pagure_message_bad_tag(self, mock_issue_from_pagure): """ This function tests 'handle_pagure_message' where the tags do not match """ # Set up return values self.mock_pagure_message['msg']['issue']['tags'] = ['bad_tags'] # Call function response = u.handle_pagure_message( msg=self.mock_pagure_message, config=self.mock_config) # Assert that calls were made correctly mock_issue_from_pagure.assert_not_called() self.assertEqual(None, response)
def test_handle_pagure_message_not_in_mapped(self, mock_issue_from_pagure): """ This function tests 'handle_pagure_message' where upstream is not in mapped repo """ # Set up return values self.mock_pagure_message['msg']['project']['name'] = 'bad_repo' # Call the function response = u.handle_pagure_message( msg=self.mock_pagure_message, config=self.mock_config ) # Assert all calls made correctly self.assertEqual(None, response) mock_issue_from_pagure.assert_not_called()
def test_handle_pagure_message_successful(self, mock_issue_from_pagure): """ This function tests 'handle_pagure_message' where everything goes smoothly and we test edge cases! """ # Set up return values mock_issue_from_pagure.return_value = "Successful Call!" # Call the function response = u.handle_pagure_message( msg=self.mock_pagure_message, config=self.mock_config ) # Assert that calls were made correctly mock_issue_from_pagure.assert_called_with( 'org/repo', {'status': 'Dropped', 'assignee': ['mock_assignee'], 'filter1': 'filter1', 'comments': ['new_comment'], 'tags': ['custom_tag', 'new_tag']}, self.mock_config ) self.assertEqual(response, 'Successful Call!')