From 48c9d72612b704a5aee0d24b49577affdf1203f8 Mon Sep 17 00:00:00 2001 From: Vladislav Denisov Date: Tue, 21 Nov 2023 15:25:08 +0300 Subject: [PATCH] added tests for pandas converter and yandex disk --- tests/query_runner/test_yandex_disk.py | 27 ++++++++++++++++++++++++++ tests/test_utils.py | 3 +++ 2 files changed, 30 insertions(+) diff --git a/tests/query_runner/test_yandex_disk.py b/tests/query_runner/test_yandex_disk.py index 02ab267611..ca8c97e473 100644 --- a/tests/query_runner/test_yandex_disk.py +++ b/tests/query_runner/test_yandex_disk.py @@ -134,6 +134,33 @@ def test_run_query(mocked_requests, mock_yandex_disk): assert data == expected_data +@skip_condition +def test_run_query_with_empty_query(mock_yandex_disk): + result = mock_yandex_disk.run_query("", "user") + assert result == (None, "Query is empty") + + +@skip_condition +def test_run_query_bad_yaml(mock_yandex_disk): + bad_yaml_query = "unparseable = yaml" + result = mock_yandex_disk.run_query(bad_yaml_query, "user") + assert result == (None, "The query format must be JSON or YAML") + + +@skip_condition +def test_run_query_without_path(mock_yandex_disk): + bad_yaml_query = "without: path" + result = mock_yandex_disk.run_query(bad_yaml_query, "user") + assert result == (None, "The query must contain path") + + +@skip_condition +def test_run_query_unsupported_extension(mock_yandex_disk): + bad_yaml_query = "path: /tmp/file.txt" + result = mock_yandex_disk.run_query(bad_yaml_query, "user") + assert result == (None, "Unsupported file extension: txt") + + @skip_condition def test_read_xlsx(): output = BytesIO() diff --git a/tests/test_utils.py b/tests/test_utils.py index aca28eace5..78d193ab8f 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -122,6 +122,7 @@ def test_render(self): @pytest.fixture +@skip_condition def mock_dataframe(): df = pd.DataFrame( { @@ -136,6 +137,7 @@ def mock_dataframe(): return df +@skip_condition def test_get_column_types_from_dataframe(mock_dataframe): result = get_column_types_from_dataframe(mock_dataframe) expected_output = [ @@ -150,6 +152,7 @@ def test_get_column_types_from_dataframe(mock_dataframe): assert result == expected_output +@skip_condition def test_pandas_to_result(mock_dataframe): result = pandas_to_result(mock_dataframe)