def create_engage_oncall_dialog(incident_id: int, command: dict = None, db_session=None): """Creates a dialog to engage an oncall person.""" oncall_services = service_service.get_all_by_status(db_session=db_session, is_active=True) if not oncall_services.count(): blocks = [ { "type": "section", "text": { "type": "mrkdwn", "text": "No oncall services have been defined. You can define them in the Dispatch UI at /services", }, } ] dispatch_slack_service.send_ephemeral_message( slack_client, command["channel_id"], command["user_id"], "No Oncall Services Defined", blocks=blocks, ) return oncall_service_options = [] for oncall_service in oncall_services: oncall_service_options.append( {"label": oncall_service.name, "value": oncall_service.external_id} ) page_options = [{"label": "Yes", "value": "Yes"}, {"label": "No", "value": "No"}] dialog = { "callback_id": command["command"], "title": "Engage Oncall", "submit_label": "Engage", "elements": [ { "label": "Oncall Service", "type": "select", "name": "oncall_service_id", "options": oncall_service_options, }, { "label": "Page", "type": "select", "name": "page", "value": "No", "options": page_options, }, ], } dispatch_slack_service.open_dialog_with_user(slack_client, command["trigger_id"], dialog)
def test_get_by_status(session, services): from dispatch.service.service import get_all_by_status t_services = get_all_by_status(db_session=session, is_active=True).all() assert len(t_services) > 1