Skip to content

Commit 5d10c46

Browse files
author
Siddharta Govindaraj
committed
Validating a sequence of calls across different objects
1 parent 21f8b99 commit 5d10c46

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

stock_alerter/tests/test_alert.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,18 @@ def test_action_doesnt_fire_if_rule_doesnt_match(self):
3434
alert.check_rule(goog)
3535
rule_spy.matches.assert_called_with(exchange)
3636
self.assertFalse(action.execute.called)
37+
38+
def test_action_fires_when_rule_matches(self):
39+
goog = Stock("GOOG")
40+
exchange = {"GOOG": goog}
41+
main_mock = mock.MagicMock()
42+
rule = main_mock.rule
43+
rule.matches.return_value = True
44+
rule.depends_on.return_value = {"GOOG"}
45+
action = main_mock.action
46+
alert = Alert("sample alert", rule, action)
47+
alert.connect(exchange)
48+
goog.update(datetime(2014, 5, 14), 11)
49+
main_mock.assert_has_calls(
50+
[mock.call.rule.matches(exchange),
51+
mock.call.action.execute("sample alert")])

0 commit comments

Comments
 (0)