示例#1
0
def test_bandwidth_converter_raise_time():
    with pytest.raises(ValueError, match=r"invalid time. It must be.*"):
        bytesconv.bandwidth_converter(10,
                                      from_unit="bps",
                                      to_unit="KB",
                                      from_time="XXX")

    with pytest.raises(ValueError, match=r"invalid time. It must be.*"):
        bytesconv.bandwidth_converter(10,
                                      from_unit="bps",
                                      to_unit="KB",
                                      to_time="XXX")
示例#2
0
def test_bandwidth_converter_bits_to_bytes_binary(number, f_unit, t_unit,
                                                  f_time, t_time, result):
    """Convert from bits to bytes (binary)."""
    x = bytesconv.bandwidth_converter(number,
                                      from_unit=f_unit,
                                      to_unit=t_unit,
                                      from_time=f_time,
                                      to_time=t_time)
    assert (round(x[0], 1), x[1]) == (result, "{}/{}".format(t_unit, t_time))
示例#3
0
def test_bandwidth_converter_bits_to_bytes_decimal(number, f_unit, t_unit,
                                                   f_time, t_time, result):
    """Convert from bits to bytes (Decimal)."""
    assert bytesconv.bandwidth_converter(
        number,
        from_unit=f_unit,
        to_unit=t_unit,
        from_time=f_time,
        to_time=t_time) == (result, "{}/{}".format(t_unit, t_time))
示例#4
0
def test_bandwidth_converter_bytes_dec_to_bytes_dec(number, f_unit, t_unit,
                                                    f_time, t_time, result):
    """Convert bytes decimal to bytes decimal."""
    x = bytesconv.bandwidth_converter(number,
                                      from_unit=f_unit,
                                      to_unit=t_unit,
                                      from_time=f_time,
                                      to_time=t_time)
    assert (round(x[0], 2), x[1]) == (result, "{}/{}".format(t_unit, t_time))