mirror of
https://github.com/element-hq/synapse.git
synced 2024-12-21 03:42:55 +03:00
Fix signature and bug in writeHeaders
in the tests
This commit is contained in:
parent
b220096147
commit
3b8ed30163
1 changed files with 22 additions and 4 deletions
|
@ -198,17 +198,35 @@ class FakeChannel:
|
||||||
def headers(self) -> Headers:
|
def headers(self) -> Headers:
|
||||||
if not self.result:
|
if not self.result:
|
||||||
raise Exception("No result yet.")
|
raise Exception("No result yet.")
|
||||||
h = Headers()
|
|
||||||
for i in self.result["headers"]:
|
h = self.result["headers"]
|
||||||
h.addRawHeader(*i)
|
assert isinstance(h, Headers)
|
||||||
return h
|
return h
|
||||||
|
|
||||||
def writeHeaders(
|
def writeHeaders(
|
||||||
self, version: bytes, code: bytes, reason: bytes, headers: Headers
|
self,
|
||||||
|
version: bytes,
|
||||||
|
code: bytes,
|
||||||
|
reason: bytes,
|
||||||
|
headers: Union[Headers, List[Tuple[bytes, bytes]]],
|
||||||
) -> None:
|
) -> None:
|
||||||
self.result["version"] = version
|
self.result["version"] = version
|
||||||
self.result["code"] = code
|
self.result["code"] = code
|
||||||
self.result["reason"] = reason
|
self.result["reason"] = reason
|
||||||
|
|
||||||
|
if isinstance(headers, list):
|
||||||
|
# Support prior to Twisted 24.7.0rc1
|
||||||
|
new_headers = Headers()
|
||||||
|
for k, v in headers:
|
||||||
|
assert isinstance(k, bytes), f"key is not of type bytes: {k!r}"
|
||||||
|
assert isinstance(v, bytes), f"value is not of type bytes: {v!r}"
|
||||||
|
new_headers.addRawHeader(k, v)
|
||||||
|
headers = new_headers
|
||||||
|
|
||||||
|
assert isinstance(
|
||||||
|
headers, Headers
|
||||||
|
), f"headers are of the wrong type: {headers!r}"
|
||||||
|
|
||||||
self.result["headers"] = headers
|
self.result["headers"] = headers
|
||||||
|
|
||||||
def write(self, data: bytes) -> None:
|
def write(self, data: bytes) -> None:
|
||||||
|
|
Loading…
Reference in a new issue