Пример #1
0
def camera_info(draw,
                header=header(),
                height=uint32(),
                width=uint32(),
                distortion_model=string(),
                D=array(elements=float64()),
                K=array(elements=float64(), min_size=9, max_size=9),
                R=array(elements=float64(), min_size=9, max_size=9),
                P=array(elements=float64(), min_size=12, max_size=12),
                binning_x=uint32(),
                binning_y=uint32(),
                roi=region_of_interest()):
    """
    Generate values for ROS1 sensor_msgs/CameraInfo.msg.
    """
    header_value = draw(header)
    height_value = draw(height)
    width_value = draw(width)
    distortion_model_value = draw(distortion_model)
    d_value = draw(D)
    k_value = draw(K)
    r_value = draw(R)
    p_value = draw(P)
    binning_x_value = draw(binning_x)
    binning_y_value = draw(binning_y)
    roi_value = draw(roi)
    return _CameraInfo(header_value, height_value, width_value,
                       distortion_model_value, d_value, k_value, r_value,
                       p_value, binning_x_value, binning_y_value, roi_value)
Пример #2
0
def header(draw, seq=uint32(), stamp=time(), frame_id=string()):
    """
    Generate value for ROS1 standard message type "header".

    Parameters
    ----------
    seq : hypothesis_ros.message_fields.uint32()
        Strategy to generate seq value. (Default: Default hypothesis_ros strategy.)
    stamp : hypothesis_ros.message_fields.time()
        Strategy to generate stamp value. (Default: Default hypothesis_ros strategy.)
    frame_id : hypothesis_ros.message_fields.string()
        Strategy to generate frame_id value. (Default: Default hypothesis_ros strategy.)

    """
    seq_value = draw(seq)
    stamp_value = draw(stamp)
    frame_id_value = draw(frame_id)
    assert isinstance(
        seq_value, int
    ), 'drew invalid seq={seq_value} from {seq} for uint32 field'.format(
        seq_value, seq)
    assert isinstance(
        stamp_value.secs, int
    ), 'drew invalid stamp.secs={stamp_value} from {stamp} for int field'.format(
        stamp_value.secs, stamp)
    assert isinstance(
        stamp_value.nsecs, int
    ), 'drew invalid stamp.nsecs={stamp_value} from {stamp} for int field'.format(
        stamp_value.nsecs, stamp)
    assert isinstance(
        frame_id_value, str
    ), 'drew invalid frame_id={frame_id_value} from {frame_id} for str field'.format(
        frame_id_value, frame_id)
    return _Header(seq_value, stamp_value, frame_id_value)
Пример #3
0
def transform_stamped(draw,
                      header=header(),
                      child_frame_id=string(),
                      transform=transform()):
    """
    Generate value for ROS geometry message type "TransformStamped".

    Parameters
    ----------
    header : hypothesis_ros.messages.std_msgs.header()
        Strategy to generate header value. (Default: Default hypothesis-ros strategy.)
    child_frame_id : hypothesis_ros.message_fields.string()
        Strategy to generate child_frame_id value. (Default: Default hypothesis-ros strategy.)
    transform : hypothesis_ros.messages.geometry_msgs.transform()
        Strategy to generate transform value. (Default: Default hypothesis-ros strategy.)

    """
    header_value = draw(header)
    child_frame_id_value = draw(child_frame_id)
    transform_value = draw(transform)
    assert isinstance(
        header_value, _Header
    ), 'drew invalid header={header_value} from {header} for _Header field'.format(
        header_value, header)
    assert isinstance(
        child_frame_id_value, str
    ), 'drew invalid child_frame_id={child_frame_id_value} from {child_frame_id} for string field'.format(
        child_frame_id_value, child_frame_id)
    assert isinstance(
        transform_value, _Transform
    ), 'drew invalid transform={transform_value} from {transform} for _Transform field'.format(
        transform_value, transform)
    return _TransformStamped(header_value, child_frame_id_value,
                             transform_value)
