ATLAS Offline Software
Loading...
Searching...
No Matches
DumpGeoConfig_test.DumpGeoConfigTest Class Reference
Inheritance diagram for DumpGeoConfig_test.DumpGeoConfigTest:
Collaboration diagram for DumpGeoConfig_test.DumpGeoConfigTest:

Public Member Functions

 test_default_flags (self)
 test_configuration_does_not_dump_flags_at_info_level (self)
 test_configuration_dumps_flags_at_debug_level (self)
 test_automatic_output_filename (self)
 test_automatic_filename_and_filter (self)
 test_custom_output_filename (self)
 test_show_treetop_content (self)
 test_explicit_properties_override_flags (self)
 test_explicit_output_filename_is_validated (self)
 test_force_overwrite_configures_explicit_output_filename (self)
 test_force_overwrite_does_not_delete_during_configuration (self)
 test_explicit_force_overwrite_property_is_authoritative (self)
 test_existing_file_without_force_raises (self)
 test_force_overwrite_preflight_does_not_remove_existing_file (self)
 test_output_filename_helper (self)
 test_detdescr_overrides_generic_geometry_flag (self)
 test_geometry_tag_is_preserved_without_detdescr (self)
 test_geometry_fallback_is_used_when_no_tag_is_available (self)
 test_input_file_detection (self)
 test_inputless_flags_are_initialized_without_an_event_file (self)
 test_real_input_files_are_preserved (self)
 test_resolved_geometry_tag_is_used_in_output_filename (self)
 test_zdc_failure_reminder_is_logged (self)
 test_zdc_failure_reminder_is_suppressed_when_not_applicable (self)
 test_custom_filename_and_filter (self)
 test_algorithm_name (self)

Protected Member Functions

 _algorithm (self, flags, **kwargs)

Static Protected Member Functions

 _flags (*, output_file="", filters=None, force_overwrite=False, show_treetops=False, atlas_version="ATLAS-UNIT-TEST-00-00-00")

Detailed Description

Characterization tests for DumpGeoCfg.

Definition at line 24 of file DumpGeoConfig_test.py.

Member Function Documentation

◆ _algorithm()

DumpGeoConfig_test.DumpGeoConfigTest._algorithm ( self,
flags,
** kwargs )
protected

Definition at line 41 of file DumpGeoConfig_test.py.

41 def _algorithm(self, flags, **kwargs):
42 with patch("DumpGeo.DumpGeoConfig.os.path.exists", return_value=False):
43 accumulator = DumpGeoCfg(flags, **kwargs)
44 self.addCleanup(accumulator.wasMerged)
45 return accumulator.getPrimary()
46

◆ _flags()

DumpGeoConfig_test.DumpGeoConfigTest._flags ( * ,
output_file = "",
filters = None,
force_overwrite = False,
show_treetops = False,
atlas_version = "ATLAS-UNIT-TEST-00-00-00" )
staticprotected

Definition at line 28 of file DumpGeoConfig_test.py.

30 atlas_version="ATLAS-UNIT-TEST-00-00-00"):
31 flags = AthConfigFlags()
32 flags.addFlag("GeoModel.AtlasVersion", atlas_version)
33 createDumpGeoConfigFlags(flags)
34 flags.GeoModel.DumpGeo.OutputFileName = output_file
35 flags.GeoModel.DumpGeo.FilterDetManagers = filters or []
36 flags.GeoModel.DumpGeo.ForceOverwrite = force_overwrite
37 flags.GeoModel.DumpGeo.ShowTreetopContent = show_treetops
38 flags.lock()
39 return flags
40

◆ test_algorithm_name()

DumpGeoConfig_test.DumpGeoConfigTest.test_algorithm_name ( self)
DumpGeoCfg passes its name argument to the algorithm.

Definition at line 319 of file DumpGeoConfig_test.py.

319 def test_algorithm_name(self):
320 """DumpGeoCfg passes its name argument to the algorithm."""
321 algorithm = self._algorithm(self._flags(), name="RequestedDumpGeo")
322
323 self.assertEqual(algorithm.name, "RequestedDumpGeo")
324
325

◆ test_automatic_filename_and_filter()

