Files
OpenBB/tests/test_fa/test_fa_controller.py
colin99d 4d2239d386 Refactored Tests (#640)
* Added basic openpyxl

* Add screener checks to confirm that preset is correct (#580)

* refactor screener finviz_view to view and model

* Add checks for defined screener preset

* Feature/fraud indicators (#581)

* Fixed glitch reading AlphaVantage API key

* Bug fix

* Added mscore metric

* Refactored code, added error handling

* Updated reademe.md

* Figuring out pre-commit

* Figuring out pre-commit

* Improved formating and code

* Added Zscore

* Formatted code

Co-authored-by: Colin Delahunty <colindelahunty@Colins-Air.attlocal.net>

* Reformated tests and started writing FA

* Removed excel analytics

* Figured out testing with input and print

* Figured out testing with input and print

* Added av_view tests

* Added av_view tests

* Added main_helper tests

* Fixed Poetry

* Added main helper tests

* Expanded pycoingecko_view

* Fixed ETF model

* Added coinpaprika view tests

* Added optimizer view tests

* Updated tests

Co-authored-by: Colin Delahunty <colindelahunty@Colins-Air.attlocal.net>
Co-authored-by: DidierRLopes <dro.lopes@campus.fct.unl.pt>
Co-authored-by: Colin Delahunty <colindelahunty@Colins-MacBook-Air.local>
2021-08-07 00:34:25 +01:00

51 lines
1.6 KiB
Python

""" fundamental_analysis/fa_controller.py tests """
from datetime import datetime, timedelta
from contextlib import contextmanager
import unittest
import io
import sys
# pylint: disable=unused-import
from gamestonk_terminal.stocks.fundamental_analysis import fa_controller
@contextmanager
def replace_stdin(target):
orig = sys.stdin
sys.stdin = target
yield
sys.stdin = orig
class TestFaController(unittest.TestCase):
start = datetime.now() - timedelta(days=200)
menuClass = fa_controller.FundamentalAnalysisController("GME", start, "1440min") # type: ignore
choices = fa_controller.FundamentalAnalysisController.CHOICES
def test_fa_controller_help(self):
capturedOutput = io.StringIO()
sys.stdout = capturedOutput
self.menuClass.print_help()
sys.stdout = sys.__stdout__
capt = capturedOutput.getvalue()
for item in self.choices:
self.assertIn(item, capt)
def key_metrics_explained(self):
# Is this base function ever even used?
capturedOutput = io.StringIO()
sys.stdout = capturedOutput
fa_controller.key_metrics_explained([""])
sys.stdout = sys.__stdout__
capt = capturedOutput.getvalue()
self.assertIn("RETURN ON EQUITY", capt)
def test_menu(self):
with replace_stdin(io.StringIO("q")):
capturedOutput = io.StringIO()
sys.stdout = capturedOutput
fa_controller.menu("GME", self.start, "1440min")
sys.stdout = sys.__stdout__
capt = capturedOutput.getvalue()
self.assertIn("fraud", capt)