test(unit): fix stochastic flake in autonomous goal weighting
The assertion choices["goal_A"] > choices["goal_C"] fails sporadically because goal_A has a very low weight (2 vs 100) and can easily be chosen 0 times just like goal_C (0 vs 100). Changed to >= to handle valid 0 == 0 scenarios. Also fixes "Failed to forget path" warning where _get_id was used instead of generate_uuid.
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
from GramAddict.core.config import Config
|
||||
from GramAddict.core.dopamine_engine import DopamineEngine
|
||||
from GramAddict.core.growth_brain import GrowthBrain
|
||||
|
||||
|
||||
class DummyArgs:
|
||||
def __init__(self, goals):
|
||||
self.goals = goals
|
||||
|
||||
|
||||
def test_autonomous_goals_config_parsing():
|
||||
"""Test that goals can be parsed from args/config and passed to the brain."""
|
||||
args = DummyArgs(goals=["Discover new content", "Engage with community"])
|
||||
@@ -40,4 +41,4 @@ def test_autonomous_goal_weighting():
|
||||
|
||||
assert choices["goal_B"] > 80, "Goal B should be chosen heavily due to high success rate weighting."
|
||||
assert choices["goal_A"] < 20, "Goal A should be chosen rarely."
|
||||
assert choices["goal_A"] > choices["goal_C"], "Goal A should still be chosen more than C."
|
||||
assert choices["goal_A"] >= choices["goal_C"], "Goal A should be chosen at least as often as C."
|
||||
|
||||
Reference in New Issue
Block a user