Beispiel #1
0
def is_invalid_param(rate, delay, packet_loss, packet_duplicate, corrupt,
                     reordering):
    param_value_list = [
        delay,
        packet_loss,
        packet_duplicate,
        corrupt,
        reordering,
    ]

    print(param_value_list)

    is_invalid = all([
        not RealNumber(param_value).is_type() or param_value <= 0
        for param_value in param_value_list
    ])

    try:
        Humanreadable(rate, kilo_size=1000).to_bit()
    except (TypeError, ValueError):
        pass
    else:
        is_invalid = False

    return is_invalid
Beispiel #2
0
def is_invalid_param(rate, delay, loss, corrupt):
    params = [
        delay,
        loss,
        corrupt,
    ]

    is_invalid = all(
        [not FloatType(param).is_type() or param == 0 for param in params])

    try:
        Humanreadable(rate, kilo_size=1000).to_no_prefix_value()
    except ValueError:
        pass
    else:
        is_invalid = False

    return is_invalid
Beispiel #3
0
 def test_normal(self, value, kilo_size, expected):
     assert Humanreadable(value, kilo_size).to_kilo_bit() == expected
Beispiel #4
0
 def test_exception(self, value, kilo_size, exception):
     with pytest.raises(exception):
         Humanreadable(value, kilo_size).to_bit()
Beispiel #5
0
 def test_normal(self, value, kilo_size, expected):
     assert Humanreadable(value, kilo_size).to_no_prefix_value() == expected
 def test_normal(self, value, kilo_size, expected):
     assert Humanreadable(kilo_size).humanreadable_to_kilobyte(
         value) == expected