def test_handle_prs_closed_not_merged(mock_new_metric, mock_put_metrics, mock_create_widget): mock_new_metric.return_value = 'closed' mock_create_widget.return_value = {'test-widget': 'pull_request'} payload = get_payload('pr') payload['pull_request']['merged'] = False handle_prs_return = hw.handle_prs(payload, 'test-dashboard-name-prefix') mock_put_metrics.assert_called_once_with(['closed']) assert handle_prs_return == {'test-widget': 'pull_request'}
def test_handle_prs_opened(mock_new_metric, mock_put_metrics, mock_create_widget): mock_new_metric.return_value = 'opened' payload = get_payload('pr') payload['action'] = 'opened' handle_prs_return = hw.handle_prs(payload, 'test-dashboard-name-prefix') mock_put_metrics.assert_called_once_with(['opened']) mock_create_widget.assert_not_called() assert not handle_prs_return
def test_handle_prs_closed_and_merged(mock_new_metric, mock_put_metrics, mock_create_widget): mock_new_metric.side_effect = ['merged', 'closed'] mock_create_widget.return_value = {'test-widget': 'pull_request'} payload = get_payload('pr') payload['pull_request']['merged'] = True handle_prs_return = hw.handle_prs(payload, 'test-dashboard-name-prefix') mock_put_metrics.assert_has_calls([call(['merged']), call(['closed'])]) assert handle_prs_return == {'test-widget': 'pull_request'}
def test_handle_issues_neither_opened_nor_closed(mock_new_metric, mock_put_metrics, mock_create_widget): payload = get_payload('issue') payload['action'] = 'assigned' handle_issues_return = hw.handle_prs(payload, 'test-dashboard-name-prefix') mock_new_metric.assert_not_called() mock_put_metrics.assert_not_called() mock_create_widget.assert_not_called() assert not handle_issues_return