How to use the werobot.utils function in WeRoBot

To help you get started, we’ve selected a few WeRoBot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github offu / WeRoBot / tests / test_imagemessage.py View on Github external
def test_echo():
    robot = werobot.WeRoBot(token=werobot.utils.generate_token())

    @robot.handler
    def echo(message):
        return message.img

    tester = werobot.testing.WeTest(robot)
    xml = """
    
    
    
    1348831860
    
    
    
    1234567890123456
github offu / WeRoBot / tests / test_textmessage.py View on Github external
def test_echo():
    robot = werobot.WeRoBot(token=werobot.utils.generate_token())

    @robot.handler
    def echo(message):
        return message.content

    tester = werobot.test.WeTest(robot)
    message = werobot.test.make_text_message('test')
    print tester.send(message)
    assert tester.send(message) == 'test'
github offu / WeRoBot / tests / test_textmessage.py View on Github external
def test_echo():
    robot = werobot.WeRoBot(token=werobot.utils.generate_token())

    @robot.handler
    def echo(message):
        return message.content

    tester = werobot.testing.WeTest(robot)
    xml = """
    
    
    
    1348831860
    
    <content></content>
    1234567890123456
    
    """
github offu / WeRoBot / tests / test_locationmessage.py View on Github external
def test_echo():
    robot = werobot.WeRoBot(token=werobot.utils.generate_token())

    @robot.location
    def report(message):
        x, y = message.location
        return 'You are at ({x}, {y})'.format(
            x=x,
            y=y
        )

    tester = werobot.testing.WeTest(robot)
    xml = """
    
    
    
    1351776360
github offu / WeRoBot / tests / test_handlers.py View on Github external
def test_two():
    robot = werobot.WeRoBot(token=werobot.utils.generate_token())

    @robot.handler
    def first(message):
        if 'hi' in message.content:
            return 'Hello'

    @robot.handler
    def second(message):
        return "Hi"

    tester = werobot.testing.WeTest(robot)
    xml = """
    
    
    
    1348831860
github offu / WeRoBot / tests / test_types.py View on Github external
def test_types():
    robot = werobot.WeRoBot(token=werobot.utils.generate_token())

    for type in robot.message_types:
        assert hasattr(robot, type)

    @robot.text
    def second(message):
        return "Hi"

    @robot.image
    def third(message):
        return 'nice pic'

    tester = werobot.testing.WeTest(robot)
    xml = """
    
github offu / WeRoBot / tests / test_link.py View on Github external
def test_link():
    robot = werobot.WeRoBot(token=werobot.utils.generate_token())

    @robot.link
    def first(message):
        assert message.title == 'title'
        assert message.description == 'description'
        assert message.url == 'url'

    tester = werobot.testing.WeTest(robot)

    xml = """
    
        
        
        123456789
        
        <title>&lt;![CDATA[title]]&gt;</title>
github offu / WeRoBot / tests / test_session.py View on Github external
def test_session():
    robot = werobot.WeRoBot(
        token=werobot.utils.generate_token(), enable_session=True
    )

    @robot.text
    def first(message, session):
        if 'last' in session:
            return
        session['last'] = message.content
        return message.content

    @robot.text
    def second(_, session):
        return session['last']

    tester = werobot.testing.WeTest(robot)
    xml_1 = """
github offu / WeRoBot / tests / test_events.py View on Github external
def test_events():
    robot = werobot.WeRoBot(token=werobot.utils.generate_token())
    t = [False, '', 'NOTCHANGED']

    @robot.subscribe
    def first(message):
        return 'Hi'

    tester = werobot.testing.WeTest(robot)

    xml = """
    
        
        
        123456789