1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# # SPDX-FileCopyrightText: 2021-2023 Constantine Evans <qslib@mb.costi.net>
# # SPDX-License-Identifier: EUPL-1.2
# import asyncio
# import logging
# import pytest
# from qslib.qs_is_protocol import QS_IS_Protocol
# @pytest.fixture
# def fake_connection():
# q = QS_IS_Protocol.__new__(QS_IS_Protocol)
# q.connection_made(None)
# return q
# def test_partial_quote(
# fake_connection: QS_IS_Protocol,
# monkeypatch: pytest.MonkeyPatch,
# caplog: pytest.LogCaptureFixture,
# ):
# def setparsed(msg):
# fake_connection._parsed = msg
# monkeypatch.setattr(asyncio, "create_task", lambda x: x)
# monkeypatch.setattr(fake_connection, "parse_message", setparsed)
# fake_connection.data_received(b"<tag>\n")
# assert fake_connection.quote_stack == [b"tag"]
# fake_connection.data_received(b"12345\n")
# with caplog.at_level(logging.DEBUG, logger="qslib.qs_is_protocol"):
# fake_connection.data_received(b"</ta")
# assert "Unclosed tag opener: b'</ta'" in caplog.messages
# assert fake_connection.quote_stack == [b"tag"]
# fake_connection.data_received(b"g>\n")
# assert fake_connection.quote_stack == []
# assert fake_connection._parsed == b"<tag>\n12345\n</tag>\n"