예제 #1
0
def test_CtrlConn_handle_cmd_response_wrong_state():
    ctrl = CtrlConn()

    with pytest.raises(ValueError) as err:
        ctrl._handle_cmd_response({'state': ':smile:', 'msg_id': 'magic'})

    assert 'Invalid state' in str(err)
예제 #2
0
def test_CtrlConn_handle_cmd_response_error():
    def success(payload):
        assert False

    def error(payload):
        assert payload == {
            'msg_id': 'magic',
            'state': 'error',
            'answer': 42,
        }
        error.invoked = True

    ctrl = CtrlConn()
    ctrl.res_callbacks['magic'] = success, error
    ctrl._handle_cmd_response({
        'msg_id': 'magic',
        'state': 'error',
        'answer': 42})

    assert error.invoked == True
예제 #3
0
def test_CtrlConn_handle_cmd_response_malformed():
    ctrl = CtrlConn()

    with pytest.raises(ValueError):
        ctrl._handle_cmd_response({'emoji': ':tada:'})