Add ark_view unit test

This commit is contained in:
Artem Veremey
2021-04-05 16:29:55 -07:00
parent 357e94c772
commit 893e812cd6
3 changed files with 73 additions and 1 deletions

View File

@@ -0,0 +1,30 @@
test_ark_orders_view:
base_ark_view:
return_get_ark_orders: |
,ticker,date,shares,weight,fund,direction
0,TRMB,2021-04-01,453214,0.153,ARKK,Buy
1,API,2021-04-01,104001,0.0789,ARKW,Sell
2,PSTI,2021-04-01,121919,0.0063,ARKG,Sell
3,SYRS,2021-04-01,35756,0.003,ARKG,Sell
4,TXG,2021-04-01,79573,0.1536,ARKG,Buy
5,PHR,2021-04-01,80935,0.0465,ARKG,Sell
6,BFLY,2021-04-01,274300,0.0487,ARKG,Buy
7,PYPL,2021-03-31,66500,0.0725,ARKK,Sell
8,FATE,2021-03-31,2660,0.0009,ARKK,Buy
9,API,2021-03-31,101999,0.0747,ARKW,Sell
10,PYPL,2021-03-31,161846,0.9914,ARKF,Sell
11,SHOP,2021-03-31,18184,0.5059,ARKF,Buy
12,SE,2021-03-31,20091,0.1109,ARKF,Buy
return_add_order_total: |
,ticker,date,shares,volume,open,close,high,low,total,weight,fund,direction
0,TRMB,2021-04-01,453214,2958400,79.13999938964844,80.73999786376953,81.08999633789062,78.0,36592497.391830444,0.153,ARKK,Buy
1,API,2021-04-01,104001,890300,52.70000076293945,53.720001220703125,54.33000183105469,52.11000061035156,5586933.846954346,0.0789,ARKW,Sell
2,PSTI,2021-04-01,121919,401100,4.789999961853027,4.809999942779541,5.090000152587891,4.789999961853027,586430.3830237389,0.0063,ARKG,Sell
3,SYRS,2021-04-01,35756,964400,7.440000057220459,7.385000228881836,8.199999809265137,7.349999904632568,264058.0681838989,0.003,ARKG,Sell
4,TXG,2021-04-01,79573,855400,181.55999755859375,185.7899932861328,186.1699981689453,176.52000427246094,14783867.135757446,0.1536,ARKG,Buy
5,PHR,2021-04-01,80935,692500,53.459999084472656,55.130001068115234,55.959999084472656,53.459999084472656,4461946.6364479065,0.0465,ARKG,Sell
6,BFLY,2021-04-01,274300,3566000,17.200000762939453,16.270000457763672,17.459999084472656,16.209999084472656,4462861.125564575,0.0487,ARKG,Buy
7,PYPL,2021-03-31,66500,7633400,238.11000061035156,242.83999633789062,245.22999572753906,237.27000427246094,16148859.756469727,0.0725,ARKK,Sell
8,FATE,2021-03-31,2660,1801100,75.86000061035156,82.44999694824219,83.79000091552734,75.56999969482422,219316.99188232422,0.0009,ARKK,Buy
9,API,2021-03-31,101999,1153000,52.0,50.27000045776367,52.0,49.84000015258789,5127489.776691437,0.0747,ARKW,Sell
10,PYPL,2021-03-31,161846,7633400,238.11000061035156,242.83999633789062,245.22999572753906,237.27000427246094,39302682.047302246,0.9914,ARKF,Sell

View File

@@ -15,7 +15,7 @@ from gamestonk_terminal.discovery.ark_model import get_ark_orders, add_order_tot
assertions = unittest.TestCase("__init__")
class TestDiscoveryFidelityModel:
class TestDiscoveryArkModel:
@mock.patch("gamestonk_terminal.discovery.ark_model.requests")
@parameterize_from_file(
"test_get_ark_orders",

View File

@@ -0,0 +1,42 @@
""" discovery/ark_view.py tests """
import unittest
from unittest import mock
from io import StringIO
import pandas as pd
# pylint: disable=unused-import
from gamestonk_terminal.test_helper import ( # noqa: F401
parameterize_from_file,
pytest_generate_tests,
)
from gamestonk_terminal.discovery.ark_view import ark_orders_view
assertions = unittest.TestCase("__init__")
class TestDiscoveryArkView:
@mock.patch("gamestonk_terminal.discovery.ark_view.ark_model.get_ark_orders")
@mock.patch("gamestonk_terminal.discovery.ark_view.ark_model.add_order_total")
@parameterize_from_file(
"test_ark_orders_view",
"../tests/data/discovery_ark_view.yaml",
)
def test_ark_orders_view(
self,
mock_add_order_total,
mock_get_ark_orders,
return_get_ark_orders,
return_add_order_total,
):
mock_get_ark_orders.return_value = pd.read_csv(
StringIO(return_get_ark_orders), header=0, index_col=0, parse_dates=["date"]
)
mock_add_order_total.return_value = pd.read_csv(
StringIO(return_add_order_total),
header=0,
index_col=0,
parse_dates=["date"],
)
ark_orders_view(["-n", "10"])