def test_validate_end_event__valid_event_should_not_raise_error():
    event = get_sample_end_event()
    try:
        validate_end_event(event)
        assert True
    except:
        pytest.fail("Valid end event raised exception")
Пример #2
0
def test_create_end_event__event_is_added_to_cassandra():
    event = get_sample_end_event(
        player_id='00000000000000000000000000000009',
        session_id='00000000-0123-4567-8910-000000000009')

    state_before = session_end_event_exists(player_id=event["player_id"],
                                            session_id=event["session_id"])
    insert_end_event(event)
    state_after = session_end_event_exists(player_id=event["player_id"],
                                           session_id=event["session_id"])

    assert state_before is False and state_after is True
Пример #3
0
def test_create_start_and_end_event__completed_session_is_added_to_cassandra():
    player_id = '00000000000000000000000000000003'
    session_id = '00000000-0123-4567-8910-000000000003'
    start_event = get_sample_start_event(player_id=player_id,
                                         session_id=session_id)
    end_event = get_sample_end_event(player_id=player_id,
                                     session_id=session_id)

    completed_state_before = completed_session_exists(player_id, session_id)
    insert_start_event(start_event)
    insert_end_event(end_event)

    completed_state_after = completed_session_exists(player_id, session_id)
    assert completed_state_before is False and completed_state_after is True
Пример #4
0
def test_create_end_first_then_start_event__completed_session_added_to_db():
    player_id = '00000000000000000000000000000004'
    session_id = '00000000-0123-4567-8910-000000000004'
    start_event = get_sample_start_event(player_id=player_id,
                                         session_id=session_id)
    end_event = get_sample_end_event(player_id=player_id,
                                     session_id=session_id)

    completed_state_before = completed_session_exists(player_id, session_id)
    # the other way around.
    insert_end_event(end_event)
    insert_start_event(start_event)

    completed_state_after = completed_session_exists(player_id, session_id)
    assert completed_state_before is False and completed_state_after is True
def test_validate_end_event__missing_event():
    event = get_sample_end_event()
    del event['event']
    with pytest.raises(TypeError) as e_info:
        validate_start_event(event)