def log(
    draw,  # DEBUG=uint8(), INFO=uint8(), WARN=uint8(), ERROR=uint8(), FATAL=uint8(),
    header=header(),
    level=uint8(),
    name=string(),
    msg=string(),
    file=string(),
    function=string(),
    line=uint32(),
    topics=array(elements=string())):
    """
    Generate value for ROS1 rosgraph message type "log".

    Parameters
    ----------
    header : hypothesis_ros.messages.std_msgs.header()
        Strategy to generate header value. (Default: Default hypothesis_ros strategy.)
    level : hypothesis_ros.message_fields.uint8()
        Strategy to generate level value. (Default: Default hypothesis_ros strategy.)
    name : hypothesis_ros.message_fields.string()
        Strategy to generate name value. (Default: Default hypothesis_ros strategy.)
    msg : hypothesis_ros.message_fields.string()
        Strategy to generate msg value. (Default: Default hypothesis_ros strategy.)
    file : hypothesis_ros.message_fields.string()
        Strategy to generate file value. (Default: Default hypothesis_ros strategy.)
    function : hypothesis_ros.message_fields.string()
        Strategy to generate function value. (Default: Default hypothesis_ros strategy.)
    line : hypothesis_ros.message_fields.string()
        Strategy to generate line value. (Default: Default hypothesis_ros strategy.)
    topics : hypothesis_ros.message_fields.array()
        Strategy to generate topics value. (Default: Default hypothesis_ros strategy.)

    """

    header_value = draw(header)
    level_value = draw(level)
    name_value = draw(name)
    msg_value = draw(msg)
    file_value = draw(file)
    function_value = draw(function)
    line_value = draw(line)
    topics_value = draw(topics)

    assert isinstance(
        level_value, int
    ), 'drew invalid level={level_value} from {level} for int field'.format(
        level_value, level)
    assert isinstance(
        name_value, str
    ), 'drew invalid name={name_value} from {name} for string field'.format(
        name_value, name)
    assert isinstance(
        msg_value, str
    ), 'drew invalid msg={msg_value} from {msg} for string field'.format(
        msg_value, msg)
    assert isinstance(
        file_value, str
    ), 'drew invalid file={file_value} from {file} for string field'.format(
        file_value, file)
    assert isinstance(
        function_value, str
    ), 'drew invalid function={function_value} from {function} for string field'.format(
        function_value, function)
    assert isinstance(
        line_value, int
    ), 'drew invalid line={line_value} from {line} for int field'.format(
        line_value, line)
    assert isinstance(
        topics_value, list
    ), 'drew invalid topics={topics_value} from {msg} for list field'.format(
        topics_value, topics)

    return _Log(header_value, level_value, name_value, msg_value, file_value,
                function_value, line_value, topics_value)
def test_string_with_bigger_min_than_max_size_raises_exception():
    """Verifies validation of String min_value/max_value."""
    with raises(InvalidArgument):
        string(min_size=STRING_MIN_SIZE + 1,
               max_size=STRING_MIN_SIZE).example()

@given(float64())
def test_float64_generates_expected_min_value_as_default(generated_value):
    """Verify default min. generated value for Float64."""
    assert generated_value >= FLOAT64_MIN_VALUE
    assert generated_value <= FLOAT64_MAX_VALUE


# def test_float64_with_invalid_min_value_raises_exception():
#     """Verifies validation of Float64 min_value (lower limit)."""
#     with raises(InvalidArgument):
#         float64(min_value = FLOAT64_MIN_VALUE - 0.1).example()


@given(string())
def test_string_generates_in_range_size_per_default(generated_value):
    """Verify default generated string size."""
    assert len(generated_value) >= STRING_MIN_SIZE
    assert len(generated_value) <= STRING_MAX_SIZE


def test_string_with_bigger_min_than_max_size_raises_exception():
    """Verifies validation of String min_value/max_value."""
    with raises(InvalidArgument):
        string(min_size=STRING_MIN_SIZE + 1,
               max_size=STRING_MIN_SIZE).example()


@given(time())
def test_time_generates_in_range_values_per_default(generated_value):