Compare commits

...

13 Commits

Author SHA1 Message Date
69049ed6x f7f99395ec test: cover none factor rule conditions 2026-03-07 19:27:47 +08:00
69049ed6x dcb17ea19b test: cover empty factor rule conditions entries 2026-03-07 19:17:44 +08:00
69049ed6x 34538f696f test: cover empty string factor conditions 2026-03-07 19:08:19 +08:00
69049ed6x 039c88b4ce test: cover empty string factor rule condition 2026-03-07 18:58:04 +08:00
69049ed6x 92d3168f27 test: cover tuple factor rule conditions 2026-03-07 18:47:42 +08:00
69049ed6x 5a4657781f test: cover dict factor rule conditions 2026-03-07 18:38:07 +08:00
69049ed6x 9dadfb49e6 test: cover false factor rule weight 2026-03-07 18:28:06 +08:00
69049ed6x 42977a7e00 test: cover zero factor rule weight 2026-03-07 18:17:33 +08:00
69049ed6x a12ea1fc83 test: cover implicit default factor rule name 2026-03-07 18:08:14 +08:00
69049ed6x a302378641 test: cover empty factor rule name 2026-03-07 17:37:53 +08:00
69049ed6x f33b0824fb test: cover explicit empty rationale 2026-03-07 17:07:44 +08:00
69049ed6x fd70acca74 test: cover explicit empty conditions 2026-03-07 16:47:36 +08:00
69049ed6x 7d875dba3b test: cover default factor rule signal 2026-03-07 16:17:37 +08:00
1 changed files with 120 additions and 0 deletions

View File

@ -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()