def test_get_message_data():
    assert story_context.get_message_data(
        {
            'session': {
                'data': {
                    'message': {
                        'text': {
                            'raw': 'I\'m going to Mars',
                        },
                        'location': {
                            'lat': 12,
                            'lng': 21,
                        }
                    }
                }
            }
        }, 'text') == {
            'raw': 'I\'m going to Mars',
        }
async def test_integrate_mongodb_with_facebook(open_db, build_context):
    async with open_db() as mongodb:
        facebook, _, story, user = await build_context(mongodb)

        trigger = utils.SimpleTrigger()

        @story.on('hello, world!')
        def correct_story():
            @story.part()
            def store_result(ctx):
                trigger.receive(ctx)

        await facebook.handle(
            build_message(user['facebook_user_id'], {'text': 'hello, world!'}))

        assert trigger.value['user'] == user
        assert story_context.get_message_data(trigger.value) == {
            'text': {
                'raw': 'hello, world!'
            }
        }
 def store_location(ctx):
     trigger_location.receive(
         story_context.get_message_data(ctx))
Exemple #4
0
 def store_result(ctx):
     incorrect_trigger.receive(story_context.get_message_data(ctx))
Exemple #5
0
def get_option(ctx):
    return story_context.get_message_data(ctx, 'option', 'value')
Exemple #6
0
def get_raw_text(ctx, default=None):
    return story_context.get_message_data(ctx, 'text', 'raw', default=default)
Exemple #7
0
def get_sticker(ctx):
    return story_context.get_message_data(ctx, 'sticker_id')
 def store_option(ctx):
     trigger.receive(
         story_context.get_message_data(ctx, 'option',
                                        'matches')[0])