diff --git a/src/pyFAI/test/test_integrate_config.py b/src/pyFAI/test/test_integrate_config.py index de951bf86..f239d2d0b 100644 --- a/src/pyFAI/test/test_integrate_config.py +++ b/src/pyFAI/test/test_integrate_config.py @@ -32,7 +32,7 @@ __contact__ = "valentin.valls@esrf.fr" __license__ = "MIT" __copyright__ = "European Synchrotron Radiation Facility, Grenoble, France" -__date__ = "15/04/2024" +__date__ = "20/12/2024" import os import json @@ -50,31 +50,31 @@ def test_poni(self): config = {"poni": utilstest.UtilsTest.getimage("Pilatus1M.poni"), "wavelength": 50} config = integration_config.normalize(config) - self.assertNotIn("poni", config) + # self.assertNotIn("poni", config) # From PONI file - self.assertEqual(config["dist"], 1.58323111834) + self.assertEqual(config["poni"]["dist"], 1.58323111834) # From dict - self.assertEqual(config["wavelength"], 50) + self.assertEqual(config["poni"]["wavelength"], 50) def test_single_flatdark(self): config = {"dark_current": "abc", "flat_field": "abd"} config = integration_config.normalize(config) - self.assertEqual(config["dark_current"], "abc") - self.assertEqual(config["flat_field"], "abd") + self.assertEqual(config["dark_current_image"], "abc") + self.assertEqual(config["flat_field_image"], "abd") def test_coma_flatdark(self): config = {"dark_current": "a,b,c", "flat_field": "a,b,d"} config = integration_config.normalize(config) - self.assertEqual(config["dark_current"], ["a", "b", "c"]) - self.assertEqual(config["flat_field"], ["a", "b", "d"]) + self.assertEqual(config["dark_current_image"], ["a", "b", "c"]) + self.assertEqual(config["flat_field_image"], ["a", "b", "d"]) def test_pilatus(self): config = {"detector": "pilatus2m"} config = integration_config.normalize(config) - self.assertEqual(config["detector"], "Pilatus2M") - self.assertIsInstance(config["detector_config"], dict) + self.assertEqual(config["poni"]["detector"], "Pilatus2M") + self.assertIsInstance(config["poni"]["detector_config"], dict) def test_detector(self): config = {"detector": "detector", @@ -83,9 +83,9 @@ def test_detector(self): config = integration_config.normalize(config) self.assertNotIn("pixel1", config) self.assertNotIn("pixel2", config) - self.assertEqual(config["detector"], "Detector") - self.assertEqual(config["detector_config"]["pixel1"], 1.0) - self.assertEqual(config["detector_config"]["pixel2"], 1.0) + self.assertEqual(config["poni"]["detector"], "Detector") + self.assertEqual(config["poni"]["detector_config"]["pixel1"], 1.0) + self.assertEqual(config["poni"]["detector_config"]["pixel2"], 1.0) def test_frelon(self): spline_file = utilstest.UtilsTest.getimage("frelon.spline") @@ -93,8 +93,8 @@ def test_frelon(self): "splineFile": spline_file} config = integration_config.normalize(config) self.assertNotIn("splineFile", config) - self.assertEqual(config["detector"], "FReLoN") - self.assertEqual(config["detector_config"]["splineFile"], spline_file) + self.assertEqual(config["poni"]["detector"], "FReLoN") + self.assertEqual(config["poni"]["detector_config"]["splineFile"], spline_file) def test_opencl(self): config = {"do_OpenCL": True} @@ -151,6 +151,14 @@ def test_2132(self): expected = expected_with_gpu if ocl else expected_without_gpu self.assertEqual(parsed_config["ai"]["method"], expected, "method match with -g option") + def test_dataclass(self): + test_files = "0.14_verson0.json id11_v0.json id13_v0.json id15_1_v0.json id15_v0.json id16_v3.json id21_v0.json version0.json version3.json version4.json" + for fn in test_files.split(): + js = utilstest.UtilsTest.getimage(fn) + with utilstest.TestLogging(logger='pyFAI.io.integrarion_config', warning=0): + # with self.assertLogs('pyFAI.io.integrarion_config', level='WARNING') as cm: + wc = integration_config.WorkerConfig.load(js) + self.assertEqual(wc, integration_config.WorkerConfig.from_dict(wc.as_dict()), f"Idempotent {fn}") def suite(): diff --git a/src/pyFAI/test/test_worker.py b/src/pyFAI/test/test_worker.py index ae22db0d0..6e0799356 100644 --- a/src/pyFAI/test/test_worker.py +++ b/src/pyFAI/test/test_worker.py @@ -557,18 +557,6 @@ def test_v3_equal_to_v4(self): poni_v4_from_config = PoniFile(data=config_v4) self.assertEqual(poni_v3_from_config.as_dict(), poni_v4_from_config.as_dict(), "PONI dictionaries from config match") - def test_dataclass(self): - test_files = "0.14_verson0.json id11_v0.json id13_v0.json id15_1_v0.json id15_v0.json id16_v3.json id21_v0.json version0.json version3.json version4.json" - for fn in test_files.split(): - js = utilstest.UtilsTest.getimage(fn) - with utilstest.TestLogging(logger='pyFAI.io.integrarion_config', warning=0): - # with self.assertLogs('pyFAI.io.integrarion_config', level='WARNING') as cm: - wc = WorkerConfig.load(js) - self.assertEqual(wc, WorkerConfig.from_dict(wc.as_dict()), f"Idempotent {fn}") - - - - def suite(): loader = unittest.defaultTestLoader.loadTestsFromTestCase