def test_help_payload(payload, parser): # Option 1: Using --help payload.text = '--help' result = handle_slash_command(payload, parser) assert len(result['text']) > 10 # Option 2: Sending nothing payload.text = '' result = handle_slash_command(payload, parser) assert len(result['text']) > 10
def test_handle(parser, payload, caplog): payload.text = 'roll 1d20 test' with caplog.at_level(logging.INFO): assert handle_slash_command(payload, parser) == { "response_type": "in_channel" } sleep(5) # Waits for the delayed thread to run assert '1d20' in caplog.messages[-2]
def test_hp_shortcut(payload, parser, caplog): # Special shortcut for /roll payload.command = '/hp' payload.text = '' payload.user_id = 'UP4K437HT' with caplog.at_level(logging.INFO): assert handle_slash_command(payload, parser) == { "response_type": "in_channel" } sleep(5) # Waits for the delayed thread to run assert caplog.messages[-1].startswith('No changes.')
def test_payload_error(parser, payload): payload.text = 'roll' result = handle_slash_command(payload, parser) assert isinstance(result, dict)
def modron_slash_cmd(): payload = SlashCommandPayload(**request.form.to_dict()) return handle_slash_command(payload, parser=modron_cmd_parser)