Esempio n. 1
0
def test_regex_handler_double_match(mocked_compile, message):
    handler = handlers.RegexHandler(pattern='\d+')
    message.text = 'pings'

    handler.match(message)
    handler.match(message)
    assert handler.regex
    assert mocked_compile.call_count == 1
Esempio n. 2
0
def test_regex_handler_double_match(mocked_compile):
    handler = handlers.RegexHandler(pattern='\d+')
    message = type('Message', (), {'text': 'pings'})

    handler.match(message)
    handler.match(message)
    assert handler.regex
    assert mocked_compile.call_count == 1
Esempio n. 3
0
def test_regex_handler_check_negative_match(message):
    message.text = 'pings'
    handler = handlers.RegexHandler(pattern='\d+')
    assert not handler.check(message)
Esempio n. 4
0
def test_regex_handler_check(message):
    message.text = '20 pings'
    handler = handlers.RegexHandler(pattern='\d+')
    assert handler.check(message)
Esempio n. 5
0
def test_regex_handler_check():
    message = type('Message', (), {'text': '20 pings'})
    handler = handlers.RegexHandler(pattern='\d+')
    assert handler.check(message)
Esempio n. 6
0
def test_regex_handler_check_negative_match():
    message = type('Message', (), {'text': 'pings'})
    handler = handlers.RegexHandler(pattern='\d+')
    assert not handler.check(message)