Repository navigation
feat(agent): complete #136 CLI acceptance #157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,8 +57,8 @@ def load_fixture_definition(path: Path) -> dict[str, Any]: | |
| raise DescriptorError(f"{path} has invalid fixture fields") | ||
| if data["schema_version"] != 1 or data["kind"] != "synthetic-snapshotdb": | ||
| raise DescriptorError(f"{path} must declare synthetic-snapshotdb schema version 1") | ||
| if not isinstance(data["devices"], dict) or not data["devices"]: | ||
| raise DescriptorError(f"{path}: devices must be a non-empty mapping") | ||
| if not isinstance(data["devices"], dict): | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Low] 移除 |
||
| raise DescriptorError(f"{path}: devices must be a mapping") | ||
| for device_id, device in data["devices"].items(): | ||
| if not str(device_id).isdigit() or not isinstance(device, dict): | ||
| raise DescriptorError(f"{path}: device IDs must be non-negative integers") | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -88,13 +88,30 @@ def _is_subset(expected: dict[str, Any], actual: dict[str, Any]) -> bool: | |
| return all(key in actual and actual[key] == value for key, value in expected.items()) | ||
|
|
||
|
|
||
| def _value_contains(expected: Any, actual: Any) -> bool: | ||
| if isinstance(expected, dict): | ||
| return isinstance(actual, dict) and all( | ||
| key in actual and _value_contains(value, actual[key]) for key, value in expected.items() | ||
| ) | ||
| if isinstance(expected, list): | ||
| return ( | ||
| isinstance(actual, list) | ||
| and len(expected) <= len(actual) | ||
| and all( | ||
| _value_contains(item, candidate) | ||
| for item, candidate in zip(expected, actual, strict=False) | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Low]
|
||
| ) | ||
| ) | ||
| return expected == actual | ||
|
|
||
|
|
||
| def _output_contains(expected: dict[str, Any], output: Any) -> bool: | ||
| if not expected: | ||
| return True | ||
| if isinstance(output, dict): | ||
| return _is_subset(expected, output) | ||
| if _value_contains(expected, output): | ||
| return True | ||
| if isinstance(output, list): | ||
| return any(_output_contains(expected, item) for item in output) | ||
| return any(_value_contains(expected, item) for item in output) | ||
| return False | ||
|
|
||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Medium] 本 PR 唯一的产出代码行为变更缺少快速回归测试
logging.disable(CRITICAL)用于抑制 snapshot runtime 写向 stderr 的进度日志(snapshot/util/logger.py:125的StreamHandler()默认 stderr),但现有测试无法守住它:_assert_clean_json_success(tests/test_cli_json.py:153-161)只校验 stdout,从不断言result.stderr为空;test_import_json_fresh_and_reuse(tests/test_cli_json.py:397-420)继承同一缺口。直接回退此处的抑制,
pytest仍然全绿,只有 3.13-only 的 clean-wheel 门禁才会失败(慢、需先构建 wheel)。建议补充针对import --json(fresh + focused 路径)的空 stderr 断言,并校验logging.root.manager.disable在调用后恢复原值。