Ejemplo n.º 1
0
def test_context_passed(setup_one_route, api_key_authed_event):
    assert dispatch(api_key_authed_event, {'foo': 'bar'}) == {
        'success': {
            'caller_user_id': None,
            'arguments': ['arg1', 'arg2'],
            'kwargs': {'source': {'anotherField': 42}, 'context': {'foo': 'bar'}, 'client': {}},
        },
    }
Ejemplo n.º 2
0
def test_basic_success(setup_one_route, cognito_authed_event):
    assert dispatch(cognito_authed_event, {}) == {
        'success': {
            'caller_user_id': '42-42',
            'arguments': ['arg1', 'arg2'],
            'kwargs': {'source': {'anotherField': 42}, 'context': {}, 'client': {'version': '1.2.3(456)'}},
        },
    }
Ejemplo n.º 3
0
def test_no_source(setup_one_route, cognito_authed_event):
    cognito_authed_event['source'] = None
    assert dispatch(cognito_authed_event, {}) == {
        'success': {
            'caller_user_id': '42-42',
            'arguments': ['arg1', 'arg2'],
            'kwargs': {'source': None, 'context': {}, 'client': {'version': '1.2.3(456)'}},
        },
    }
Ejemplo n.º 4
0
def test_no_source(setup_one_route, cognito_authed_event):
    cognito_authed_event['source'] = None
    resp = dispatch(cognito_authed_event, {})
    assert resp == {
        'success': {
            'caller_user_id': '42-42',
            'arguments': ['arg1', 'arg2'],
            'source': None
        },
    }
Ejemplo n.º 5
0
def test_api_key_authenticated(setup_one_route, api_key_authed_event):
    resp = dispatch(api_key_authed_event, {})
    assert resp == {
        'success': {
            'caller_user_id': None,
            'arguments': ['arg1', 'arg2'],
            'source': {
                'anotherField': 42
            }
        },
    }
Ejemplo n.º 6
0
def test_basic_success(setup_one_route, cognito_authed_event):
    resp = dispatch(cognito_authed_event, {})
    assert resp == {
        'success': {
            'caller_user_id': '42-42',
            'arguments': ['arg1', 'arg2'],
            'source': {
                'anotherField': 42
            }
        },
    }
Ejemplo n.º 7
0
def test_api_key_authenticated(setup_one_route, api_key_authed_event):
    assert dispatch(api_key_authed_event, {}) == {
        'data': {
            'caller_user_id': None,
            'arguments': ['arg1', 'arg2'],
            'kwargs': {
                'source': {
                    'anotherField': 42
                },
                'context': {},
                'client': {},
                'event': api_key_authed_event,
            },
        },
    }
Ejemplo n.º 8
0
def test_unknown_field_raises_exception(setup_one_route, cognito_authed_event):
    cognito_authed_event['info']['fieldName'] = 'unknownField'
    with pytest.raises(Exception,
                       match='No handler for field `Type.unknownField` found'):
        dispatch(cognito_authed_event, {})