Compare commits
13 Commits
bfe8d36e82
...
f7f99395ec
| Author | SHA1 | Date |
|---|---|---|
|
|
f7f99395ec | |
|
|
dcb17ea19b | |
|
|
34538f696f | |
|
|
039c88b4ce | |
|
|
92d3168f27 | |
|
|
5a4657781f | |
|
|
9dadfb49e6 | |
|
|
42977a7e00 | |
|
|
a12ea1fc83 | |
|
|
a302378641 | |
|
|
f33b0824fb | |
|
|
fd70acca74 | |
|
|
7d875dba3b |
|
|
@ -234,6 +234,126 @@ class FactorRulesPathTests(unittest.TestCase):
|
|||
self.assertIn("- Rationale: ", summary)
|
||||
self.assertIn("- Thesis: Range-bound", summary)
|
||||
|
||||
def test_summarize_factor_rules_preserves_blank_signal_line(self):
|
||||
summary = summarize_factor_rules(
|
||||
[{"name": "Carry", "weight": "low", "thesis": "Sideways"}],
|
||||
ticker="DIA",
|
||||
trade_date="2026-03-07",
|
||||
)
|
||||
|
||||
self.assertIn("- Signal bias: neutral", summary)
|
||||
self.assertIn("- Weight: low", summary)
|
||||
|
||||
def test_summarize_factor_rules_preserves_explicit_empty_conditions(self):
|
||||
summary = summarize_factor_rules(
|
||||
[{"name": "Carry", "signal": "neutral", "conditions": []}],
|
||||
ticker="IWM",
|
||||
trade_date="2026-03-07",
|
||||
)
|
||||
|
||||
self.assertIn("- Conditions: No explicit conditions provided", summary)
|
||||
|
||||
def test_summarize_factor_rules_preserves_explicit_empty_rationale(self):
|
||||
summary = summarize_factor_rules(
|
||||
[{"name": "Carry", "signal": "neutral", "rationale": ""}],
|
||||
ticker="XLF",
|
||||
trade_date="2026-03-07",
|
||||
)
|
||||
|
||||
self.assertIn("- Rationale: ", summary)
|
||||
|
||||
def test_summarize_factor_rules_preserves_empty_name_as_blank_label(self):
|
||||
summary = summarize_factor_rules(
|
||||
[{"name": "", "signal": "neutral"}],
|
||||
ticker="TLT",
|
||||
trade_date="2026-03-07",
|
||||
)
|
||||
|
||||
self.assertIn("Rule 1: ", summary)
|
||||
self.assertIn("- Signal bias: neutral", summary)
|
||||
|
||||
def test_summarize_factor_rules_defaults_missing_name_to_rule_index(self):
|
||||
summary = summarize_factor_rules(
|
||||
[{"signal": "neutral"}],
|
||||
ticker="GLD",
|
||||
trade_date="2026-03-07",
|
||||
)
|
||||
|
||||
self.assertIn("Rule 1: Rule 1", summary)
|
||||
self.assertIn("- Signal bias: neutral", summary)
|
||||
|
||||
def test_summarize_factor_rules_preserves_zero_weight_value(self):
|
||||
summary = summarize_factor_rules(
|
||||
[{"name": "Carry", "signal": "neutral", "weight": 0}],
|
||||
ticker="USO",
|
||||
trade_date="2026-03-07",
|
||||
)
|
||||
|
||||
self.assertIn("- Weight: 0", summary)
|
||||
|
||||
def test_summarize_factor_rules_preserves_false_weight_value(self):
|
||||
summary = summarize_factor_rules(
|
||||
[{"name": "Carry", "signal": "neutral", "weight": False}],
|
||||
ticker="SLV",
|
||||
trade_date="2026-03-07",
|
||||
)
|
||||
|
||||
self.assertIn("- Weight: False", summary)
|
||||
|
||||
def test_summarize_factor_rules_stringifies_dict_conditions(self):
|
||||
summary = summarize_factor_rules(
|
||||
[{"name": "Carry", "signal": "neutral", "conditions": [{"threshold": 5}]}],
|
||||
ticker="HYG",
|
||||
trade_date="2026-03-07",
|
||||
)
|
||||
|
||||
self.assertIn("- Conditions: {'threshold': 5}", summary)
|
||||
|
||||
def test_summarize_factor_rules_stringifies_tuple_conditions(self):
|
||||
summary = summarize_factor_rules(
|
||||
[{"name": "Carry", "signal": "neutral", "conditions": [("threshold", 5)]}],
|
||||
ticker="LQD",
|
||||
trade_date="2026-03-07",
|
||||
)
|
||||
|
||||
self.assertIn("- Conditions: ('threshold', 5)", summary)
|
||||
|
||||
def test_summarize_factor_rules_preserves_none_conditions_value(self):
|
||||
summary = summarize_factor_rules(
|
||||
[{"name": "Carry", "signal": "neutral", "conditions": [None, "fallback"]}],
|
||||
ticker="IEF",
|
||||
trade_date="2026-03-07",
|
||||
)
|
||||
|
||||
self.assertIn("- Conditions: None; fallback", summary)
|
||||
|
||||
def test_summarize_factor_rules_preserves_empty_condition_entries(self):
|
||||
summary = summarize_factor_rules(
|
||||
[{"name": "Carry", "signal": "neutral", "conditions": ["", "macro-ok"]}],
|
||||
ticker="IEF",
|
||||
trade_date="2026-03-07",
|
||||
)
|
||||
|
||||
self.assertIn("- Conditions: ; macro-ok", summary)
|
||||
|
||||
def test_summarize_factor_rules_preserves_empty_string_condition_entries(self):
|
||||
summary = summarize_factor_rules(
|
||||
[{"name": "Carry", "signal": "neutral", "conditions": ["", "fallback"]}],
|
||||
ticker="IEF",
|
||||
trade_date="2026-03-07",
|
||||
)
|
||||
|
||||
self.assertIn("- Conditions: ; fallback", summary)
|
||||
|
||||
def test_summarize_factor_rules_preserves_empty_string_condition(self):
|
||||
summary = summarize_factor_rules(
|
||||
[{"name": "Carry", "signal": "neutral", "conditions": [""]}],
|
||||
ticker="IEF",
|
||||
trade_date="2026-03-07",
|
||||
)
|
||||
|
||||
self.assertIn("- Conditions: ", summary)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
|
|||
Loading…
Reference in New Issue