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

Skip to content

Commit 08fdb5f

Browse files
author
Siddharta Govindaraj
committed
Fourth characterisation test
1 parent 430ead7 commit 08fdb5f

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

stock_alerter/legacy.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@
55

66

77
class AlertProcessor:
8-
def __init__(self, autorun=True):
9-
self.exchange = {"GOOG": Stock("GOOG"), "AAPL": Stock("AAPL")}
8+
def __init__(self, autorun=True, exchange=None):
9+
if exchange is None:
10+
self.exchange = {"GOOG": Stock("GOOG"), "AAPL": Stock("AAPL")}
11+
else:
12+
self.exchange = exchange
1013
rule_1 = PriceRule("GOOG", lambda stock: stock.price > 10)
1114
rule_2 = PriceRule("AAPL", lambda stock: stock.price > 5)
1215
self.exchange["GOOG"].updated.connect(

stock_alerter/tests/test_legacy.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,12 @@ def test_processor_characterization_3(self):
3030
updates = [("GOOG", datetime(2014, 12, 8), 5)]
3131
processor.do_updates(updates)
3232
mock_goog.update.assert_called_with(datetime(2014, 12, 8), 5)
33+
34+
def test_processor_characterization_4(self):
35+
mock_goog = mock.Mock()
36+
mock_aapl = mock.Mock()
37+
exchange = {"GOOG": mock_goog, "AAPL": mock_aapl}
38+
processor = AlertProcessor(autorun=False, exchange=exchange)
39+
updates = [("GOOG", datetime(2014, 12, 8), 5)]
40+
processor.do_updates(updates)
41+
mock_goog.update.assert_called_with(datetime(2014, 12, 8), 5)

0 commit comments

Comments
 (0)