Merge pull request #268 from DidierRLopes/add-market-watch-unit

Adding MarketWatch unit test
This commit is contained in:
Artem Veremey
2021-03-24 07:24:24 -07:00
committed by GitHub
3 changed files with 9458 additions and 1 deletions

View File

@@ -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

File diff suppressed because one or more lines are too long

View 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"),
)