psdi-data-conversion 0.0.35__py3-none-any.whl → 0.0.37__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. psdi_data_conversion/app.py +110 -10
  2. psdi_data_conversion/constants.py +2 -0
  3. psdi_data_conversion/converter.py +16 -6
  4. psdi_data_conversion/converters/atomsk.py +3 -1
  5. psdi_data_conversion/converters/base.py +99 -39
  6. psdi_data_conversion/converters/c2x.py +3 -1
  7. psdi_data_conversion/converters/openbabel.py +40 -1
  8. psdi_data_conversion/database.py +5 -0
  9. psdi_data_conversion/main.py +18 -10
  10. psdi_data_conversion/static/content/accessibility.htm +5 -5
  11. psdi_data_conversion/static/content/convert.htm +18 -13
  12. psdi_data_conversion/static/content/convertato.htm +40 -33
  13. psdi_data_conversion/static/content/convertc2x.htm +40 -33
  14. psdi_data_conversion/static/content/documentation.htm +4 -4
  15. psdi_data_conversion/static/content/download.htm +26 -10
  16. psdi_data_conversion/static/content/feedback.htm +4 -4
  17. psdi_data_conversion/static/content/index-versions/psdi-common-header.html +1 -1
  18. psdi_data_conversion/static/content/psdi-common-header.html +1 -1
  19. psdi_data_conversion/static/content/report.htm +9 -7
  20. psdi_data_conversion/static/javascript/common.js +20 -0
  21. psdi_data_conversion/static/javascript/convert.js +1 -2
  22. psdi_data_conversion/static/javascript/convert_common.js +80 -7
  23. psdi_data_conversion/static/javascript/convertato.js +1 -2
  24. psdi_data_conversion/static/javascript/convertc2x.js +1 -2
  25. psdi_data_conversion/static/javascript/format.js +12 -0
  26. psdi_data_conversion/static/javascript/report.js +6 -0
  27. psdi_data_conversion/static/styles/format.css +0 -6
  28. psdi_data_conversion/static/styles/psdi-common.css +10 -6
  29. psdi_data_conversion/templates/index.htm +10 -2
  30. psdi_data_conversion/testing/constants.py +6 -3
  31. psdi_data_conversion/testing/conversion_callbacks.py +7 -6
  32. psdi_data_conversion/testing/conversion_test_specs.py +333 -153
  33. psdi_data_conversion/testing/gui.py +366 -0
  34. psdi_data_conversion/testing/utils.py +108 -51
  35. {psdi_data_conversion-0.0.35.dist-info → psdi_data_conversion-0.0.37.dist-info}/METADATA +90 -51
  36. {psdi_data_conversion-0.0.35.dist-info → psdi_data_conversion-0.0.37.dist-info}/RECORD +39 -38
  37. {psdi_data_conversion-0.0.35.dist-info → psdi_data_conversion-0.0.37.dist-info}/WHEEL +1 -1
  38. {psdi_data_conversion-0.0.35.dist-info → psdi_data_conversion-0.0.37.dist-info}/entry_points.txt +1 -0
  39. {psdi_data_conversion-0.0.35.dist-info → psdi_data_conversion-0.0.37.dist-info}/licenses/LICENSE +0 -0
