Esempio n. 1
0
def test_disable_disabled_session(session: Session):
    try:
        session.disable_event(EventType.service_request)
    except EventNotEnabledError:
        pass
    with pytest.raises(EventNotEnabledError):
        session.disable_event(EventType.service_request)
Esempio n. 2
0
def test_session(session: Session):
    session.enable_event(EventType.service_request)
    session.set_event(EventType.service_request)
    session.wait_for_event(EventType.service_request, timeout=timedelta(0))
    session.set_event(EventType.service_request)
    assert (not session._events[EventType.service_request].empty())
    session.discard_events(EventType.service_request)
    assert (session._events[EventType.service_request].empty())
    session.disable_event(EventType.service_request)
Esempio n. 3
0
def test_unsupported_event_errors(session: Session):
    unsupported_event = EventType.tcpip_connect
    with pytest.raises(EventNotSupportedError):
        session.enable_event(unsupported_event)
    with pytest.raises(EventNotSupportedError):
        session.disable_event(unsupported_event)
    with pytest.raises(EventNotSupportedError):
        session.wait_for_event(unsupported_event, timeout=timedelta(0))
    with pytest.raises(EventNotSupportedError):
        session.set_event(unsupported_event)
    with pytest.raises(EventNotSupportedError):
        session.discard_events(unsupported_event)
Esempio n. 4
0
def test_disable_event(session: Session):
    # Make sure event is disabled
    try:
        session.disable_event(EventType.service_request)
    except EventNotEnabledError:
        pass
    with pytest.raises(EventNotEnabledError):
        session.set_event(EventType.service_request)
    with pytest.raises(EventNotEnabledError):
        session.discard_events(EventType.service_request)
    with pytest.raises(EventNotEnabledError):
        session.disable_event(EventType.service_request)
    with pytest.raises(EventNotEnabledError):
        try:
            session.wait_for_event(EventType.service_request,
                                   timeout=timedelta(0))
        except EventTimeoutError:
            # If we do get here ignore exception so assert catches missed exception
            pass
Esempio n. 5
0
def test_multiple_events(session: Session):
    for cur_event in session._SUPPORTED_EVENTS:
        logging.getLogger().debug(session._events_enabled)
        try:
            session.enable_event(cur_event)
        except EventNotDisabledError:
            pass
    # Verify that all events enabled
    for cur_event in session._SUPPORTED_EVENTS:
        with pytest.raises(EventNotDisabledError):
            session.enable_event(cur_event)

    enabled_events = list(session._SUPPORTED_EVENTS)
    # Disable each event
    while enabled_events:
        cur_event = enabled_events.pop(0)
        session.disable_event(cur_event)
        # Make sure other events are still enabled
        for verify_enable_event in enabled_events:
            with pytest.raises(EventNotDisabledError):
                session.enable_event(verify_enable_event)