8Regression tests for :func:`oct.core.log_writer.write_command_log`.
12- Verify JSON file creation, naming convention, and content fidelity.
13- Verify directory auto-creation and UTF-8 encoding.
20 L3 — assertion details
25- All file writes are confined to ``tmp_path``.
29from pathlib
import Path
31from oct.core.log_writer
import write_command_log
35 (tmp_path /
".option_c").mkdir()
41 data = {
"status":
"ok",
"count": 42}
42 path = write_command_log(root,
"health", data)
44 content = json.loads(path.read_text(encoding=
"utf-8"))
45 assert content == data
50 path = write_command_log(root,
"health", {})
51 assert path.name.startswith(
"oct-health-")
52 assert path.suffix ==
".json"
57 logs_dir = tmp_path /
".option_c" /
"logs"
58 assert not logs_dir.exists()
59 write_command_log(root,
"lint", {
"ok":
True})
60 assert logs_dir.is_dir()
65 data = {
"project":
"demo",
"checks": [1, 2, 3],
"nested": {
"a":
"b"}}
66 path = write_command_log(root,
"audit", data)
67 assert json.loads(path.read_text(encoding=
"utf-8")) == data
72 result = write_command_log(root,
"test", {})
73 assert isinstance(result, Path)
74 assert result.exists()
79 data = {
"message":
"café résumé naïve — ñ ü ö"}
80 path = write_command_log(root,
"health", data)
81 content = json.loads(path.read_text(encoding=
"utf-8"))
82 assert content[
"message"] == data[
"message"]
test_report_content_matches(Path tmp_path)
test_writes_json_file(Path tmp_path)
test_creates_directory(Path tmp_path)
Path _setup_option_c(Path tmp_path)
test_returns_path(Path tmp_path)
test_filename_convention(Path tmp_path)
test_utf8_encoding(Path tmp_path)