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

Skip to content

Commit 2799282

Browse files
author
Siddharta Govindaraj
committed
Removed nose2 specific tests
1 parent 45e5705 commit 2799282

File tree

1 file changed

+0
-79
lines changed

1 file changed

+0
-79
lines changed

stock_alerter/tests/test_stock.py

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -2,88 +2,9 @@
22
import collections
33
from datetime import datetime, timedelta
44

5-
from nose2.tools.params import params
6-
from nose2.tools import such
7-
85
from ..stock import Stock, StockSignal
96

107

11-
def setup_test():
12-
global goog
13-
goog = Stock("GOOG")
14-
15-
16-
def teardown_test():
17-
global goog
18-
goog = None
19-
20-
21-
def test_price_of_a_new_stock_class_should_be_None():
22-
assert goog.price is None
23-
test_price_of_a_new_stock_class_should_be_None.setup = setup_test
24-
test_price_of_a_new_stock_class_should_be_None.teardown = teardown_test
25-
26-
27-
def given_a_series_of_prices(stock, prices):
28-
timestamps = [datetime(2014, 2, 10), datetime(2014, 2, 11),
29-
datetime(2014, 2, 12), datetime(2014, 2, 13)]
30-
for timestamp, price in zip(timestamps, prices):
31-
stock.update(timestamp, price)
32-
33-
34-
@params(
35-
([8, 10, 12], True),
36-
([8, 12, 10], False),
37-
([8, 10, 10], False)
38-
)
39-
def test_stock_trends(prices, expected_output):
40-
goog = Stock("GOOG")
41-
given_a_series_of_prices(goog, prices)
42-
assert goog.is_increasing_trend() == expected_output
43-
44-
45-
def test_trend_with_all_consecutive_values_upto_100():
46-
for i in range(100):
47-
yield stock_trends_with_consecutive_prices, [i, i+1, i+2]
48-
49-
50-
def stock_trends_with_consecutive_prices(prices):
51-
goog = Stock("GOOG")
52-
given_a_series_of_prices(goog, prices)
53-
assert goog.is_increasing_trend()
54-
55-
56-
with such.A("Stock class") as it:
57-
58-
@it.has_setup
59-
def setup():
60-
it.goog = Stock("GOOG")
61-
62-
with it.having("a price method"):
63-
@it.has_setup
64-
def setup():
65-
it.goog.update(datetime(2014, 2, 12), price=10)
66-
67-
@it.should("return the price")
68-
def test(case):
69-
assert it.goog.price == 10
70-
71-
@it.should("return the latest price")
72-
def test(case):
73-
it.goog.update(datetime(2014, 2, 11), price=15)
74-
assert it.goog.price == 10
75-
76-
with it.having("a trend method"):
77-
@it.should("return True if the last three updates were increasing")
78-
def test(case):
79-
it.goog.update(datetime(2014, 2, 11), price=12)
80-
it.goog.update(datetime(2014, 2, 12), price=13)
81-
it.goog.update(datetime(2014, 2, 13), price=14)
82-
assert it.goog.is_increasing_trend()
83-
84-
it.createTests(globals())
85-
86-
878
class StockTest(unittest.TestCase):
889
def setUp(self):
8910
self.goog = Stock("GOOG")

0 commit comments

Comments
 (0)