mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-12-01 13:44:16 +00:00
Merge pull request #268 from DidierRLopes/add-market-watch-unit
Adding MarketWatch unit test
This commit is contained in:
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
@@ -26,7 +26,7 @@ jobs:
|
||||
- run: pip install bandit black codespell flake8 mypy pyupgrade safety pylint
|
||||
- run: bandit -r . || true
|
||||
- run: black --check .
|
||||
- run: codespell --ignore-words-list="mape","ba" --quiet-level=2 --skip=".git"
|
||||
- run: codespell --ignore-words-list="mape","ba" --quiet-level=2 --skip=".git" --skip="*.yaml" --skip="*.json"
|
||||
- run: flake8 . --count --ignore=E203,W503 --max-line-length=122 --show-source --statistics
|
||||
- run: mypy --ignore-missing-imports .
|
||||
- run: shopt -s globstar && pyupgrade --py36-plus **/*.py
|
||||
|
||||
9422
tests/data/fa_market_watch_api.yaml
Normal file
9422
tests/data/fa_market_watch_api.yaml
Normal file
File diff suppressed because one or more lines are too long
35
tests/test_fa_market_watch_api_unit.py
Normal file
35
tests/test_fa_market_watch_api_unit.py
Normal file
@@ -0,0 +1,35 @@
|
||||
""" fundamental_analysis/market_watch_api.py tests """
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
# pylint: disable=unused-import
|
||||
from gamestonk_terminal.test_helper import ( # noqa: F401
|
||||
parametrize_from_file,
|
||||
pytest_generate_tests,
|
||||
)
|
||||
|
||||
from gamestonk_terminal.fundamental_analysis.market_watch_api import (
|
||||
prepare_df_financials,
|
||||
)
|
||||
|
||||
assertions = unittest.TestCase("__init__")
|
||||
|
||||
|
||||
class TestFaMarketWatchApiUnit:
|
||||
@mock.patch("gamestonk_terminal.fundamental_analysis.market_watch_api.requests")
|
||||
@parametrize_from_file(
|
||||
"test_prepare_df_financials",
|
||||
"../tests/data/fa_market_watch_api.yaml",
|
||||
)
|
||||
# pylint: disable=too-many-arguments
|
||||
def test_prepare_df_financials(
|
||||
self, mock_request_get, ticker, statement, mock_market_watch, expected_result
|
||||
):
|
||||
mock_request_get.get().text = mock_market_watch
|
||||
ret = prepare_df_financials(ticker, statement)
|
||||
|
||||
assertions.assertEqual.__self__.maxDiff = None
|
||||
assertions.assertEqual(
|
||||
ret.to_csv().replace("\r\n", "\n"),
|
||||
expected_result.replace("\r\n", "\n"),
|
||||
)
|
||||
Reference in New Issue
Block a user