MCPcopy Create free account
hub / github.com/archlinux/archinstall / test_truncation

Function test_truncation

tests/test_share_log.py:88–102  ·  view source on GitHub ↗
(log_file: Path, resp_url: str, paste_url: str, max_byte: int | None)

Source from the content-addressed store, hash-verified

86@given(paste_url=urls, resp_url=urls, max_byte=max_bytes)
87@settings(max_examples=3, suppress_health_check=[HealthCheck.function_scoped_fixture])
88def test_truncation(log_file: Path, resp_url: str, paste_url: str, max_byte: int | None) -> None:
89 content = b'A' * 50 + b'B' * 80
90 log_file.write_bytes(content)
91 fake_response = BytesIO(resp_url.encode())
92
93 exptected_byte = len(content) if max_byte is None else max_byte
94
95 with (
96 patch('archinstall.lib.log.logger._path', new=log_file.parent),
97 patch('urllib.request.urlopen', return_value=fake_response) as mock_open,
98 ):
99 _ = share_install_log(paste_url, max_byte)
100 req = mock_open.call_args[0][0]
101 assert len(req.data) == exptected_byte
102 assert req.data == content[-exptected_byte:]
103
104
105@given(paste_url=urls, max_byte=max_bytes)

Callers

nothing calls this directly

Calls 1

share_install_logFunction · 0.90

Tested by

no test coverage detected