コード例 #1
0
def test_session_hanlder_post(mock_handler):
    event = {'httpMethod': 'POST'}
    response = handler.session(event, None)
    assert_200(response)
    body = get_body_from_response(response)
    assert body == {'test_passed': True}
    mock_handler.assert_called_once_with('POST', event)
コード例 #2
0
def test_create_session(session_dict):
    response = create_session(session_dict)
    assert_200(response)
    body = get_body_from_response(response)
    assert body['session']
    assert body['session']['name'] == 'Test cupping'
    assert body['session']['id'] >= 1
コード例 #3
0
def test_create_session_missing_cupping_scores(session_dict):
    session_dict['cuppings'][0].pop('scores')
    response = create_session(session_dict)
    assert_200(response)
    body = get_body_from_response(response)
    assert body == {
        'errors': {
            'cuppings': {
                '0': {'scores': 'This field is required.'}
            }
        }
    }
コード例 #4
0
def test_get_session():
    session = SessionFactory()
    cuppings = CuppingFactory.create_batch(2, session_id=session.id)

    response = get_session_detail({'pathParameters': {'id': session.id}})
    assert_200(response)
    body = get_body_from_response(response)

    return_session =  body.get('session')
    assert return_session
    assert return_session['id'] == session.id

    assert len(return_session['cuppings']) == 2
    cupping_ids = set(c['id'] for c in return_session['cuppings'])
    assert len(cupping_ids) == 2

    session_ids = set(c['session_id'] for c in return_session['cuppings'])
    assert session_ids == set((session.id, ))
コード例 #5
0
def test_create_session_missing_name(session_dict):
    session_dict.pop('name')
    response = create_session(session_dict)
    assert_200(response)
    body = get_body_from_response(response)
    assert body == {'errors': {'name': 'This field is required.'}}
コード例 #6
0
def test_create_session_invalid_data(data):
    response = create_session(data)
    assert_200(response)
    body = get_body_from_response(response)
    assert body == {'errors': ['Invalid input data']}