Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
rcholic committed Jun 28, 2024
1 parent 516b036 commit 37a7afa
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
from .test_token import mock_tokens

mock_file_name = "mock_schwab_api_resp.json"
token_store = LocalTokenStore(json_file_name="test_tokens.json")


def mock_account() -> AccountNumberWithHashID:
Expand Down Expand Up @@ -108,7 +109,7 @@ def test_parsing_order():
async def test_get_order(httpx_mock: HTTPXMock):
json_mock = get_mock_response()["single_order"]
mocked_token = mock_tokens()
token_store = LocalTokenStore()

if os.path.exists(Path(token_store.token_output_path)):
os.remove(token_store.token_output_path) # clean up before test

Expand Down Expand Up @@ -158,7 +159,6 @@ async def test_get_order(httpx_mock: HTTPXMock):
@pytest.mark.asyncio
async def test_place_order(httpx_mock: HTTPXMock):
mocked_token = mock_tokens()
token_store = LocalTokenStore()
if os.path.exists(Path(token_store.token_output_path)):
os.remove(token_store.token_output_path) # clean up before test

Expand Down Expand Up @@ -237,7 +237,6 @@ async def test_place_order(httpx_mock: HTTPXMock):
@pytest.mark.asyncio
async def test_cancel_order(httpx_mock: HTTPXMock):
mocked_token = mock_tokens()
token_store = LocalTokenStore()
if os.path.exists(Path(token_store.token_output_path)):
os.remove(token_store.token_output_path) # clean up before test

Expand Down Expand Up @@ -276,7 +275,7 @@ async def test_cancel_order(httpx_mock: HTTPXMock):
async def test_get_order_by_id(httpx_mock: HTTPXMock):
json_mock = get_mock_response()["filled_order"]
mocked_token = mock_tokens()
token_store = LocalTokenStore()

if os.path.exists(Path(token_store.token_output_path)):
os.remove(token_store.token_output_path) # clean up before test

Expand Down Expand Up @@ -319,7 +318,7 @@ async def test_get_order_by_id(httpx_mock: HTTPXMock):
async def test_get_single_account(httpx_mock: HTTPXMock):
json_mock = get_mock_response()["single_account"]
mocked_token = mock_tokens()
token_store = LocalTokenStore()

if os.path.exists(Path(token_store.token_output_path)):
os.remove(token_store.token_output_path) # clean up before test

Expand Down Expand Up @@ -364,7 +363,7 @@ async def test_get_single_account(httpx_mock: HTTPXMock):
async def test_get_securities_account(httpx_mock: HTTPXMock):
json_mock = get_mock_response()["securities_account"] # single_account
mocked_token = mock_tokens()
token_store = LocalTokenStore()

if os.path.exists(Path(token_store.token_output_path)):
os.remove(token_store.token_output_path) # clean up before test

Expand Down Expand Up @@ -413,7 +412,7 @@ async def test_get_securities_account(httpx_mock: HTTPXMock):
async def test_download_option_chain(httpx_mock: HTTPXMock):
mock_option_chain_resp = get_mock_response()
mocked_token = mock_tokens()
token_store = LocalTokenStore()

if os.path.exists(Path(token_store.token_output_path)):
os.remove(token_store.token_output_path) # clean up before test

Expand Down Expand Up @@ -478,7 +477,7 @@ async def test_download_option_chain(httpx_mock: HTTPXMock):
async def test_get_option_expirations(httpx_mock: HTTPXMock):
mock_option_chain_resp = get_mock_response()
mocked_token = mock_tokens()
token_store = LocalTokenStore()

if os.path.exists(Path(token_store.token_output_path)):
os.remove(token_store.token_output_path) # clean up before test

Expand Down Expand Up @@ -529,7 +528,7 @@ async def test_get_account_numbers(httpx_mock: HTTPXMock):
# Mock response for account numbers API
mock_data = get_mock_response()
mocked_token = mock_tokens()
token_store = LocalTokenStore()

token_store.save_tokens(mocked_token)
if os.path.exists(Path(token_store.token_output_path)):
os.remove(token_store.token_output_path) # clean up before test
Expand Down

0 comments on commit 37a7afa

Please sign in to comment.