From ed9f2158f1ffbde8bec546340c6486660e1c4936 Mon Sep 17 00:00:00 2001 From: OlivieFranklova Date: Wed, 2 Oct 2024 15:15:31 +0200 Subject: [PATCH] Add tests --- .github/workflows/py_test.yml | 2 +- test/test_runner_connectors.py | 2 ++ test/test_runner_formators.py | 28 ++++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 test/test_runner_formators.py diff --git a/.github/workflows/py_test.yml b/.github/workflows/py_test.yml index 86f894a..fee1298 100644 --- a/.github/workflows/py_test.yml +++ b/.github/workflows/py_test.yml @@ -75,7 +75,7 @@ jobs: pytest $TEST_FILES - name: Show coverage - run: coverage report -m --omit=".*.ipynb" + run: coverage report -m --omit=[".*.ipynb", "similarityRunner/UI", "similarityRunner/models", "similarityRunner/runner.py"] - name: Create coverage file if: github.event_name == 'pull_request' diff --git a/test/test_runner_connectors.py b/test/test_runner_connectors.py index 030f03d..5126791 100644 --- a/test/test_runner_connectors.py +++ b/test/test_runner_connectors.py @@ -12,6 +12,7 @@ def test_get_data_files(self): directory_paths=[], file_type=("csv",)) data, names = connector.get_data(settings) + connector.close() self.assertEqual(len(data), 2) self.assertEqual(names[0], "./data/netflix_titles") self.assertEqual(names[1], "./data/disney_movies") @@ -22,4 +23,5 @@ def test_get_data_folder(self): directory_paths=["./data"], file_type=("csv",)) data, _ = connector.get_data(settings) + connector.close() self.assertEqual(len(data), 11) diff --git a/test/test_runner_formators.py b/test/test_runner_formators.py new file mode 100644 index 0000000..fc16e10 --- /dev/null +++ b/test/test_runner_formators.py @@ -0,0 +1,28 @@ +import unittest + +from formators.jason_formater import JsonFormater + + +class TestJsonFormater(unittest.TestCase): + def test_format_data(self): + data = {"a": {"b": 0.5, "c": 0.3}, + "b": {"a": 0.5, "c": 0.8}, + "c": {"a": 0.3, "b": 0.8}} + formater = JsonFormater() + jsondata = formater.format(data) + self.assertEqual(jsondata, '''{ + "a": { + "b": 0.5, + "c": 0.3 + }, + "b": { + "a": 0.5, + "c": 0.8 + }, + "c": { + "a": 0.3, + "b": 0.8 + } +}''') + +