Пример #1
0
def test_range_parse():
    assert isinstance(Range.parse('bytes=0-99'), Range)
    assert isinstance(Range.parse('BYTES=0-99'), Range)
    assert isinstance(Range.parse('bytes = 0-99'), Range)
    assert isinstance(Range.parse('bytes=0 - 102'), Range)
    assert Range.parse('bytes=10-5') is None
    assert Range.parse('bytes 5-10') is None
    assert Range.parse('words=10-5') is None
Пример #2
0
def test_range_parse():
    assert isinstance(Range.parse('bytes=0-99'), Range)
    assert isinstance(Range.parse('BYTES=0-99'), Range)
    assert isinstance(Range.parse('bytes = 0-99'), Range)
    assert isinstance(Range.parse('bytes=0 - 102'), Range)
    assert Range.parse('bytes=10-5') is None
    assert Range.parse('bytes 5-10') is None
    assert Range.parse('words=10-5') is None
Пример #3
0
def test_range_parse():
    assert isinstance(Range.parse("bytes=0-99"), Range)
    assert isinstance(Range.parse("BYTES=0-99"), Range)
    assert isinstance(Range.parse("bytes = 0-99"), Range)
    assert isinstance(Range.parse("bytes=0 - 102"), Range)
    assert Range.parse("bytes=10-5") is None
    assert Range.parse("bytes 5-10") is None
    assert Range.parse("words=10-5") is None
Пример #4
0
def test_parse_range_values():
    from webob.byterange import Range
    range = Range.parse("bytes=1-500")
    eq_(range.start, 1)
    eq_(range.end, 501)
Пример #5
0
def test_parse_range_type():
    from webob.byterange import Range
    from webob.descriptors import parse_range
    val = parse_range("bytes=1-500")
    eq_(type(val), type(Range.parse("bytes=1-500")))
def test_parse_range_values():
    from webob.byterange import Range
    from webob.descriptors import parse_range
    val = parse_range("bytes=1-500")
    eq_(val.ranges, Range.parse("bytes=1-500").ranges)
Пример #7
0
def _parse_range(value):
    if not value:
        return None
    # Might return None too:
    return Range.parse(value)
Пример #8
0
def test_parse_range_type():
    from webob.byterange import Range
    from webob.descriptors import parse_range

    val = parse_range("bytes=1-500")
    assert type(val) is type(Range.parse("bytes=1-500"))  # noqa: E701
Пример #9
0
def test_parse_range_type():
    from webob.byterange import Range
    from webob.descriptors import parse_range
    val = parse_range("bytes=1-500")
    assert type(val) == type(Range.parse("bytes=1-500"))
Пример #10
0
def test_parse_invalid_units():
    range = Range(((0, 100), ))
    assert_equal(range.parse('words=0-99'), None)
Пример #11
0
def test_parse_missing_equals_sign():
    range = Range(((0, 100), ))
    assert_equal(range.parse('bytes 0-99'), None)
Пример #12
0
def test_parse_valid_input():
    range = Range(((0, 100), ))
    assert_equal(range.parse('bytes=0-99').__class__, Range)
Пример #13
0
def test_parse_range_values():
    from webob.byterange import Range
    from webob.descriptors import parse_range
    val = parse_range("bytes=1-500")
    eq_(val.ranges, Range.parse("bytes=1-500").ranges)
Пример #14
0
def test_parse_range_values():
    from webob.byterange import Range

    range = Range.parse("bytes=1-500")
    eq_(range.start, 1)
    eq_(range.end, 501)
Пример #15
0
def test_not_satisfiable():
    range = Range.parse("bytes=-100")
    assert range.range_for_length(50) is None
    range = Range.parse("bytes=100-")
    assert range.range_for_length(50) is None
Пример #16
0
def test_not_satisfiable():
    range = Range.parse('bytes=-100')
    assert_false(range.satisfiable(50))
    range = Range.parse('bytes=100-')
    assert_false(range.satisfiable(50))
Пример #17
0
def test_parse_valid_input():
    range = Range(((0, 100),))
    assert_equal(range.parse("bytes=0-99").__class__, Range)
Пример #18
0
def test_parse_range_values():
    from webob.byterange import Range
    range = Range.parse("bytes=1-500")
    assert range.start == 1
    assert range.end == 501
Пример #19
0
def test_parse_missing_equals_sign():
    range = Range(((0, 100),))
    assert_equal(range.parse("bytes 0-99"), None)
Пример #20
0
def test_parse_range_values():
    from webob.byterange import Range

    range = Range.parse("bytes=1-500")
    assert range.start == 1
    assert range.end == 501
Пример #21
0
def test_parse_invalid_units():
    range = Range(((0, 100),))
    assert_equal(range.parse("words=0-99"), None)
Пример #22
0
def parse_range(value):
    if not value:
        return None
    # Might return None too:
    return Range.parse(value)
Пример #23
0
def test_not_satisfiable():
    range = Range.parse('bytes=-100')
    assert_false(range.satisfiable(50))
    range = Range.parse('bytes=100-')
    assert_false(range.satisfiable(50))