@@ -15,194 +15,374 @@ from psdi_data_conversion.converters.openbabel import CONVERTER_OB, COORD_GEN_KE
15
15
  from psdi_data_conversion.testing.conversion_callbacks import (CheckArchiveContents, CheckException, CheckLogContents,
16
16
  CheckLogContentsSuccess, CheckFileStatus,
17
17
  CheckStderrContents, CheckStdoutContents,
18
- MatchOutputFile, MultiCallback)
19
- from psdi_data_conversion.testing.utils import ConversionTestSpec
20
-
21
- basic_tests = ConversionTestSpec(filename=["1NE6.mmcif", "standard_test.cdxml",
22
- "hemoglobin.pdb", "nacl.cif",
23
- "hemoglobin.pdb", "nacl.cif",
24
- "hemoglobin.pdb", "nacl.cif"],
25
- to_format=["pdb", "inchi", "cif", "xyz",
26
- "cif", "xyz",
27
- "cif", "xyz"],
28
- name=[CONVERTER_OB, CONVERTER_OB,
29
- CONVERTER_OB, CONVERTER_OB,
30
- CONVERTER_ATO, CONVERTER_ATO,
31
- CONVERTER_C2X, CONVERTER_C2X],
32
- callback=MultiCallback(CheckFileStatus(),
33
- CheckLogContentsSuccess()))
34
- """A basic set of test conversions which we expect to succeed without issue, running two conversions with each of the
18
+ MatchOutputFile, MultiCallback as MCB)
19
+ from psdi_data_conversion.testing.utils import ConversionTestSpec as Spec
20
+
21
+
22
+ l_all_test_specs: list[Spec] = []
23
+ """All test specs defined in this file"""
24
+
25
+ l_all_test_specs.append(Spec(name="Standard Single Test",
26
+ filename="standard_test.cdxml",
27
+ to_format="inchi",
28
+ callback=MCB(CheckFileStatus(),
29
+ CheckLogContentsSuccess(),
30
+ MatchOutputFile("standard_test.inchi")),
31
+ ))
32
+
33
+ l_all_test_specs.append(Spec(name="Standard Multiple Tests",
34
+ filename=["1NE6.mmcif",
35
+ "hemoglobin.pdb", "aceticacid.mol", "nacl.cif",
36
+ "hemoglobin.pdb", "hemoglobin.pdb", "nacl.cif",
37
+ "hemoglobin.pdb", "hemoglobin.pdb", "nacl.cif",
38
+ "ethanol.xyz"],
39
+ to_format=["pdb",
40
+ "cif", "mol2", "xyz",
41
+ "cif", "xyz", "xyz",
42
+ "cif", "xyz", "xyz",
43
+ "cml"],
44
+ converter_name=[CONVERTER_OB,
45
+ CONVERTER_OB, CONVERTER_OB, CONVERTER_OB,
46
+ CONVERTER_ATO, CONVERTER_ATO, CONVERTER_ATO,
47
+ CONVERTER_C2X, CONVERTER_C2X, CONVERTER_C2X,
48
+ CONVERTER_OB],
49
+ callback=MCB(CheckFileStatus(),
50
+ CheckLogContentsSuccess()),
51
+ ))
52
+ """A basic set of test conversions which we expect to succeed without issue, running conversions with each of the
35
53
  Open Babel, Atomsk, and c2x converters"""
36
54
 
37
- archive_callback = MultiCallback(CheckFileStatus(),
38
- CheckArchiveContents(l_filename_bases=["caffeine-no-flags",
39
- "caffeine-ia",
40
- "caffeine-ia-ox",
41
- "caffeine-ia-okx",
42
- "caffeine-ia-okx-oof4",
43
- "caffeine-ia-okx-oof4l5",],
44
- to_format="inchi"))
45
- archive_tests = ConversionTestSpec(filename=["caffeine-smi.zip",
46
- "caffeine-smi.tar",
47
- "caffeine-smi.tar.gz"],
48
- to_format="inchi",
49
- callback=archive_callback)
55
+ archive_callback = MCB(CheckFileStatus(),
56
+ CheckArchiveContents(l_filename_bases=["caffeine-no-flags",
57
+ "caffeine-ia",
58
+ "caffeine-ia-ox",
59
+ "caffeine-ia-okx",
60
+ "caffeine-ia-okx-oof4",
61
+ "caffeine-ia-okx-oof4l5",],
62
+ to_format="inchi"))
63
+
64
+ l_all_test_specs.append(Spec(name="Archive",
65
+ filename=["caffeine-smi.zip",
66
+ "caffeine-smi.tar",
67
+ "caffeine-smi.tar.gz"],
68
+ conversion_kwargs={"from_format": "smi"},
69
+ to_format="inchi",
70
+ callback=archive_callback,
71
+ ))
50
72
  """A test of converting a archives of files"""
51
73
 
52
- archive_wrong_format_test = ConversionTestSpec(filename="caffeine-smi.zip",
53
- to_format="inchi",
54
- conversion_kwargs=[{"from_format": "pdb"},
55
- {"from_format": "pdb", "strict": True}],
56
- expect_success=[True, False],
57
- callback=[CheckStderrContents(const.ERR_WRONG_EXTENSIONS),
58
- CheckException(ex_type=FileConverterInputException,
59
- ex_message=const.ERR_WRONG_EXTENSIONS)]
60
- )
74
+ l_all_test_specs.append(Spec(name="Archive (wrong format) - Library and CLA",
75
+ filename="caffeine-smi.zip",
76
+ to_format="inchi",
77
+ conversion_kwargs=[{"from_format": "pdb"},
78
+ {"from_format": "pdb", "strict": True}],
79
+ expect_success=[True, False],
80
+ callback=[CheckStderrContents(const.ERR_WRONG_EXTENSIONS),
81
+ CheckException(ex_type=FileConverterInputException,
82
+ ex_message=const.ERR_WRONG_EXTENSIONS)],
83
+ compatible_with_gui=False,
84
+ ))
61
85
  """A test that if the user provides the wrong input format for files in an archive, and error will be output to stderr
62
86
  """
63
87
 
64
- log_mode_tests = ConversionTestSpec(conversion_kwargs=[{"log_mode": const.LOG_NONE},
65
- {"log_mode": const.LOG_STDOUT},
66
- {"log_mode": const.LOG_SIMPLE},
67
- {"log_mode": const.LOG_FULL},
68
- {"log_mode": const.LOG_FULL_FORCE},],
69
- callback=[CheckFileStatus(expect_log_exists=False,
70
- expect_global_log_exists=False),
71
- CheckFileStatus(expect_log_exists=False,
72
- expect_global_log_exists=False),
73
- CheckFileStatus(expect_log_exists=True,
74
- expect_global_log_exists=False),
75
- CheckFileStatus(expect_log_exists=True,
76
- expect_global_log_exists=True),
77
- CheckFileStatus(expect_log_exists=True,
78
- expect_global_log_exists=True)],
79
- )
88
+ l_all_test_specs.append(Spec(name="Archive (wrong format) - GUI",
89
+ filename="caffeine-smi.zip",
90
+ to_format="inchi",
91
+ conversion_kwargs=[{"from_format": "pdb"},
92
+ {"from_format": "pdb", "strict": True}],
93
+ expect_success=[False, False],
94
+ callback=CheckException(ex_type=FileConverterInputException,
95
+ ex_message=const.ERR_WRONG_EXTENSIONS),
96
+ compatible_with_library=False,
97
+ compatible_with_cla=False,
98
+ ))
99
+ """A test that if the user provides the wrong input format for files in an archive - variant for the GUI test, which is
100
+ more strict
101
+ """
102
+
103
+
104
+ l_all_test_specs.append(Spec(name="Log mode",
105
+ conversion_kwargs=[{"log_mode": const.LOG_NONE},
106
+ {"log_mode": const.LOG_STDOUT},
107
+ {"log_mode": const.LOG_SIMPLE},
108
+ {"log_mode": const.LOG_FULL},
109
+ {"log_mode": const.LOG_FULL_FORCE},],
110
+ callback=[CheckFileStatus(expect_log_exists=False,
111
+ expect_global_log_exists=False),
112
+ CheckFileStatus(expect_log_exists=False,
113
+ expect_global_log_exists=False),
114
+ CheckFileStatus(expect_log_exists=True,
115
+ expect_global_log_exists=False),
116
+ CheckFileStatus(expect_log_exists=True,
117
+ expect_global_log_exists=True),
118
+ CheckFileStatus(expect_log_exists=True,
119
+ expect_global_log_exists=True)],
120
+ compatible_with_gui=False,
121
+ ))
80
122
  """Tests that the different log modes have the desired effects on logs
81
123
 
82
- NOTE: Not compatible with GUI tests, since the GUI requires the log mode to always be "Full"
124
+ Not compatible with GUI tests, since the GUI requires the log mode to always be "Full"
83
125
  """
84
126
 
85
- stdout_test = ConversionTestSpec(conversion_kwargs={"log_mode": const.LOG_STDOUT},
86
- callback=CheckStdoutContents(l_strings_to_exclude=["ERROR", "exception", "Exception"],
87
- l_regex_to_find=[r"File name:\s*nacl",
88
- const.DATETIME_RE_RAW]
89
- ))
127
+ l_all_test_specs.append(Spec(name="Stdout",
128
+ conversion_kwargs={"log_mode": const.LOG_STDOUT},
129
+ callback=CheckStdoutContents(l_strings_to_exclude=["ERROR", "exception",
130
+ "Exception"],
131
+ l_regex_to_find=[r"File name:\s*nacl",
132
+ const.DATETIME_RE_RAW]
133
+ ),
134
+ compatible_with_gui=False,
135
+ ))
90
136
  """Test that the log is output to stdout when requested
91
137
 
92
- NOTE: Not compatible with GUI tests, since the GUI requires the log mode to always be "Full"
138
+ Not compatible with GUI tests, since the GUI requires the log mode to always be "Full"
93
139
  """
94
140
 
95
- quiet_test = ConversionTestSpec(conversion_kwargs={"log_mode": const.LOG_NONE},
96
- callback=CheckStdoutContents(l_regex_to_exclude=r"."))
141
+ l_all_test_specs.append(Spec(name="Quiet",
142
+ conversion_kwargs={"log_mode": const.LOG_NONE},
143
+ callback=CheckStdoutContents(l_regex_to_exclude=r"."),
144
+ compatible_with_gui=False,
145
+ ))
97
146
  """Test that nothing is output to stdout when quiet mode is enabled
98
147
 
99
- NOTE: Not compatible with GUI tests, since the GUI doesn't support quiet mode
148
+ Not compatible with GUI tests, since the GUI doesn't support quiet mode
100
149
  """
101
150
 
102
- open_babel_warning_test = ConversionTestSpec(filename="1NE6.mmcif",
103
- to_format="pdb",
104
- callback=CheckLogContentsSuccess(["Open Babel Warning",
105
- "Failed to kekulize aromatic bonds",])
106
- )
151
+ l_all_test_specs.append(Spec(name="Open Babel Warning",
152
+ filename="1NE6.mmcif",
153
+ to_format="pdb",
154
+ callback=CheckLogContentsSuccess(["Open Babel Warning",
155
+ "Failed to kekulize aromatic bonds",])
156
+ ))
107
157
  """A test that confirms expected warnings form Open Babel are output and captured in the log"""
108
158
 
109
- invalid_converter_callback = MultiCallback(CheckFileStatus(expect_output_exists=False,
110
- expect_log_exists=False),
111
- CheckException(ex_type=FileConverterInputException,
112
- ex_message="Converter {} not recognized"))
113
- invalid_converter_test = ConversionTestSpec(name="INVALID",
114
- expect_success=False,
115
- callback=invalid_converter_callback)
116
- """A test that a proper error is returned if an invalid converter is requested"""
117
-
118
- quality_note_callback = CheckLogContentsSuccess(["WARNING",
119
- const.QUAL_NOTE_OUT_MISSING.format(const.QUAL_2D_LABEL),
120
- const.QUAL_NOTE_OUT_MISSING.format(const.QUAL_3D_LABEL),
121
- const.QUAL_NOTE_IN_MISSING.format(const.QUAL_CONN_LABEL)])
122
- quality_note_test = ConversionTestSpec(filename="quartz.xyz",
123
- to_format="inchi",
124
- callback=quality_note_callback)
159
+ invalid_converter_callback = MCB(CheckFileStatus(expect_output_exists=False,
160
+ expect_log_exists=False),
161
+ CheckException(ex_type=FileConverterInputException,
162
+ ex_message="Converter {} not recognized"))
163
+ l_all_test_specs.append(Spec(name="Invalid Converter",
164
+ converter_name="INVALID",
165
+ expect_success=False,
166
+ callback=invalid_converter_callback,
167
+ compatible_with_gui=False,
168
+ ))
169
+ """A test that a proper error is returned if an invalid converter is requested
170
+
171
+ Not compatible with GUI tests, since the GUI only offers valid converters to choose from
172
+ """
173
+
174
+ quartz_quality_note_callback = CheckLogContentsSuccess(["WARNING",
175
+ const.QUAL_NOTE_OUT_MISSING.format(const.QUAL_2D_LABEL),
176
+ const.QUAL_NOTE_OUT_MISSING.format(const.QUAL_3D_LABEL),
177
+ const.QUAL_NOTE_IN_MISSING.format(const.QUAL_CONN_LABEL)])
178
+ ethanol_quality_note_callback = CheckLogContentsSuccess(["WARNING",
179
+ "Potential data loss or extrapolation",
180
+ const.QUAL_NOTE_IN_MISSING.format(const.QUAL_CONN_LABEL)])
181
+ hemoglobin_quality_note_callback = CheckLogContentsSuccess(["WARNING",
182
+ "Potential data loss or extrapolation",
183
+ const.QUAL_NOTE_OUT_MISSING.format(const.QUAL_CONN_LABEL)])
184
+ l_all_test_specs.append(Spec(name="Quality note",
185
+ filename=["quartz.xyz", "ethanol.xyz", "hemoglobin.pdb"],
186
+ to_format=["inchi", "cml", "xyz"],
187
+ callback=[quartz_quality_note_callback,
188
+ ethanol_quality_note_callback,
189
+ hemoglobin_quality_note_callback],
190
+ ))
125
191
  """A test conversion which we expect to produce a warning for conversion quality issues, where the connections property
126
192
  isn't present in the input and has to be extrapolated, and the 2D and 3D coordinates properties aren't present in the
127
193
  output and will be lost"""
128
194
 
129
- cleanup_input_test = ConversionTestSpec(conversion_kwargs={"delete_input": True},
130
- callback=CheckFileStatus(expect_input_exists=False))
131
- """A test that the input file to a conversion is deleted when cleanup is requested"""
132
-
133
- cant_read_xyz_callback = MultiCallback(CheckFileStatus(expect_output_exists=False,
134
- expect_log_exists=None),
135
- CheckException(ex_type=FileConverterAbortException,
136
- ex_message="Problems reading an XYZ file"))
137
- invalid_conversion_callback = MultiCallback(CheckFileStatus(expect_output_exists=False,
138
- expect_log_exists=None),
139
- CheckException(ex_type=FileConverterHelpException,
140
- ex_message="is not supported"))
141
- wrong_type_callback = MultiCallback(CheckFileStatus(expect_output_exists=False,
142
- expect_log_exists=None),
143
- CheckException(ex_type=FileConverterAbortException,
144
- ex_message="not a valid {} file"))
145
- failed_conversion_test = ConversionTestSpec(filename=["quartz_err.xyz", "hemoglobin.pdb", "1NE6.mmcif"],
146
- to_format=["inchi", "pdb", "cif"],
147
- conversion_kwargs=[{}, {}, {"from_format": "pdb"}],
148
- expect_success=False,
149
- callback=[cant_read_xyz_callback, invalid_conversion_callback,
150
- wrong_type_callback])
151
- """A test that a conversion which fails due to an invalid input file will properly fail"""
152
-
153
- max_size_callback = MultiCallback(CheckFileStatus(expect_output_exists=False),
154
- CheckLogContents("Output file exceeds maximum size"),
155
- CheckException(ex_type=FileConverterSizeException,
156
- ex_message="exceeds maximum size",
157
- ex_status_code=const.STATUS_CODE_SIZE))
158
- max_size_test = ConversionTestSpec(filename=["1NE6.mmcif", "caffeine-smi.tar.gz"],
159
- to_format="pdb",
160
- conversion_kwargs=[{"max_file_size": 0.0001}, {"max_file_size": 0.0005}],
161
- expect_success=False,
162
- callback=max_size_callback)
195
+ l_all_test_specs.append(Spec(name="Cleanup input",
196
+ conversion_kwargs={"delete_input": True},
197
+ callback=CheckFileStatus(expect_input_exists=False),
198
+ compatible_with_gui=False,
199
+ ))
200
+ """A test that the input file to a conversion is deleted when cleanup is requested.
201
+
202
+ Not compatible with the GUI, since the GUI can't forcibly delete files uploaded from the user's computer
203
+ """
204
+
205
+ l_all_test_specs.append(Spec(name="Failed conversion - bad input file",
206
+ filename=["quartz_err.xyz", "cyclopropane_err.mol"],
207
+ to_format=["inchi", "xyz"],
208
+ expect_success=False,
209
+ converter_name=[CONVERTER_OB, CONVERTER_C2X],
210
+ callback=[MCB(CheckFileStatus(expect_output_exists=False,
211
+ expect_log_exists=None),
212
+ CheckException(ex_type=FileConverterAbortException,
213
+ ex_message="Problems reading an XYZ file")),
214
+ MCB(CheckFileStatus(expect_output_exists=False,
215
+ expect_log_exists=None),
216
+ CheckException(ex_type=FileConverterAbortException,
217
+ ex_message="Aborting: mol file contains no atoms"))],
218
+ ))
219
+ """A test that a conversion that fails due to an unreadable input file will properly fail"""
220
+
221
+ quartz_error_ob_callback = CheckLogContents(["ERROR",
222
+ "Problems reading an XYZ file: Could not read line #11, file error"])
223
+ l_all_test_specs.append(Spec(name="Errors in logs - Library and CLA",
224
+ filename="quartz_err.xyz",
225
+ to_format="inchi",
226
+ converter_name=CONVERTER_OB,
227
+ expect_success=False,
228
+ callback=quartz_error_ob_callback,
229
+ compatible_with_gui=False,
230
+ ))
231
+ """A test that when a conversion fails in the library or CLA, logs are still produced and contain the expected error
232
+ message"""
233
+
234
+ l_all_test_specs.append(Spec(name="Errors in logs - GUI",
235
+ filename="quartz_err.xyz",
236
+ to_format="inchi",
237
+ converter_name=CONVERTER_OB,
238
+ expect_success=False,
239
+ callback=CheckException(ex_type=FileConverterAbortException,
240
+ ex_message=("Problems reading an XYZ file: Could not read line "
241
+ "#11, file error")),
242
+ compatible_with_library=False,
243
+ compatible_with_cla=False,
244
+ ))
245
+ """A test that when a conversion fails in the GUI, the log message is output to the alert box"""
246
+
247
+ l_all_test_specs.append(Spec(name="Failed conversion - invalid conversion",
248
+ filename=["Fapatite.ins", "nacl.mol"],
249
+ to_format=["cml", "xyz"],
250
+ expect_success=False,
251
+ converter_name=[CONVERTER_OB, CONVERTER_ATO],
252
+ callback=MCB(CheckFileStatus(expect_output_exists=False,
253
+ expect_log_exists=None),
254
+ CheckException(ex_type=FileConverterHelpException,
255
+ ex_message="is not supported")),
256
+ compatible_with_gui=False,
257
+ ))
258
+ """A test that a conversion that fails due an unsupported conversion will properly fail.
259
+
260
+ Not compatible with the GUI, since the GUI only offers valid conversions.
261
+ """
262
+
263
+ l_all_test_specs.append(Spec(name="Blocked conversion - wrong input type",
264
+ filename="1NE6.mmcif",
265
+ to_format="cif",
266
+ conversion_kwargs={"from_format": "pdb", "strict": True},
267
+ expect_success=False,
268
+ callback=MCB(CheckFileStatus(expect_output_exists=False,
269
+ expect_log_exists=None),
270
+ CheckException(ex_type=FileConverterInputException,
271
+ ex_message=("The file extension is not {} or a zip or tar "
272
+ "archive extension"))),
273
+ compatible_with_library=False,
274
+ compatible_with_cla=False,
275
+ ))
276
+ """A test that a conversion which is blocked in the GUI"""
277
+
278
+ l_all_test_specs.append(Spec(name="Failed conversion - wrong input type",
279
+ filename="1NE6.mmcif",
280
+ to_format="cif",
281
+ conversion_kwargs={"from_format": "pdb", "strict": False},
282
+ expect_success=False,
283
+ callback=MCB(CheckFileStatus(expect_output_exists=False,
284
+ expect_log_exists=None),
285
+ CheckException(ex_type=FileConverterAbortException,
286
+ ex_message=("not a valid {} file"))),
287
+ ))
288
+ """A test that a conversion which fails due to the wrong input file type will properly fail"""
289
+
290
+ l_all_test_specs.append(Spec(name="Large files - Library and CLA",
291
+ filename=["ch3cl-esp.cub", "benzyne.molden", "periodic_dmol3.outmol",
292
+ "fullRhinovirus.pdb"],
293
+ to_format=["cdjson", "dmol", "mol", "cif"],
294
+ converter_name=[CONVERTER_OB, CONVERTER_OB, CONVERTER_OB, CONVERTER_C2X],
295
+ callback=CheckFileStatus(),
296
+ compatible_with_gui=False,
297
+ ))
298
+ """Test that the library and CLA can process large files properly"""
299
+
300
+ l_all_test_specs.append(Spec(name="Large files - GUI",
301
+ filename=["ch3cl-esp.cub", "benzyne.molden",
302
+ "periodic_dmol3.outmol", "fullRhinovirus.pdb"],
303
+ to_format=["cdjson", "dmol", "mol", "cif"],
304
+ converter_name=[CONVERTER_OB, CONVERTER_OB, CONVERTER_OB, CONVERTER_C2X],
305
+ expect_success=[False, False, False, True],
306
+ callback=[CheckException(ex_type=FileConverterInputException),
307
+ CheckException(ex_type=FileConverterInputException),
308
+ CheckException(ex_type=FileConverterInputException),
309
+ CheckFileStatus()],
310
+ compatible_with_library=False,
311
+ compatible_with_cla=False,
312
+ ))
313
+ """Test that the GUI will refuse to process large files with OB, but will with other converters"""
314
+
315
+ max_size_callback = MCB(CheckFileStatus(expect_output_exists=False),
316
+ CheckLogContents("file exceeds maximum size"),
317
+ CheckException(ex_type=FileConverterSizeException,
318
+ ex_message="exceeds maximum size",
319
+ ex_status_code=const.STATUS_CODE_SIZE))
320
+ l_all_test_specs.append(Spec(name="Max size exceeded",
321
+ filename=["1NE6.mmcif", "caffeine-smi.tar.gz"],
322
+ to_format="pdb",
323
+ conversion_kwargs=[{"max_file_size": 0.0001}, {"max_file_size": 0.0005}],
324
+ expect_success=False,
325
+ callback=max_size_callback,
326
+ compatible_with_cla=False,
327
+ compatible_with_gui=False,
328
+ ))
163
329
  """A set of test conversion that the maximum size constraint is properly applied. In the first test, the input file
164
330
  will be greater than the maximum size, and the test should fail as soon as it checks it. In the second test, the input
165
331
  archive is smaller than the maximum size, but the unpacked files in it are greater, so it should fail midway through.
166
332
 
167
- NOTE: Not compatible with CLA tests, since the CLA doesn't allow the imposition of a maximum size.
333
+ Not compatible with CLA tests, since the CLA doesn't allow the imposition of a maximum size.
334
+
335
+ Not compatible with GUI tests in current setup of test implementation, which doesn't let us set env vars to control
336
+ things like maximum size on a per-test basis. May be possible to set up in the future though
168
337
  """
169
338
 
170
339
 
171
- format_args_test = ConversionTestSpec(filename="caffeine.inchi",
172
- to_format="smi",
173
- conversion_kwargs=[{},
174
- {"data": {"from_flags": "a"}},
175
- {"data": {"from_flags": "a", "to_flags": "x"}},
176
- {"data": {"from_flags": "a", "to_flags": "kx"}},
177
- {"data": {"from_flags": "a", "to_flags": "kx",
178
- "to_options": "f4"}},
179
- {"data": {"from_flags": "a", "to_flags": "kx",
180
- "to_options": "f4 l5"}}
181
- ],
182
- callback=[MatchOutputFile("caffeine-no-flags.smi"),
183
- MatchOutputFile("caffeine-ia.smi"),
184
- MatchOutputFile("caffeine-ia-ox.smi"),
185
- MatchOutputFile("caffeine-ia-okx.smi"),
186
- MatchOutputFile("caffeine-ia-okx-oof4.smi"),
187
- MatchOutputFile("caffeine-ia-okx-oof4l5.smi")
188
- ]
189
- )
340
+ l_all_test_specs.append(Spec(name="Format args",
341
+ filename="caffeine.inchi",
342
+ to_format="smi",
343
+ conversion_kwargs=[{},
344
+ {"data": {"from_flags": "a"}},
345
+ {"data": {"from_flags": "a", "to_flags": "x"}},
346
+ {"data": {"from_flags": "a", "to_flags": "kx"}},
347
+ {"data": {"from_flags": "a", "to_flags": "kx",
348
+ "to_options": "f4"}},
349
+ {"data": {"from_flags": "a", "to_flags": "kx",
350
+ "to_options": "f4 l5"}}
351
+ ],
352
+ callback=[MatchOutputFile("caffeine.smi"),
353
+ MatchOutputFile("caffeine_a_in.smi"),
354
+ MatchOutputFile("caffeine_a_in_x_out.smi"),
355
+ MatchOutputFile("caffeine_a_in_kx_out.smi"),
356
+ MatchOutputFile("caffeine_a_in_kx_f4_out.smi"),
357
+ MatchOutputFile("caffeine_a_in_kx_f4_l5_out.smi")
358
+ ]
359
+ ))
190
360
  """A set of tests which checks that format args (for how to read from and write to specific file formats) are processed
191
361
  correctly, by matching tests using them to expected output files"""
192
362
 
193
363
 
194
- coord_gen_test = ConversionTestSpec(filename="caffeine.inchi",
195
- to_format="xyz",
196
- conversion_kwargs=[{},
197
- {"data": {COORD_GEN_KEY: "Gen2D",
198
- COORD_GEN_QUAL_KEY: "fastest"}},
199
- {"data": {COORD_GEN_KEY: "Gen3D",
200
- COORD_GEN_QUAL_KEY: "best"}}
201
- ],
202
- callback=[MatchOutputFile("caffeine.xyz"),
203
- MatchOutputFile("caffeine-2D-fastest.xyz"),
204
- MatchOutputFile("caffeine-3D-best.xyz"),
205
- ]
206
- )
364
+ l_all_test_specs.append(Spec(name="Coord gen",
365
+ filename="caffeine.inchi",
366
+ to_format="xyz",
367
+ conversion_kwargs=[{},
368
+ {"data": {COORD_GEN_KEY: "Gen2D",
369
+ COORD_GEN_QUAL_KEY: "fastest"}},
370
+ {"data": {COORD_GEN_KEY: "Gen3D",
371
+ COORD_GEN_QUAL_KEY: "best"}}
372
+ ],
373
+ callback=[MatchOutputFile("caffeine.xyz"),
374
+ MatchOutputFile("caffeine-2D-fastest.xyz"),
375
+ MatchOutputFile("caffeine-3D-best.xyz"),
376
+ ]
377
+ ))
207
378
  """A set of tests which checks that coordinate generation options are processed correctly, by matching tests using them
208
379
  to expected output files"""
380
+
381
+ l_library_test_specs = [x for x in l_all_test_specs if x.compatible_with_library and not x.skip_all]
382
+ """All test specs which are compatible with being run on the Python library"""
383
+
384
+ l_cla_test_specs = [x for x in l_all_test_specs if x.compatible_with_cla and not x.skip_all]
385
+ """All test specs which are compatible with being run on the command-line application"""
386
+
387
+ l_gui_test_specs = [x for x in l_all_test_specs if x.compatible_with_gui and not x.skip_all]
388
+ """All test specs which are compatible with being run on the GUI"""