DumpGeoConfig_test.DumpGeoConfigTest.test_automatic_filename_and_filter ( self)

Definition at line 95 of file DumpGeoConfig_test.py.

95 def test_automatic_filename_and_filter(self):
96 algorithm = self._algorithm(
97 self._flags(filters=["Pixel", "Tile"])
98 )
99
100 self.assertEqual(
101 algorithm.OutSQLiteFileName,
102 "geometry-ATLAS-UNIT-TEST-00-00-00-Pixel-Tile.db",
103 )
104 self.assertEqual(algorithm.UserFilterDetManager, ["Pixel", "Tile"])
105

◆ test_automatic_output_filename()

DumpGeoConfig_test.DumpGeoConfigTest.test_automatic_output_filename ( self)

Definition at line 87 of file DumpGeoConfig_test.py.

87 def test_automatic_output_filename(self):
88 algorithm = self._algorithm(self._flags())
89
90 self.assertEqual(
91 algorithm.OutSQLiteFileName,
92 "geometry-ATLAS-UNIT-TEST-00-00-00.db",
93 )
94

◆ test_configuration_does_not_dump_flags_at_info_level()

DumpGeoConfig_test.DumpGeoConfigTest.test_configuration_does_not_dump_flags_at_info_level ( self)

Definition at line 57 of file DumpGeoConfig_test.py.

57 def test_configuration_does_not_dump_flags_at_info_level(self):
58 flags = self._flags()
59
60 with (
61 patch.object(AthConfigFlags, "dump") as dump,
62 patch(
63 "DumpGeo.DumpGeoConfig._logger.isEnabledFor",
64 return_value=False,
65 ),
66 ):
67 accumulator = DumpGeoCfg(flags)
68
69 self.addCleanup(accumulator.wasMerged)
70 dump.assert_not_called()
71

◆ test_configuration_dumps_flags_at_debug_level()

DumpGeoConfig_test.DumpGeoConfigTest.test_configuration_dumps_flags_at_debug_level ( self)

Definition at line 72 of file DumpGeoConfig_test.py.

72 def test_configuration_dumps_flags_at_debug_level(self):
73 flags = self._flags()
74
75 with (
76 patch.object(AthConfigFlags, "dump") as dump,
77 patch(
78 "DumpGeo.DumpGeoConfig._logger.isEnabledFor",
79 return_value=True,
80 ),
81 ):
82 accumulator = DumpGeoCfg(flags)
83
84 self.addCleanup(accumulator.wasMerged)
85 dump.assert_called_once_with("GeoModel.DumpGeo")
86

◆ test_custom_filename_and_filter()

DumpGeoConfig_test.DumpGeoConfigTest.test_custom_filename_and_filter ( self)
A custom filename must not disable DetectorManager filtering.

Definition at line 308 of file DumpGeoConfig_test.py.

308 def test_custom_filename_and_filter(self):
309 """A custom filename must not disable DetectorManager filtering."""
310 algorithm = self._algorithm(
311 self._flags(
312 output_file="filtered.db",
313 filters=["Pixel", "Tile"],
314 )
315 )
316
317 self.assertEqual(algorithm.UserFilterDetManager, ["Pixel", "Tile"])
318

◆ test_custom_output_filename()

DumpGeoConfig_test.DumpGeoConfigTest.test_custom_output_filename ( self)

Definition at line 106 of file DumpGeoConfig_test.py.

106 def test_custom_output_filename(self):
107 algorithm = self._algorithm(
108 self._flags(output_file="custom-geometry.db")
109 )
110
111 self.assertEqual(algorithm.OutSQLiteFileName, "custom-geometry.db")
112

◆ test_default_flags()

DumpGeoConfig_test.DumpGeoConfigTest.test_default_flags ( self)

Definition at line 47 of file DumpGeoConfig_test.py.

47 def test_default_flags(self):
48 flags = AthConfigFlags()
49 createDumpGeoConfigFlags(flags)
50 flags.lock()
51
52 self.assertEqual(flags.GeoModel.DumpGeo.OutputFileName, "")
53 self.assertEqual(flags.GeoModel.DumpGeo.FilterDetManagers, [])
54 self.assertFalse(flags.GeoModel.DumpGeo.ForceOverwrite)
55 self.assertFalse(flags.GeoModel.DumpGeo.ShowTreetopContent)
56

