From 80c40b4bfbbb0960acf8660f98f0ac9fe76c8786 Mon Sep 17 00:00:00 2001 From: Panu Lahtinen Date: Thu, 20 Jun 2024 10:14:05 +0300 Subject: [PATCH] Add a test that nonshareable variables are not shared --- satpy/tests/reader_tests/test_fci_l1c_nc.py | 33 +++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/satpy/tests/reader_tests/test_fci_l1c_nc.py b/satpy/tests/reader_tests/test_fci_l1c_nc.py index 1d478a21a3..8e24212b67 100644 --- a/satpy/tests/reader_tests/test_fci_l1c_nc.py +++ b/satpy/tests/reader_tests/test_fci_l1c_nc.py @@ -956,7 +956,8 @@ def test_reusing_shared_segment_info(): with mock.patch("satpy.readers.netcdf_utils.NetCDF4FsspecFileHandler._get_file_handle"): with mock.patch("satpy.readers.netcdf_utils.np2str", _mock_np2str): fh_ = FCIL1cNCFileHandler(filename, filename_info, filetype_info) - assert fh_.file_content["attr/platform"] == filetype_info["shared_info"]["attr/platform"] + + assert fh_.file_content["attr/platform"] == filetype_info["shared_info"]["attr/platform"] def test_store_shared_segment_info(): @@ -969,4 +970,32 @@ def test_store_shared_segment_info(): get_file_handle.return_value.platform = "mock-satellite" with mock.patch("satpy.readers.netcdf_utils.np2str", _mock_np2str): _ = FCIL1cNCFileHandler(filename, filename_info, filetype_info) - assert filetype_info["shared_info"]["attr/platform"] == "mock-satellite" + + assert filetype_info["shared_info"]["attr/platform"] == "mock-satellite" + + +def test_store_shared_segment_info_ignore_nonshareable(): + """Test that nonshareable segment info are not collected for sharing.""" + variables = [ + "data/ir105/measured/effective_radiance", + "data/ir105/measured/y", + "data/ir105/measured/end_position_row", + "data/ir105/measured/start_position_row", + "data/ir105/measured/index_map", + "data/ir105/measured/pixel_quality", + "index", + "time", + ] + + filename = TEST_FILENAMES["fdhsi"][0] + filename_info = parse_fdhsi_filename_info(filename) + filetype_info = {"required_netcdf_variables": variables} + + with mock.patch("satpy.readers.netcdf_utils.NetCDF4FsspecFileHandler._get_file_handle") as get_file_handle: + for itm in variables: + setattr(get_file_handle.return_value, itm, "mock-value") + with mock.patch("satpy.readers.netcdf_utils.np2str", _mock_np2str): + _ = FCIL1cNCFileHandler(filename, filename_info, filetype_info) + + for itm in variables: + assert itm not in filetype_info["shared_info"]