Exemplo n.º 1
0
def test_length_overflow():
    # Test only saving the given number of chars
    l = http.LengthData(100)
    l.add_data('A' * 400)
    assert l.complete
    assert l.body == 'A' * 100

    # Test throwing an exception when adding data after complete
    l = http.LengthData(100)
    l.add_data('A' * 100)
    with pytest.raises(PappyException):
        l.add_data('A')
Exemplo n.º 2
0
def test_length_one_character():
    # Test adding one character at a time
    l = http.LengthData(100)
    for i in range(100):
        l.add_data('A')
    assert l.complete
    assert l.body == 'A' * 100

    # Test adding one character at a time (incomplete)
    l = http.LengthData(100)
    for i in range(99):
        l.add_data('A')
    assert not l.complete
Exemplo n.º 3
0
def test_length_data_simple():
    # Basic test
    l = http.LengthData(100)
    assert not l.complete
    l.add_data('A' * 100)
    assert l.complete
    assert l.body == 'A' * 100

    l = http.LengthData(0)
    assert l.complete
    assert l.body == ''

    # Test incomplete
    l = http.LengthData(100)
    l.add_data('A' * 99)
    assert not l.complete