◆ test_detdescr_overrides_generic_geometry_flag()

DumpGeoConfig_test.DumpGeoConfigTest.test_detdescr_overrides_generic_geometry_flag ( self)

Definition at line 223 of file DumpGeoConfig_test.py.

223 def test_detdescr_overrides_generic_geometry_flag(self):
224 self.assertEqual(
225 resolveDumpGeoGeometryTag(
226 "ALIAS-TAG",
227 "GENERIC-TAG",
228 "FALLBACK-TAG",
229 ),
230 "ALIAS-TAG",
231 )
232

◆ test_existing_file_without_force_raises()

DumpGeoConfig_test.DumpGeoConfigTest.test_existing_file_without_force_raises ( self)

Definition at line 194 of file DumpGeoConfig_test.py.

194 def test_existing_file_without_force_raises(self):
195 flags = self._flags(output_file="existing.db")
196
197 with (
198 patch("DumpGeo.DumpGeoConfig.os.path.exists", return_value=True),
199 patch("DumpGeo.DumpGeoConfig.os.remove") as remove,
200 ):
201 with self.assertRaisesRegex(ConfigurationError, "existing.db"):
202 DumpGeoCfg(flags)
203
204 remove.assert_not_called()
205

◆ test_explicit_force_overwrite_property_is_authoritative()

DumpGeoConfig_test.DumpGeoConfigTest.test_explicit_force_overwrite_property_is_authoritative ( self)

Definition at line 178 of file DumpGeoConfig_test.py.

178 def test_explicit_force_overwrite_property_is_authoritative(self):
179 flags = self._flags(
180 output_file="existing.db",
181 force_overwrite=False,
182 )
183
184 with (
185 patch("DumpGeo.DumpGeoConfig.os.path.exists", return_value=True),
186 patch("DumpGeo.DumpGeoConfig.os.remove") as remove,
187 ):
188 accumulator = DumpGeoCfg(flags, ForceOverwrite=True)
189
190 self.addCleanup(accumulator.wasMerged)
191 self.assertTrue(accumulator.getPrimary().ForceOverwrite)
192 remove.assert_not_called()
193

◆ test_explicit_output_filename_is_validated()

DumpGeoConfig_test.DumpGeoConfigTest.test_explicit_output_filename_is_validated ( self)

Definition at line 128 of file DumpGeoConfig_test.py.

128 def test_explicit_output_filename_is_validated(self):
129 flags = self._flags(output_file="from-flags.db")
130
131 with patch(
132 "DumpGeo.DumpGeoConfig.os.path.exists",
133 side_effect=lambda path: path == "from-kwargs.db",
134 ):
135 with self.assertRaisesRegex(ConfigurationError, "from-kwargs.db"):
136 DumpGeoCfg(flags, OutSQLiteFileName="from-kwargs.db")
137

◆ test_explicit_properties_override_flags()

DumpGeoConfig_test.DumpGeoConfigTest.test_explicit_properties_override_flags ( self)

Definition at line 118 of file DumpGeoConfig_test.py.

118 def test_explicit_properties_override_flags(self):
119 algorithm = self._algorithm(
120 self._flags(show_treetops=True),
121 ShowTreetopContent=False,
122 OutSQLiteFileName="from-kwargs.db",
123 )
124
125 self.assertFalse(algorithm.ShowTreetopContent)
126 self.assertEqual(algorithm.OutSQLiteFileName, "from-kwargs.db")
127

◆ test_force_overwrite_configures_explicit_output_filename()

DumpGeoConfig_test.DumpGeoConfigTest.test_force_overwrite_configures_explicit_output_filename ( self)

Definition at line 138 of file DumpGeoConfig_test.py.

