Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ad3596d

Browse files
author
Siddharta Govindaraj
committed
Setting mock return values
1 parent fce6447 commit ad3596d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

stock_alerter/tests/test_alert.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
class AlertTest(unittest.TestCase):
1111
def test_action_is_executed_when_rule_matches(self):
1212
exchange = {"GOOG": Stock("GOOG")}
13-
rule = PriceRule("GOOG", lambda stock: stock.price > 10)
13+
rule = mock.MagicMock(spec=PriceRule)
14+
rule.matches.return_value = True
15+
rule.depends_on.return_value = {"GOOG"}
1416
action = mock.MagicMock()
1517
alert = Alert("sample alert", rule, action)
1618
alert.connect(exchange)

0 commit comments

Comments
 (0)