コード例 #1
0
ファイル: test_table.py プロジェクト: irvind/hpack
 def test_add_to_large(self):
     tbl = HeaderTable()
     # Max size to small to hold the value we specify
     tbl.maxsize = 1
     tbl.add(b'TestName', b'TestValue')
     # Table length should be 0
     assert len(tbl.dynamic_entries) == 0
コード例 #2
0
 def test_search_in_dynamic_full(self):
     tbl = HeaderTable()
     idx = len(HeaderTable.STATIC_TABLE) + 1
     tbl.add(b'TestName', b'TestValue')
     exp = (idx, b'TestName', b'TestValue')
     res = tbl.search(b'TestName', b'TestValue')
     assert res == exp
コード例 #3
0
ファイル: test_table.py プロジェクト: Coder206/servo
 def test_repr(self):
     tbl = HeaderTable()
     tbl.add(b'TestName1', b'TestValue1')
     tbl.add(b'TestName2', b'TestValue2')
     tbl.add(b'TestName2', b'TestValue2')
     # Meh, I hate that I have to do this to test
     # repr
     if is_py3:
         exp = (
             "HeaderTable(4096, False, deque(["
             "(b'TestName2', b'TestValue2'), "
             "(b'TestName2', b'TestValue2'), "
             "(b'TestName1', b'TestValue1')"
             "]))"
         )
     else:
         exp = (
             "HeaderTable(4096, False, deque(["
             "('TestName2', 'TestValue2'), "
             "('TestName2', 'TestValue2'), "
             "('TestName1', 'TestValue1')"
             "]))"
         )
     res = repr(tbl)
     assert res == exp
コード例 #4
0
ファイル: test_table.py プロジェクト: irvind/hpack
 def test_search_in_dynamic_partial(self):
     tbl = HeaderTable()
     idx = len(HeaderTable.STATIC_TABLE) + 1
     tbl.add(b'TestName', b'TestValue')
     exp = (idx , b'TestName', None)
     res = tbl.search(b'TestName', b'NotInTable')
     assert res == exp
コード例 #5
0
ファイル: test_table.py プロジェクト: irvind/hpack
 def test_get_by_index_dynamic_table(self):
     tbl = HeaderTable()
     off = len(HeaderTable.STATIC_TABLE)
     val = (b'TestName', b'TestValue')
     tbl.add(*val)
     res = tbl.get_by_index(off + 1)
     assert res == val
コード例 #6
0
 def test_get_by_index_dynamic_table(self):
     tbl = HeaderTable()
     off = len(HeaderTable.STATIC_TABLE)
     val = (b'TestName', b'TestValue')
     tbl.add(*val)
     res = tbl.get_by_index(off + 1)
     assert res == val
コード例 #7
0
 def test_add_to_large(self):
     tbl = HeaderTable()
     # Max size to small to hold the value we specify
     tbl.maxsize = 1
     tbl.add(b'TestName', b'TestValue')
     # Table length should be 0
     assert len(tbl.dynamic_entries) == 0
コード例 #8
0
 def test_get_by_index_static_table(self):
     tbl = HeaderTable()
     exp = (b':authority', b'')
     res = tbl.get_by_index(1)
     assert res == exp
     idx = len(HeaderTable.STATIC_TABLE)
     exp = (b'www-authenticate', b'')
     res = tbl.get_by_index(idx)
     assert res == exp
コード例 #9
0
ファイル: test_table.py プロジェクト: Coder206/servo
    def test_shrink_maxsize(self):
        tbl = HeaderTable()
        for i in range(3):
            tbl.add(b'TestName', b'TestValue')

        assert tbl._current_size == 147
        tbl.maxsize = 146
        assert len(tbl.dynamic_entries) == 2
        assert tbl._current_size == 98
コード例 #10
0
ファイル: test_table.py プロジェクト: irvind/hpack
 def test_get_by_index_static_table(self):
     tbl = HeaderTable()
     exp = (b':authority', b'')
     res = tbl.get_by_index(1)
     assert res == exp
     idx = len(HeaderTable.STATIC_TABLE)
     exp = (b'www-authenticate', b'')
     res = tbl.get_by_index(idx)
     assert res == exp
コード例 #11
0
    def test_shrink_maxsize(self):
        tbl = HeaderTable()
        for i in range(3):
            tbl.add(b'TestName', b'TestValue')

        assert tbl._current_size == 147
        tbl.maxsize = 146
        assert len(tbl.dynamic_entries) == 2
        assert tbl._current_size == 98
コード例 #12
0
ファイル: test_table.py プロジェクト: Coder206/servo
    def test_get_by_index_out_of_range(self):
        tbl = HeaderTable()
        off = len(HeaderTable.STATIC_TABLE)
        tbl.add(b'TestName', b'TestValue')
        with pytest.raises(InvalidTableIndex) as e:
            tbl.get_by_index(off + 2)

        assert (
            "InvalidTableIndex: Invalid table index %d" % (off + 2) in str(e)
        )
コード例 #13
0
ファイル: test_table.py プロジェクト: irvind/hpack
 def test_maxsize_prop_setter(self):
     tbl = HeaderTable()
     exp = int(HeaderTable.DEFAULT_SIZE / 2)
     tbl.maxsize = exp
     assert tbl.resized == True
     assert tbl.maxsize == exp
     tbl.resized = False
     tbl.maxsize = exp
     assert tbl.resized == False
     assert tbl.maxsize == exp
コード例 #14
0
 def test_maxsize_prop_setter(self):
     tbl = HeaderTable()
     exp = int(HeaderTable.DEFAULT_SIZE / 2)
     tbl.maxsize = exp
     assert tbl.resized is True
     assert tbl.maxsize == exp
     tbl.resized = False
     tbl.maxsize = exp
     assert tbl.resized is False
     assert tbl.maxsize == exp
コード例 #15
0
ファイル: test_table.py プロジェクト: jayvdb/hpack
    def test_get_by_index_out_of_range(self):
        tbl = HeaderTable()
        off = len(HeaderTable.STATIC_TABLE)
        tbl.add(b'TestName', b'TestValue')
        with pytest.raises(InvalidTableIndex) as e:
            tbl.get_by_index(off + 2)

        assert ("Invalid table index %d" % (off + 2) in str(e.value))
コード例 #16
0
ファイル: test_table.py プロジェクト: graingert/hpack
 def test_repr(self):
     tbl = HeaderTable()
     tbl.add(b'TestName1', b'TestValue1')
     tbl.add(b'TestName2', b'TestValue2')
     tbl.add(b'TestName2', b'TestValue2')
     exp = ("HeaderTable(4096, False, deque(["
            "(b'TestName2', b'TestValue2'), "
            "(b'TestName2', b'TestValue2'), "
            "(b'TestName1', b'TestValue1')"
            "]))")
     res = repr(tbl)
     assert res == exp
コード例 #17
0
 def test_repr(self):
     tbl = HeaderTable()
     tbl.add(b'TestName1', b'TestValue1')
     tbl.add(b'TestName2', b'TestValue2')
     tbl.add(b'TestName2', b'TestValue2')
     # Meh, I hate that I have to do this to test
     # repr
     if is_py3:
         exp = ("HeaderTable(4096, False, deque(["
                "(b'TestName2', b'TestValue2'), "
                "(b'TestName2', b'TestValue2'), "
                "(b'TestName1', b'TestValue1')"
                "]))")
     else:
         exp = ("HeaderTable(4096, False, deque(["
                "('TestName2', 'TestValue2'), "
                "('TestName2', 'TestValue2'), "
                "('TestName1', 'TestValue1')"
                "]))")
     res = repr(tbl)
     assert res == exp
コード例 #18
0
ファイル: test_table.py プロジェクト: Coder206/servo
 def test_get_by_index_zero_index(self):
     tbl = HeaderTable()
     with pytest.raises(InvalidTableIndex):
         tbl.get_by_index(0)
コード例 #19
0
ファイル: test_table.py プロジェクト: irvind/hpack
 def test_search_no_match(self):
     tbl = HeaderTable()
     idx = len(HeaderTable.STATIC_TABLE)
     tbl.add(b'TestName', b'TestValue')
     res = tbl.search(b'NotInTable', b'NotInTable')
     assert res is None
コード例 #20
0
 def test_shrink_maxsize_is_zero(self):
     tbl = HeaderTable()
     tbl.add(b'TestName', b'TestValue')
     assert len(tbl.dynamic_entries) == 1
     tbl.maxsize = 0
     assert len(tbl.dynamic_entries) == 0
コード例 #21
0
 def test_size(self):
     tbl = HeaderTable()
     for i in range(3):
         tbl.add(b'TestName', b'TestValue')
     res = tbl._current_size
     assert res == 147
コード例 #22
0
 def test_maxsize_prop_getter(self):
     tbl = HeaderTable()
     assert tbl.maxsize == HeaderTable.DEFAULT_SIZE
コード例 #23
0
 def test_search_no_match(self):
     tbl = HeaderTable()
     tbl.add(b'TestName', b'TestValue')
     res = tbl.search(b'NotInTable', b'NotInTable')
     assert res is None
コード例 #24
0
 def test_get_by_index_out_of_range(self):
     tbl = HeaderTable()
     off = len(HeaderTable.STATIC_TABLE)
     tbl.add(b'TestName', b'TestValue')
     with pytest.raises(InvalidTableIndex):
         tbl.get_by_index(off + 2)
コード例 #25
0
ファイル: test_table.py プロジェクト: irvind/hpack
 def test_size(self):
     tbl = HeaderTable()
     for i in range(3):
         tbl.add(b'TestValue', b'TestName')
     res = tbl._size()
     assert res == 147
コード例 #26
0
ファイル: test_table.py プロジェクト: irvind/hpack
 def test_shrink_maxsize_is_zero(self):
     tbl = HeaderTable()
     tbl.add(b'TestName',b'TestValue')
     assert len(tbl.dynamic_entries) == 1
     tbl.maxsize = 0
     assert len(tbl.dynamic_entries) == 0
コード例 #27
0
 def test_get_by_index_zero_index(self):
     tbl = HeaderTable()
     with pytest.raises(InvalidTableIndex):
         tbl.get_by_index(0)
コード例 #28
0
ファイル: test_table.py プロジェクト: irvind/hpack
 def test_get_by_index_out_of_range(self):
     tbl = HeaderTable()
     off = len(HeaderTable.STATIC_TABLE)
     tbl.add(b'TestName', b'TestValue')
     res = tbl.get_by_index(off+2)
     assert res is None # TODO HPACKException will be raised instead
コード例 #29
0
ファイル: test_table.py プロジェクト: irvind/hpack
 def test_get_by_index_zero_index(self):
     tbl = HeaderTable()
     res = tbl.get_by_index(0)
     assert res is None # TODO HPACKException will be raised instead
コード例 #30
0
 def test_search_in_static_partial(self):
     tbl = HeaderTable()
     exp = (1, b':authority', None)
     res = tbl.search(b':authority', b'NotInTable')
     assert res == exp
コード例 #31
0
ファイル: test_table.py プロジェクト: Coder206/servo
 def test_search_no_match(self):
     tbl = HeaderTable()
     tbl.add(b'TestName', b'TestValue')
     res = tbl.search(b'NotInTable', b'NotInTable')
     assert res is None
コード例 #32
0
 def test_search_in_static_full(self):
     tbl = HeaderTable()
     itm = (b':authority', b'')
     exp = (1, itm[0], itm[1])
     res = tbl.search(itm[0], itm[1])
     assert res == exp
コード例 #33
0
ファイル: test_table.py プロジェクト: irvind/hpack
 def test_search_in_static_full(self):
     tbl = HeaderTable()
     itm = (b':authority', b'')
     exp = (1, itm[0], itm[1])
     res = tbl.search(itm[0], itm[1])
     assert res == exp
コード例 #34
0
ファイル: test_table.py プロジェクト: irvind/hpack
 def test_search_in_static_partial(self):
     tbl = HeaderTable()
     exp = (1, b':authority', None)
     res = tbl.search(b':authority', b'NotInTable')
     assert res == exp
コード例 #35
0
ファイル: test_table.py プロジェクト: Stranger6667/hpack
 def test_get_by_index_out_of_range(self):
     tbl = HeaderTable()
     off = len(HeaderTable.STATIC_TABLE)
     tbl.add(b'TestName', b'TestValue')
     with pytest.raises(InvalidTableIndex):
         res = tbl.get_by_index(off+2)