From 924672e7f580d87a2b717f2f933befc411f24029 Mon Sep 17 00:00:00 2001 From: wverastegui Date: Fri, 9 Feb 2024 16:04:37 +0100 Subject: [PATCH] updated --- tests/test_data.py | 23 +++++------------------ tests/test_utils.py | 2 +- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/tests/test_data.py b/tests/test_data.py index ec16031..d4e58f5 100644 --- a/tests/test_data.py +++ b/tests/test_data.py @@ -17,12 +17,6 @@ def does_not_raise(): yield -def _add_possible_key(keys, new_keys): - possible_keys = list(keys) - possible_keys += new_keys - return set(possible_keys) - - @pytest.mark.parametrize("filename, filetype, builder, expectation", [ ["Alkanes_20210325.msp", "msp", MatchMSDataBuilder, does_not_raise()], ["Alkanes_20210325.msp", "csv", MatchMSDataBuilder, pytest.raises(TypeError)], @@ -42,28 +36,21 @@ def test_filetype(filename, filetype, builder, expectation): builder.build() -@pytest.mark.parametrize("keys", [["test-key"], ["first_key", "second_key"]]) -def test_add_possible_keys(keys): - expected_ri_keys = _add_possible_key(Data.get_possible_ri_keys(), keys) - expected_rt_keys = _add_possible_key(Data.get_possible_rt_keys(), keys) - - Data.add_possible_ri_keys(keys) - Data.add_possible_rt_keys(keys) - - assert Data.get_possible_ri_keys() == expected_ri_keys - assert Data.get_possible_rt_keys() == expected_rt_keys - - @pytest.mark.parametrize("builder, filename_dat, filename_native, rt_unit", [ [MatchMSDataBuilder(), 'Alkanes_20210325.dat', "Alkanes_20210325.msp", "min"], [PandasDataBuilder(), 'aplcms_aligned_peaks.dat', "aplcms_aligned_peaks.csv", "sec"] ]) def test_read_dat(builder, filename_dat, filename_native, rt_unit): + # arrange ext = get_extension(filename_native) filename = os.path.join(here, 'data', 'dat', filename_dat) builder = builder.with_rt_unit(rt_unit).with_filename(filename) + + # act data_dat = builder.build() data_native = builder.with_filename(os.path.join(testdata_dir, ext, filename_native)).build() + + # assert assert data_dat == data_native diff --git a/tests/test_utils.py b/tests/test_utils.py index 89afd71..93d1573 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -34,7 +34,7 @@ def test_is_sorted(values, expected): @pytest.mark.parametrize("unclean_col_name, expected", [ [[" col_name_1 "], ["col_name_1"]], # test case for leading and trailing whitespaces [["COL_NAME_2"], ["col_name_2"]], # test case for uppercase - [["col_name 3"], ["col_name_3"]] # test case for whitespaces in between + [[" COL_NAME_3 "], ["col_name_3"]], # test case for leading and trailing whitespaces and uppercase ]) def test_clean_column_names(unclean_col_name, expected): # arrange and act