fix: update remaining tests and session_to_tree for title field rename
- test_tree_validation.py: replace "action"/"solution" content fields with "title" - test_procedural_flows.py: update solution node fixtures to use "title" - test_save_session_as_tree.py: update fixtures and assertions for "title" field - session_to_tree.py: generate "title" instead of "action"/"solution" on converted nodes; fall back to legacy field names when reading from old tree snapshots for compatibility Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -15,7 +15,7 @@ class TestValidateTreeStructure:
|
||||
|
||||
def test_valid_solution_tree(self):
|
||||
valid, errors = validate_tree_structure({
|
||||
"id": "root", "type": "solution", "solution": "Done"
|
||||
"id": "root", "type": "solution", "title": "Done"
|
||||
})
|
||||
assert valid
|
||||
assert errors == []
|
||||
@@ -26,8 +26,8 @@ class TestValidateTreeStructure:
|
||||
"type": "decision",
|
||||
"question": "Is it on?",
|
||||
"children": [
|
||||
{"id": "yes", "type": "solution", "solution": "Great"},
|
||||
{"id": "no", "type": "action", "action": "Turn it on"},
|
||||
{"id": "yes", "type": "solution", "title": "Great"},
|
||||
{"id": "no", "type": "action", "title": "Turn it on"},
|
||||
],
|
||||
})
|
||||
assert valid
|
||||
@@ -39,7 +39,7 @@ class TestValidateTreeStructure:
|
||||
assert any("empty" in e["message"].lower() for e in errors)
|
||||
|
||||
def test_missing_id_on_root(self):
|
||||
valid, errors = validate_tree_structure({"type": "solution", "solution": "X"})
|
||||
valid, errors = validate_tree_structure({"type": "solution", "title": "X"})
|
||||
assert not valid
|
||||
assert any("id" in e["field"] for e in errors)
|
||||
|
||||
@@ -67,7 +67,7 @@ class TestValidateTreeStructure:
|
||||
"type": "decision",
|
||||
"question": "Q?",
|
||||
"children": [
|
||||
{"id": "only", "type": "solution", "solution": "S"},
|
||||
{"id": "only", "type": "solution", "title": "S"},
|
||||
],
|
||||
})
|
||||
assert not valid
|
||||
@@ -80,29 +80,29 @@ class TestValidateTreeStructure:
|
||||
})
|
||||
assert valid
|
||||
|
||||
def test_action_missing_action_field(self):
|
||||
def test_action_missing_title_field(self):
|
||||
valid, errors = validate_tree_structure({
|
||||
"id": "root", "type": "action"
|
||||
})
|
||||
assert not valid
|
||||
assert any("action" in e["message"].lower() for e in errors)
|
||||
assert any("title" in e["message"].lower() for e in errors)
|
||||
|
||||
def test_action_with_empty_action(self):
|
||||
def test_action_with_empty_title(self):
|
||||
valid, errors = validate_tree_structure({
|
||||
"id": "root", "type": "action", "action": ""
|
||||
"id": "root", "type": "action", "title": ""
|
||||
})
|
||||
assert not valid
|
||||
|
||||
def test_solution_missing_solution_field(self):
|
||||
def test_solution_missing_title_field(self):
|
||||
valid, errors = validate_tree_structure({
|
||||
"id": "root", "type": "solution"
|
||||
})
|
||||
assert not valid
|
||||
assert any("solution" in e["message"].lower() for e in errors)
|
||||
assert any("title" in e["message"].lower() for e in errors)
|
||||
|
||||
def test_solution_with_empty_solution(self):
|
||||
def test_solution_with_empty_title(self):
|
||||
valid, errors = validate_tree_structure({
|
||||
"id": "root", "type": "solution", "solution": ""
|
||||
"id": "root", "type": "solution", "title": ""
|
||||
})
|
||||
assert not valid
|
||||
|
||||
@@ -119,8 +119,8 @@ class TestValidateTreeStructure:
|
||||
"type": "decision",
|
||||
"question": "Q?",
|
||||
"children": [
|
||||
{"type": "solution", "solution": "S1"},
|
||||
{"id": "c2", "type": "solution", "solution": "S2"},
|
||||
{"type": "solution", "title": "S1"},
|
||||
{"id": "c2", "type": "solution", "title": "S2"},
|
||||
],
|
||||
})
|
||||
assert not valid
|
||||
@@ -133,7 +133,7 @@ class TestValidateTreeStructure:
|
||||
"question": "Q?",
|
||||
"children": [
|
||||
{"id": "c1"},
|
||||
{"id": "c2", "type": "solution", "solution": "S2"},
|
||||
{"id": "c2", "type": "solution", "title": "S2"},
|
||||
],
|
||||
})
|
||||
assert not valid
|
||||
@@ -151,11 +151,11 @@ class TestValidateTreeStructure:
|
||||
"type": "decision",
|
||||
"question": "Level 2?",
|
||||
"children": [
|
||||
{"id": "l3a", "type": "solution", "solution": "Deep"},
|
||||
{"id": "l3b", "type": "solution"}, # Missing solution
|
||||
{"id": "l3a", "type": "solution", "title": "Deep"},
|
||||
{"id": "l3b", "type": "solution"}, # Missing title
|
||||
],
|
||||
},
|
||||
{"id": "l2b", "type": "solution", "solution": "Shallow"},
|
||||
{"id": "l2b", "type": "solution", "title": "Shallow"},
|
||||
],
|
||||
})
|
||||
assert not valid
|
||||
@@ -167,8 +167,8 @@ class TestValidateTreeStructure:
|
||||
"type": "decision",
|
||||
"question": "Q?",
|
||||
"children": [
|
||||
{"id": "c1", "type": "solution"}, # missing solution
|
||||
{"id": "c2", "type": "action"}, # missing action
|
||||
{"id": "c1", "type": "solution"}, # missing title
|
||||
{"id": "c2", "type": "action"}, # missing title
|
||||
],
|
||||
})
|
||||
assert not valid
|
||||
@@ -179,7 +179,7 @@ class TestCanPublishTree:
|
||||
|
||||
def test_valid_tree_can_publish(self):
|
||||
can, errors = can_publish_tree(
|
||||
{"id": "root", "type": "solution", "solution": "Done"},
|
||||
{"id": "root", "type": "solution", "title": "Done"},
|
||||
"My Tree"
|
||||
)
|
||||
assert can
|
||||
@@ -187,7 +187,7 @@ class TestCanPublishTree:
|
||||
|
||||
def test_empty_name_cannot_publish(self):
|
||||
can, errors = can_publish_tree(
|
||||
{"id": "root", "type": "solution", "solution": "Done"},
|
||||
{"id": "root", "type": "solution", "title": "Done"},
|
||||
""
|
||||
)
|
||||
assert not can
|
||||
@@ -195,14 +195,14 @@ class TestCanPublishTree:
|
||||
|
||||
def test_whitespace_name_cannot_publish(self):
|
||||
can, errors = can_publish_tree(
|
||||
{"id": "root", "type": "solution", "solution": "Done"},
|
||||
{"id": "root", "type": "solution", "title": "Done"},
|
||||
" "
|
||||
)
|
||||
assert not can
|
||||
|
||||
def test_none_name_cannot_publish(self):
|
||||
can, errors = can_publish_tree(
|
||||
{"id": "root", "type": "solution", "solution": "Done"},
|
||||
{"id": "root", "type": "solution", "title": "Done"},
|
||||
None
|
||||
)
|
||||
assert not can
|
||||
|
||||
Reference in New Issue
Block a user