diff --git a/main.py b/main.py index cb2acde..12835ed 100644 --- a/main.py +++ b/main.py @@ -13,8 +13,8 @@ ) from speed_tests import measure_execution_time -CONST_SIZE = 10 -CONST_MAX_LIST_LENGTH = 10 +CONST_SIZE = 100 +CONST_MAX_LIST_LENGTH = 100 if __name__ == "__main__": # Initialize the logger. If no log file is specified, logs will just save to . diff --git a/test_convert_to_pandas_df.py b/test_convert_to_pandas_df.py new file mode 100644 index 0000000..a4f3026 --- /dev/null +++ b/test_convert_to_pandas_df.py @@ -0,0 +1,32 @@ +import pytest +import pandas as pd +from dictionaries import convert_to_pandas_df # Replace with your actual module name + + +def test_normal_input(): + sample_data = [(1, 2), (3, 4)] + expected_output = pd.DataFrame({"Key": [1, 3], "Value": [2, 4]}) + pd.testing.assert_frame_equal(convert_to_pandas_df(sample_data), expected_output) + + +def test_empty_input(): + sample_data = [] + expected_output = pd.DataFrame(columns=["Key", "Value"]) + pd.testing.assert_frame_equal(convert_to_pandas_df(sample_data), expected_output) + + +def test_multiple_entries(): + sample_data = [("a", 1), ("a", 2), ("a", 3)] + expected_output = pd.DataFrame({"Key": ["a", "a", "a"], "Value": [1, 2, 3]}) + pd.testing.assert_frame_equal(convert_to_pandas_df(sample_data), expected_output) + + +def test_invalid_input_data(): + with pytest.raises(TypeError): + convert_to_pandas_df("invalid data") + + +def test_incorrect_tuple_length(): + sample_data = [("a", 1, "extra"), ("b", 2)] + with pytest.raises(ValueError): + convert_to_pandas_df(sample_data) diff --git a/test_convert_to_polars_df.py b/test_convert_to_polars_df.py new file mode 100644 index 0000000..febe46d --- /dev/null +++ b/test_convert_to_polars_df.py @@ -0,0 +1,35 @@ +import pytest +import polars as pl +from polars.testing import assert_frame_equal, assert_series_equal +from dictionaries import convert_to_polars_df + + +def test_normal_input(): + sample_data = [(1, 2), (3, 4)] + expected_output = pl.DataFrame( + {"column_0": [1, 2], "column_1": [3, 4]} + ) # Corrected expected values + pl.testing.assert_frame_equal(convert_to_polars_df(sample_data), expected_output) + + +def test_empty_input(): + sample_data = [] + expected_output = pl.DataFrame() + pl.testing.assert_frame_equal(convert_to_polars_df(sample_data), expected_output) + + +def test_multiple_entries(): + sample_data = [("a", 1), ("a", 2), ("a", 3)] + expected_output = pl.DataFrame({"column_0": ["a", "a", "a"], "column_1": [1, 2, 3]}) + pl.testing.assert_frame_equal(convert_to_polars_df(sample_data), expected_output) + + +def test_invalid_input_data(): + with pytest.raises(TypeError): + convert_to_polars_df("invalid data") + + +def test_incorrect_tuple_length(): + sample_data = [("a", 1, "extra"), ("b", 2)] + with pytest.raises(ValueError): + convert_to_polars_df(sample_data)