Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions tests/test_observation_metadata_invariants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import pytest

def sanitize_metadata(meta: dict) -> dict:
Comment on lines +1 to +3

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Test File Fails Lint

The pytest import is unused, and the module-level functions on lines 3, 12, and 16 lack the two blank lines required by Ruff. Because CI runs ruff check ., this test file prevents the lint workflow from passing.

Prompt To Fix With AI
This is a comment left during a code review.
Path: tests/test_observation_metadata_invariants.py
Line: 1-3

Comment:
**Test File Fails Lint**

The `pytest` import is unused, and the module-level functions on lines 3, 12, and 16 lack the two blank lines required by Ruff. Because CI runs `ruff check .`, this test file prevents the lint workflow from passing.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

if not isinstance(meta, dict):
return {}
cleaned = {}
for k, v in meta.items():
if isinstance(k, str) and k.strip():
cleaned[k.strip()] = v
return cleaned

def test_sanitize_metadata_valid():
data = {"env": "prod", " version ": "1.2.0", "active": True}
assert sanitize_metadata(data) == {"env": "prod", "version": "1.2.0", "active": True}

def test_sanitize_metadata_empty_keys():
data = {"": "val", " ": "val2", "valid": 100}
assert sanitize_metadata(data) == {"valid": 100}