diff --git a/conda-environment.yaml b/conda-environment.yaml old mode 100755 new mode 100644 diff --git a/gamestonk_terminal/test_helper.py b/gamestonk_terminal/test_helper.py new file mode 100644 index 00000000000..8956dc672d4 --- /dev/null +++ b/gamestonk_terminal/test_helper.py @@ -0,0 +1,63 @@ +""" Test helper """ +__docformat__ = "numpy" + +import pathlib +from typing import Callable +import yaml + + +def parametrize_from_file(test_namespace: str, parameter_file: str) -> Callable: + """A test helper function returns a wrapper function that loads sets of parameters from a YAML and + attaches test scenarios as metadata + + Parameters + ---------- + test_namespace : str + Test namespace to use within the YAML + parameter_file : str + Test scenario YAML to load + + Returns + ------- + Callable + Wrapper function + """ + + def wrapper(function): + test_file_base_path = pathlib.Path(__file__).parent.absolute() + data_file_full_path = pathlib.Path(test_file_base_path, parameter_file) + + with open(data_file_full_path, "r", encoding="utf-8") as file: + parameter_data = yaml.full_load(file) + + idlist = [] + argnames = [] + argvalues = [] + + for scenario in parameter_data[test_namespace]: + idlist.append(scenario) + argnames = [] + tempvalues = [] + for argname in parameter_data[test_namespace][scenario].keys(): + argnames.append(argname) + tempvalues.append(parameter_data[test_namespace][scenario][argname]) + argvalues.append(tempvalues) + + function.test_params_names = argnames + function.test_param_values = argvalues + function.test_ids = idlist + + return function + + return wrapper + + +def pytest_generate_tests(metafunc): + """ https://docs.pytest.org/en/stable/parametrize.html#pytest-generate-tests """ + if getattr(metafunc.function, "test_params_names", None): + metafunc.parametrize( + metafunc.function.test_params_names, + metafunc.function.test_param_values, + ids=metafunc.function.test_ids, + scope="class", + ) diff --git a/gamestonk_terminal/thought_of_the_day.py b/gamestonk_terminal/thought_of_the_day.py index 2278b71461a..8a891254223 100644 --- a/gamestonk_terminal/thought_of_the_day.py +++ b/gamestonk_terminal/thought_of_the_day.py @@ -1,4 +1,4 @@ -""" Fundamental Analysis Market Watch API """ +""" Thought of The Day """ __docformat__ = "numpy" import re diff --git a/notebooks/templates/due_diligence.ipynb b/notebooks/templates/due_diligence.ipynb old mode 100755 new mode 100644 diff --git a/tests/data/thought_of_the_day.yaml b/tests/data/thought_of_the_day.yaml new file mode 100644 index 00000000000..ec396fa26e3 --- /dev/null +++ b/tests/data/thought_of_the_day.yaml @@ -0,0 +1,55 @@ +test_get_urls: + base_case: + urls: + "some author": "https://www.goodreads.com/author/quotes/someauthor" +test_get_metadata: + base_case: + urls: + "some author": "https://www.goodreads.com/author/quotes/someauthor" + mock_goodreads_page: | + +
+