From 2cfcdced7fb473c456d3001ec3d9cdd8f1c26e82 Mon Sep 17 00:00:00 2001 From: Leonardo Schwarz Date: Mon, 30 Sep 2024 16:23:47 +0200 Subject: [PATCH] move some tests to the correct location --- pyproject.toml | 5 +++ tests/__init__.py | 0 tests/unit/results/__init__.py | 0 .../test_response_format_dict.py} | 0 .../{ => results}/test_result_container.py | 0 ..._list_not_existing_storage_directories.py} | 0 ...et.py => test_bfabric_save_csv2dataset.py} | 0 tests/unit/test_response_format_dict.py | 42 ------------------- tests/unit/utils/__init__.py | 0 tests/unit/{ => utils}/test_math_helper.py | 0 tests/unit/{ => utils}/test_paginator.py | 0 11 files changed, 5 insertions(+), 42 deletions(-) create mode 100644 tests/__init__.py create mode 100644 tests/unit/results/__init__.py rename tests/unit/{test_dict_helper.py => results/test_response_format_dict.py} (100%) rename tests/unit/{ => results}/test_result_container.py (100%) rename tests/unit/scripts/{test_list_not_existing_storage_directories.py => test_bfabric_list_not_existing_storage_directories.py} (100%) rename tests/unit/scripts/{test_save_csv2dataset.py => test_bfabric_save_csv2dataset.py} (100%) delete mode 100644 tests/unit/test_response_format_dict.py create mode 100644 tests/unit/utils/__init__.py rename tests/unit/{ => utils}/test_math_helper.py (100%) rename tests/unit/{ => utils}/test_paginator.py (100%) diff --git a/pyproject.toml b/pyproject.toml index fc0edddb..d03ee77f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -96,3 +96,8 @@ using = "PEP631" [tool.pytest.ini_options] logot_capturer = "logot.loguru.LoguruCapturer" + +[tool.check-tests-structure] +sources_path = "src/bfabric" +tests_path = "tests/unit" +allow_missing_tests = true diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/unit/results/__init__.py b/tests/unit/results/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/unit/test_dict_helper.py b/tests/unit/results/test_response_format_dict.py similarity index 100% rename from tests/unit/test_dict_helper.py rename to tests/unit/results/test_response_format_dict.py diff --git a/tests/unit/test_result_container.py b/tests/unit/results/test_result_container.py similarity index 100% rename from tests/unit/test_result_container.py rename to tests/unit/results/test_result_container.py diff --git a/tests/unit/scripts/test_list_not_existing_storage_directories.py b/tests/unit/scripts/test_bfabric_list_not_existing_storage_directories.py similarity index 100% rename from tests/unit/scripts/test_list_not_existing_storage_directories.py rename to tests/unit/scripts/test_bfabric_list_not_existing_storage_directories.py diff --git a/tests/unit/scripts/test_save_csv2dataset.py b/tests/unit/scripts/test_bfabric_save_csv2dataset.py similarity index 100% rename from tests/unit/scripts/test_save_csv2dataset.py rename to tests/unit/scripts/test_bfabric_save_csv2dataset.py diff --git a/tests/unit/test_response_format_dict.py b/tests/unit/test_response_format_dict.py deleted file mode 100644 index 9fe1765b..00000000 --- a/tests/unit/test_response_format_dict.py +++ /dev/null @@ -1,42 +0,0 @@ -import unittest - -import bfabric.results.response_format_dict as response_format_dict - - -class BfabricTestResponseFormatDict(unittest.TestCase): - def test_drop_empty_elements(self): - # Should delete all hierarchical instances of key-value pairs, where value is None or empty dict - input_list_dict = [{"a": [], "b": [1, {"aa": 14, "gg": None}], "c": []}, {"zz": None, "uu": "cat"}] - target_list_dict = [{"b": [1, {"aa": 14}]}, {"uu": "cat"}] - - output_list_dict = response_format_dict.drop_empty_elements(input_list_dict, inplace=False) - self.assertEqual(output_list_dict, target_list_dict) - - def test_map_element_keys(self): - # Main use is to delete underscores in specific keys - input_list_dict = [{"a": [], "b": [1, {"_aa": 14, "gg": None}], "c": []}, {"zz": None, "uu": "cat"}] - target_list_dict = [{"a": [], "b": [1, {"aa": 14, "gg": None}], "c": []}, {"zz": None, "uu": "cat"}] - - output_list_dict = response_format_dict.map_element_keys(input_list_dict, {"_aa": "aa"}, inplace=False) - self.assertEqual(output_list_dict, target_list_dict) - - def test_sort_dicts_by_key(self): - # NOTE: The main purpose of sorting is to ensure consistent string representation - input_list_dict = [{"b": 1, "a": 2, "c": 3}, {"dog": 25, "cat": [1, 2, 3]}] - target_list_dict = [{"a": 2, "b": 1, "c": 3}, {"cat": [1, 2, 3], "dog": 25}] - - output_list_dict = response_format_dict.sort_dicts_by_key(input_list_dict, inplace=False) - self.assertEqual(str(output_list_dict), str(target_list_dict)) - - def test_clean_result(self): - result_input = [{"b": 1, "a": 2, "_id": 3}, {"b": 4, "_id": 5, "a": 6}] - cleaned = response_format_dict.clean_result(result_input, drop_underscores_suds=True, sort_keys=True) - self.assertEqual(repr([{"a": 2, "b": 1, "id": 3}, {"a": 6, "b": 4, "id": 5}]), repr(cleaned)) - self.assertEqual( - repr([{"b": 1, "a": 2, "_id": 3}, {"b": 4, "_id": 5, "a": 6}]), - repr(result_input), - ) - - -if __name__ == "__main__": - unittest.main(verbosity=2) diff --git a/tests/unit/utils/__init__.py b/tests/unit/utils/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/unit/test_math_helper.py b/tests/unit/utils/test_math_helper.py similarity index 100% rename from tests/unit/test_math_helper.py rename to tests/unit/utils/test_math_helper.py diff --git a/tests/unit/test_paginator.py b/tests/unit/utils/test_paginator.py similarity index 100% rename from tests/unit/test_paginator.py rename to tests/unit/utils/test_paginator.py