138 def test_force_overwrite_configures_explicit_output_filename(self):
139 flags = self._flags(
140 output_file="from-flags.db",
141 force_overwrite=True,
142 )
143
144 with (
145 patch(
146 "DumpGeo.DumpGeoConfig.os.path.exists",
147 side_effect=lambda path: path == "from-kwargs.db",
148 ),
149 patch("DumpGeo.DumpGeoConfig.os.remove") as remove,
150 ):
151 accumulator = DumpGeoCfg(
152 flags,
153 OutSQLiteFileName="from-kwargs.db",
154 )
155
156 self.addCleanup(accumulator.wasMerged)
157 algorithm = accumulator.getPrimary()
158 self.assertEqual(algorithm.OutSQLiteFileName, "from-kwargs.db")
159 self.assertTrue(algorithm.ForceOverwrite)
160 remove.assert_not_called()
161

◆ test_force_overwrite_does_not_delete_during_configuration()

DumpGeoConfig_test.DumpGeoConfigTest.test_force_overwrite_does_not_delete_during_configuration ( self)

Definition at line 162 of file DumpGeoConfig_test.py.

162 def test_force_overwrite_does_not_delete_during_configuration(self):
163 flags = self._flags(
164 output_file="existing.db",
165 force_overwrite=True,
166 )
167
168 with (
169 patch("DumpGeo.DumpGeoConfig.os.path.exists", return_value=True),
170 patch("DumpGeo.DumpGeoConfig.os.remove") as remove,
171 ):
172 accumulator = DumpGeoCfg(flags)
173
174 self.addCleanup(accumulator.wasMerged)
175 self.assertTrue(accumulator.getPrimary().ForceOverwrite)
176 remove.assert_not_called()
177

◆ test_force_overwrite_preflight_does_not_remove_existing_file()

DumpGeoConfig_test.DumpGeoConfigTest.test_force_overwrite_preflight_does_not_remove_existing_file ( self)

Definition at line 206 of file DumpGeoConfig_test.py.

206 def test_force_overwrite_preflight_does_not_remove_existing_file(self):
207 with (
208 patch("DumpGeo.DumpGeoConfig.os.path.exists", return_value=True),
209 patch("DumpGeo.DumpGeoConfig.os.remove") as remove,
210 ):
211 validateDumpGeoOutputFile("existing.db", force_overwrite=True)
212
213 remove.assert_not_called()
214

◆ test_geometry_fallback_is_used_when_no_tag_is_available()

DumpGeoConfig_test.DumpGeoConfigTest.test_geometry_fallback_is_used_when_no_tag_is_available ( self)

Definition at line 243 of file DumpGeoConfig_test.py.

243 def test_geometry_fallback_is_used_when_no_tag_is_available(self):
244 self.assertEqual(
245 resolveDumpGeoGeometryTag(None, None, "FALLBACK-TAG"),
246 "FALLBACK-TAG",
247 )
248

◆ test_geometry_tag_is_preserved_without_detdescr()

DumpGeoConfig_test.DumpGeoConfigTest.test_geometry_tag_is_preserved_without_detdescr ( self)

Definition at line 233 of file DumpGeoConfig_test.py.

233 def test_geometry_tag_is_preserved_without_detdescr(self):
234 self.assertEqual(
235 resolveDumpGeoGeometryTag(
236 None,
237 "GEOMETRY-TAG",
238 "FALLBACK-TAG",
239 ),
240 "GEOMETRY-TAG",
241 )
242

◆ test_input_file_detection()

DumpGeoConfig_test.DumpGeoConfigTest.test_input_file_detection ( self)
Only actual filenames enable input metadata configuration.

Definition at line 249 of file DumpGeoConfig_test.py.

249 def test_input_file_detection(self):
250 """Only actual filenames enable input metadata configuration."""
251 self.assertFalse(dumpGeoHasInputFiles([]))
252 self.assertFalse(
253 dumpGeoHasInputFiles(["_ATHENA_GENERIC_INPUTFILE_NAME_"])
254 )
255 self.assertTrue(dumpGeoHasInputFiles(["events.pool.root"]))
256

◆ test_inputless_flags_are_initialized_without_an_event_file()

DumpGeoConfig_test.DumpGeoConfigTest.test_inputless_flags_are_initialized_without_an_event_file ( self)

Definition at line 257 of file DumpGeoConfig_test.py.

