Skip to content
This repository was archived by the owner on Jan 13, 2021. It is now read-only.

Commit 3ae32a9

Browse files
committed
First integration test.
Simple, just to confirm it works.
1 parent 11c125d commit 3ae32a9

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

test/test_integration.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
test/integration
4+
~~~~~~~~~~~~~~~~
5+
6+
This file defines integration-type tests for hyper. These are still not fully
7+
hitting the network, so that's alright.
8+
"""
9+
import ssl
10+
import threading
11+
import hyper
12+
from hyper import HTTP20Connection
13+
from server import SocketLevelTest
14+
15+
# Turn off certificate verification for the tests.
16+
hyper.http20.tls._context = hyper.http20.tls._init_context()
17+
hyper.http20.tls._context.verify_mode = ssl.CERT_NONE
18+
19+
class TestHyperIntegration(SocketLevelTest):
20+
def test_connection_string(self):
21+
self.set_up()
22+
23+
# Confirm that we send the connection upgrade string and the initial
24+
# SettingsFrame.
25+
data = []
26+
send_event = threading.Event()
27+
28+
def socket_handler(listener):
29+
sock = listener.accept()[0]
30+
31+
# We should get two packets: one connection header string, one
32+
# SettingsFrame.
33+
first = sock.recv(65535)
34+
second = sock.recv(65535)
35+
data.append(first)
36+
data.append(second)
37+
38+
send_event.set()
39+
sock.close()
40+
41+
self._start_server(socket_handler)
42+
conn = HTTP20Connection(self.host, self.port)
43+
conn.connect()
44+
send_event.wait()
45+
46+
assert data[0] == b'PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n'
47+
48+
self.tear_down()

0 commit comments

Comments
 (0)