Skip to content

Commit

Permalink
sperated test to be more isolated
Browse files Browse the repository at this point in the history
  • Loading branch information
AxelGard committed Nov 2, 2021
1 parent 11ae3ff commit 26ea90b
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions tests/test_stock.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,33 @@
import operator


def test_stock():
""" test relatied to the stock class """
portfolio = cira.Portfolio()
exchange = cira.Exchange()
def test_stock_oprators():
""" test operators relatied to the stock class """
stk = cira.Stock("PYPL")

assert stk.is_shortable == True
assert stk.can_borrow == True
assert stk.is_tradable == True

assert stk + 2 == stk.price + 2
assert stk - 2 == stk.price - 2
assert stk * 2 == stk.price * 2
for op in (operator.add, operator.sub, operator.mul, operator.truediv, operator.floordiv):
assert op(stk, 2) == op(stk.price, 2), f"test of op {op}"

def test_shortable():
""" test if a stock is able to be shorted """
stk = cira.Stock("PYPL")
assert stk.is_shortable == True

def test_tradable():
""" test if a stock is able to be shorted """
stk = cira.Stock("PYPL")
assert stk.is_tradable == True

def test_is_shortable():
pass
def test_stock_borrow():
""" test if a stock is able to be shorted """
stk = cira.Stock("PYPL")
assert stk.can_borrow == True

def test_historical_data():
""" Test that we historical data can be collected """
portfolio = cira.Portfolio()
exchange = cira.Exchange()
stk = cira.Stock("PYPL")
days = 10
print(stk.historical_data(days))
assert len(stk.historical_data(days)) == days

0 comments on commit 26ea90b

Please sign in to comment.