Skip to content

Commit

Permalink
production test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
TexasCoding committed Jun 25, 2024
1 parent 3e6c3ba commit 16819e1
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions tests/test_global_functions.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import os

import pytest

from src.alpaca_daily_losers.global_functions import send_position_messages

production = os.environ.get("PRODUCTION", False)


def test_send_position_messages_sell(capsys):
positions = [
Expand All @@ -11,12 +15,13 @@ def test_send_position_messages_sell(capsys):
pos_type = "sell"
result = send_position_messages(positions, pos_type)
printed_message = capsys.readouterr().out
assert (
printed_message
== """Message: Successfully sold the following positions:
if not production:
assert (
printed_message
== """Message: Successfully sold the following positions:
sold 10 shares of AAPL
sold 5 shares of GOOGL\n\n"""
)
)
assert True if result else False


Expand All @@ -28,12 +33,13 @@ def test_send_position_messages_buy(capsys):
pos_type = "buy"
result = send_position_messages(positions, pos_type)
printed_message = capsys.readouterr().out
assert (
printed_message
== """Message: Successfully bought the following positions:
if not production:
assert (
printed_message
== """Message: Successfully bought the following positions:
$1000 of AAPL bought
$500 of GOOGL bought\n\n"""
)
)
assert True if result else False


Expand All @@ -45,12 +51,13 @@ def test_send_position_messages_liquidate(capsys):
pos_type = "liquidate"
result = send_position_messages(positions, pos_type)
printed_message = capsys.readouterr().out
assert (
printed_message
== """Message: Successfully liquidated the following positions:
if not production:
assert (
printed_message
== """Message: Successfully liquidated the following positions:
$10 of AAPL liquidated
$5 of GOOGL liquidated\n\n"""
)
)
assert True if result else False


Expand Down

0 comments on commit 16819e1

Please sign in to comment.