257 def test_inputless_flags_are_initialized_without_an_event_file(self):
258 flags = SimpleNamespace(
259 Input=SimpleNamespace(
260 Files=["_ATHENA_GENERIC_INPUTFILE_NAME_"]
261 ),
262 IOVDb=SimpleNamespace(),
263 )
264
265 self.assertTrue(configureDumpGeoInputFlags(flags))
266 self.assertEqual(flags.Input.Files, [])
267 self.assertEqual(flags.Input.RunNumbers, [330000])
268 self.assertEqual(flags.Input.TimeStamps, [1])
269 self.assertEqual(flags.Input.TypedCollections, [])
270 self.assertTrue(flags.Input.isMC)
271

◆ test_output_filename_helper()

DumpGeoConfig_test.DumpGeoConfigTest.test_output_filename_helper ( self)

Definition at line 215 of file DumpGeoConfig_test.py.

215 def test_output_filename_helper(self):
216 flags = self._flags(filters=["Pixel", "Tile"])
217
218 self.assertEqual(
219 dumpGeoOutputFileName(flags),
220 "geometry-ATLAS-UNIT-TEST-00-00-00-Pixel-Tile.db",
221 )
222

◆ test_real_input_files_are_preserved()

DumpGeoConfig_test.DumpGeoConfigTest.test_real_input_files_are_preserved ( self)

Definition at line 272 of file DumpGeoConfig_test.py.

272 def test_real_input_files_are_preserved(self):
273 flags = SimpleNamespace(
274 Input=SimpleNamespace(Files=["events.pool.root"]),
275 IOVDb=SimpleNamespace(),
276 )
277
278 self.assertFalse(configureDumpGeoInputFlags(flags))
279 self.assertEqual(flags.Input.Files, ["events.pool.root"])
280

◆ test_resolved_geometry_tag_is_used_in_output_filename()

DumpGeoConfig_test.DumpGeoConfigTest.test_resolved_geometry_tag_is_used_in_output_filename ( self)

Definition at line 281 of file DumpGeoConfig_test.py.

281 def test_resolved_geometry_tag_is_used_in_output_filename(self):
282 geometry_tag = resolveDumpGeoGeometryTag(
283 None,
284 "METADATA-TAG",
285 "FALLBACK-TAG",
286 )
287 flags = self._flags(atlas_version=geometry_tag)
288
289 self.assertEqual(
290 dumpGeoOutputFileName(flags),
291 "geometry-METADATA-TAG.db",
292 )
293

◆ test_show_treetop_content()

DumpGeoConfig_test.DumpGeoConfigTest.test_show_treetop_content ( self)

Definition at line 113 of file DumpGeoConfig_test.py.

113 def test_show_treetop_content(self):
114 algorithm = self._algorithm(self._flags(show_treetops=True))
115
116 self.assertTrue(algorithm.ShowTreetopContent)
117

◆ test_zdc_failure_reminder_is_logged()

DumpGeoConfig_test.DumpGeoConfigTest.test_zdc_failure_reminder_is_logged ( self)

Definition at line 294 of file DumpGeoConfig_test.py.

294 def test_zdc_failure_reminder_is_logged(self):
295 with patch("DumpGeo.DumpGeoConfig._logger.error") as logger_error:
296 logZDCFailureReminder(zdc_enabled=True, run_succeeded=False)
297
298 logger_error.assert_called_once()
299 self.assertIn("ZDC geometry was enabled", logger_error.call_args[0][0])
300

◆ test_zdc_failure_reminder_is_suppressed_when_not_applicable()

DumpGeoConfig_test.DumpGeoConfigTest.test_zdc_failure_reminder_is_suppressed_when_not_applicable ( self)

Definition at line 301 of file DumpGeoConfig_test.py.

301 def test_zdc_failure_reminder_is_suppressed_when_not_applicable(self):
302 with patch("DumpGeo.DumpGeoConfig._logger.error") as logger_error:
303 logZDCFailureReminder(zdc_enabled=False, run_succeeded=False)
304 logZDCFailureReminder(zdc_enabled=True, run_succeeded=True)
305
306 logger_error.assert_not_called()
307

The documentation for this class was generated from the following file: