Beispiel #1
0
    def test_set(self):
        manager = HeaderManager()
        manager.set(("x", "y"), ("foo", "bar"))

        assert manager.get("x") == "y"
        assert manager.get("foo") == "bar"
        manager.set(("foo", "baz"))  # clears existing foo, only
        assert manager.get("foo") == "baz"
        assert manager.get("x") == "y"
Beispiel #2
0
    def test_append(self):
        manager = HeaderManager()
        manager.set(("x", "y"), ("foo", "bar"))

        assert manager.get("x") == "y"
        assert manager.get("foo") == "bar"
        manager.append(("foo", "baz"))  # appends to foo
        assert manager.get("foo") == "bar,baz"
        assert manager.get("x") == "y"
Beispiel #3
0
    def __init__(self, stream_id):
        self.stream_id = stream_id

        self.headers = HeaderManager()
        self.trailers = HeaderManager()

        self.queue = Queue()
        self.buffer = ByteBuffer()
        self.closed = False
Beispiel #4
0
    def test_for_wire(self):
        manager = HeaderManager()
        manager.set(("x", "y"), ("foo", "bar"))

        assert manager.for_wire == [(b"x", b"y"), (b"foo", b"bar")]
Beispiel #5
0
    def test_append_from_wire(self):
        manager = HeaderManager()
        manager.set(("foo", "bar"))

        manager.append((b"foo", b"baz"), from_wire=True)
        assert manager.get("foo") == "bar,baz"
Beispiel #6
0
    def test_set_from_wire(self):
        manager = HeaderManager()

        manager.set((b"foo", b"bar"), from_wire=True)
        assert manager.get("foo") == "bar"
Beispiel #7
0
    def test_get_multi(self):
        manager = HeaderManager()
        manager.set(("foo", "bar"), ("foo", "baz"))

        assert manager.get("foo") == "bar,baz"
Beispiel #8
0
    def test_get_with_default(self):
        manager = HeaderManager()

        assert manager.get("foo", "baz") == "baz"
Beispiel #9
0
    def test_get(self):
        manager = HeaderManager()
        manager.set(("foo", "bar"))

        assert manager.get("foo") == "bar"