Example #1
0
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
Example #2
0
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]
Example #3
0
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.')
Example #4
0
def test_payload_error(parser, payload):
    payload.text = 'roll'
    result = handle_slash_command(payload, parser)
    assert isinstance(result, dict)
Example #5
0
 def modron_slash_cmd():
     payload = SlashCommandPayload(**request.form.to_dict())
     return handle_slash_command(payload, parser=modron_cmd_parser)