psdi-data-conversion 0.0.35__py3-none-any.whl → 0.0.36__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 (36) hide show
  1. psdi_data_conversion/app.py +23 -3
  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 +4 -1
  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 +5 -2
  29. psdi_data_conversion/templates/index.htm +4 -1
  30. psdi_data_conversion/testing/conversion_test_specs.py +240 -149
  31. psdi_data_conversion/testing/utils.py +22 -7
  32. {psdi_data_conversion-0.0.35.dist-info → psdi_data_conversion-0.0.36.dist-info}/METADATA +29 -6
  33. {psdi_data_conversion-0.0.35.dist-info → psdi_data_conversion-0.0.36.dist-info}/RECORD +36 -36
  34. {psdi_data_conversion-0.0.35.dist-info → psdi_data_conversion-0.0.36.dist-info}/WHEEL +0 -0
  35. {psdi_data_conversion-0.0.35.dist-info → psdi_data_conversion-0.0.36.dist-info}/entry_points.txt +0 -0
  36. {psdi_data_conversion-0.0.35.dist-info → psdi_data_conversion-0.0.36.dist-info}/licenses/LICENSE +0 -0
@@ -8,14 +8,13 @@
8
8
  import { commonConvertReady, convertFile, getExtCheck, splitArchiveExt, isArchiveExt } from "./convert_common.js"
9
9
 
10
10
  var token = "",
11
- max_file_size = 0,
12
11
  in_ext = "",
13
12
  out_ext = "",
14
13
  in_str = "",
15
14
  out_str = "";
16
15
 
17
16
  $(document).ready(function () {
18
- [token, max_file_size, in_str, in_ext, out_str, out_ext] = commonConvertReady("c2x");
17
+ [token, in_str, in_ext, out_str, out_ext] = commonConvertReady("c2x");
19
18
  $("#uploadButton").click(submitFile);
20
19
  });
21
20
 
@@ -5,6 +5,7 @@
5
5
  This is the JavaScript which makes the Format and Converter Selection gui work.
6
6
  */
7
7
 
8
+ import { disableDirtyForms, cleanDirtyForms, initDirtyForms, loadServiceMode, loadProductionMode } from "./common.js";
8
9
  import {
9
10
  getInputFormats, getOutputFormats, getOutputFormatsForInputFormat,
10
11
  getInputFormatsForOutputFormat, getConverters, getConverterByName, getLevelChemInfo
@@ -29,12 +30,16 @@ $(document).ready(function () {
29
30
 
30
31
  sessionStorage.setItem("token", token);
31
32
  sessionStorage.setItem("max_file_size", max_file_size);
33
+ sessionStorage.setItem("max_file_size_ob", max_file_size_ob);
32
34
  sessionStorage.setItem("service_mode", service_mode);
33
35
  sessionStorage.setItem("production_mode", production_mode);
34
36
  sessionStorage.setItem("in_str", "");
35
37
  sessionStorage.setItem("out_str", "");
36
38
  sessionStorage.setItem("success", "");
37
39
 
40
+ loadServiceMode();
41
+ loadProductionMode();
42
+
38
43
  $("#fromList").click(populateConversionSuccess);
39
44
  $("#toList").click(populateConversionSuccess);
40
45
  $("#searchTo").keyup(filterOptions);
@@ -43,6 +48,8 @@ $(document).ready(function () {
43
48
  $("#success").click(showConverterDetails);
44
49
  $("#resetButton").click(resetAll);
45
50
  $("#showButton").click(showQualityDetails);
51
+
52
+ initDirtyForms();
46
53
  });
47
54
 
48
55
  /**
@@ -512,6 +519,9 @@ function getFormat(str) {
512
519
 
513
520
  // Stores chosen formats and switches to the Conversion page
514
521
  function goToConversionPage(event) {
522
+
523
+ disableDirtyForms();
524
+
515
525
  var path = ``;
516
526
 
517
527
  if ($("#name").html() == "Open Babel") {
@@ -604,4 +614,6 @@ function resetAll() {
604
614
 
605
615
  // Populates the "Convert to" selection list
606
616
  getOutputFormats().then(formats => populateList(formats, "to"));
617
+
618
+ cleanDirtyForms();
607
619
  }
@@ -5,6 +5,7 @@
5
5
  This is the JavaScript which makes the report.htm gui work.
6
6
  */
7
7
 
8
+ import { disableDirtyForms, initDirtyForms } from "./common.js";
8
9
  import { getAllFormats, getConverters } from "./data.js";
9
10
 
10
11
  var token = "",
@@ -53,6 +54,8 @@ $(document).ready(function () {
53
54
  $("#resetButton").click(resetAll);
54
55
  $("#resetButton2").click(resetAll);
55
56
  $("#reportButton").click(submitUserInput);
57
+
58
+ initDirtyForms();
56
59
  });
57
60
 
58
61
  // Included in this file for convenience. When the 'Report' button is clicked, a user's missing conversion report
@@ -131,6 +134,7 @@ function hideConverterDetails() {
131
134
 
132
135
  // Submits user input
133
136
  function submitUserInput() {
137
+
134
138
  const from = $("#searchFrom").val(),
135
139
  to = $("#searchTo").val();
136
140
 
@@ -205,6 +209,8 @@ function hideOffer() { }
205
209
 
206
210
  // Submit feedback
207
211
  function submitFeedback(data) {
212
+ disableDirtyForms();
213
+
208
214
  $.post(`/feedback/`, {
209
215
  'token': token,
210
216
  'data': JSON.stringify(data)
@@ -146,12 +146,6 @@ select#dark-background option {
146
146
  display: none;
147
147
  }
148
148
 
149
- .footer__hline hr {
150
- border-top-style : none;
151
- border-bottom-style: inset;
152
- border-bottom-width: 1px;
153
- }
154
-
155
149
  /* Convert button and loading spinner */
156
150
  .convert-button-and-spinner {
157
151
  display : flex;
@@ -640,8 +640,11 @@ a svg {
640
640
  }
641
641
 
642
642
  .footer__hline hr {
643
- margin: 0.5rem 0;
644
- height: 2px;
643
+ margin : 0.5rem 0;
644
+ height : 2px;
645
+ border-top-style : none;
646
+ border-bottom-style: inset;
647
+ border-bottom-width: 1px;
645
648
  }
646
649
 
647
650
  .max-width-box .footer__col {
@@ -18,10 +18,13 @@
18
18
 
19
19
  <script src="https://code.jquery.com/jquery-3.7.1.js" integrity="sha256-eKhayi8LEQwp4NKxN+CfCh+3qOVUtJn3QNZ0TciWLP4="
20
20
  crossorigin="anonymous"></script>
21
+ <script src="https://cdn.jsdelivr.net/jquery.dirtyforms/2.0.0/jquery.dirtyforms.min.js"></script>
22
+
21
23
  {% for item in data %}
22
24
  <script>
23
25
  const token = "{{item.token}}";
24
26
  const max_file_size = "{{item.max_file_size}}";
27
+ const max_file_size_ob = "{{item.max_file_size_ob}}";
25
28
  const service_mode = "{{item.service_mode}}";
26
29
  const production_mode = "{{item.production_mode}}";
27
30
  document.documentElement.setAttribute("service-mode", service_mode);
@@ -52,7 +55,7 @@
52
55
  </div>
53
56
  </div>
54
57
 
55
- <form name="gui">
58
+ <form name="gui" class="gui">
56
59
  <div class="max-width-box">
57
60
  <p>Select 'from' and 'to' file formats in the 'Convert from/to' boxes, in either order. Typing where indicated
58
61
  filters the options (case insensitive); for example, typing 'can' or 'NON' reduces the number of options to one:
@@ -15,194 +15,285 @@ 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="Basic",
26
+ filename=["1NE6.mmcif", "standard_test.cdxml",
27
+ "hemoglobin.pdb", "aceticacid.mol", "nacl.cif",
28
+ "hemoglobin.pdb", "hemoglobin.pdb", "nacl.cif",
29
+ "hemoglobin.pdb", "hemoglobin.pdb", "nacl.cif",
30
+ "ethanol.xyz"],
31
+ to_format=["pdb", "inchi",
32
+ "cif", "mol2", "xyz",
33
+ "cif", "xyz", "xyz",
34
+ "cif", "xyz", "xyz",
35
+ "cml"],
36
+ converter_name=[CONVERTER_OB, CONVERTER_OB,
37
+ CONVERTER_OB, CONVERTER_OB, CONVERTER_OB,
38
+ CONVERTER_ATO, CONVERTER_ATO, CONVERTER_ATO,
39
+ CONVERTER_C2X, CONVERTER_C2X, CONVERTER_C2X,
40
+ CONVERTER_OB],
41
+ callback=MCB(CheckFileStatus(),
42
+ CheckLogContentsSuccess()),
43
+ ))
44
+ """A basic set of test conversions which we expect to succeed without issue, running conversions with each of the
35
45
  Open Babel, Atomsk, and c2x converters"""
36
46
 
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)
47
+ archive_callback = MCB(CheckFileStatus(),
48
+ CheckArchiveContents(l_filename_bases=["caffeine-no-flags",
49
+ "caffeine-ia",
50
+ "caffeine-ia-ox",
51
+ "caffeine-ia-okx",
52
+ "caffeine-ia-okx-oof4",
53
+ "caffeine-ia-okx-oof4l5",],
54
+ to_format="inchi"))
55
+
56
+ l_all_test_specs.append(Spec(name="Archive",
57
+ filename=["caffeine-smi.zip",
58
+ "caffeine-smi.tar",
59
+ "caffeine-smi.tar.gz"],
60
+ to_format="inchi",
61
+ callback=archive_callback,
62
+ ))
50
63
  """A test of converting a archives of files"""
51
64
 
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
- )
65
+ l_all_test_specs.append(Spec(name="Archive (wrong format)",
66
+ filename="caffeine-smi.zip",
67
+ to_format="inchi",
68
+ conversion_kwargs=[{"from_format": "pdb"},
69
+ {"from_format": "pdb", "strict": True}],
70
+ expect_success=[True, False],
71
+ callback=[CheckStderrContents(const.ERR_WRONG_EXTENSIONS),
72
+ CheckException(ex_type=FileConverterInputException,
73
+ ex_message=const.ERR_WRONG_EXTENSIONS)],
74
+ ))
61
75
  """A test that if the user provides the wrong input format for files in an archive, and error will be output to stderr
62
76
  """
63
77
 
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
- )
78
+ l_all_test_specs.append(Spec(name="Log mode",
79
+ conversion_kwargs=[{"log_mode": const.LOG_NONE},
80
+ {"log_mode": const.LOG_STDOUT},
81
+ {"log_mode": const.LOG_SIMPLE},
82
+ {"log_mode": const.LOG_FULL},
83
+ {"log_mode": const.LOG_FULL_FORCE},],
84
+ callback=[CheckFileStatus(expect_log_exists=False,
85
+ expect_global_log_exists=False),
86
+ CheckFileStatus(expect_log_exists=False,
87
+ expect_global_log_exists=False),
88
+ CheckFileStatus(expect_log_exists=True,
89
+ expect_global_log_exists=False),
90
+ CheckFileStatus(expect_log_exists=True,
91
+ expect_global_log_exists=True),
92
+ CheckFileStatus(expect_log_exists=True,
93
+ expect_global_log_exists=True)],
94
+ compatible_with_gui=False,
95
+ ))
80
96
  """Tests that the different log modes have the desired effects on logs
81
97
 
82
- NOTE: Not compatible with GUI tests, since the GUI requires the log mode to always be "Full"
98
+ Not compatible with GUI tests, since the GUI requires the log mode to always be "Full"
83
99
  """
84
100
 
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
- ))
101
+ l_all_test_specs.append(Spec(name="Stdout",
102
+ conversion_kwargs={"log_mode": const.LOG_STDOUT},
103
+ callback=CheckStdoutContents(l_strings_to_exclude=["ERROR", "exception",
104
+ "Exception"],
105
+ l_regex_to_find=[r"File name:\s*nacl",
106
+ const.DATETIME_RE_RAW]
107
+ ),
108
+ compatible_with_gui=False,
109
+ ))
90
110
  """Test that the log is output to stdout when requested
91
111
 
92
- NOTE: Not compatible with GUI tests, since the GUI requires the log mode to always be "Full"
112
+ Not compatible with GUI tests, since the GUI requires the log mode to always be "Full"
93
113
  """
94
114
 
95
- quiet_test = ConversionTestSpec(conversion_kwargs={"log_mode": const.LOG_NONE},
96
- callback=CheckStdoutContents(l_regex_to_exclude=r"."))
115
+ l_all_test_specs.append(Spec(name="Quiet",
116
+ conversion_kwargs={"log_mode": const.LOG_NONE},
117
+ callback=CheckStdoutContents(l_regex_to_exclude=r"."),
118
+ compatible_with_gui=False,
119
+ ))
97
120
  """Test that nothing is output to stdout when quiet mode is enabled
98
121
 
99
- NOTE: Not compatible with GUI tests, since the GUI doesn't support quiet mode
122
+ Not compatible with GUI tests, since the GUI doesn't support quiet mode
100
123
  """
101
124
 
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
- )
125
+ l_all_test_specs.append(Spec(name="Open Babel Warning",
126
+ filename="1NE6.mmcif",
127
+ to_format="pdb",
128
+ callback=CheckLogContentsSuccess(["Open Babel Warning",
129
+ "Failed to kekulize aromatic bonds",])
130
+ ))
107
131
  """A test that confirms expected warnings form Open Babel are output and captured in the log"""
108
132
 
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)
133
+ invalid_converter_callback = MCB(CheckFileStatus(expect_output_exists=False,
134
+ expect_log_exists=False),
135
+ CheckException(ex_type=FileConverterInputException,
136
+ ex_message="Converter {} not recognized"))
137
+ l_all_test_specs.append(Spec(name="Invalid Converter",
138
+ converter_name="INVALID",
139
+ expect_success=False,
140
+ callback=invalid_converter_callback,
141
+ ))
116
142
  """A test that a proper error is returned if an invalid converter is requested"""
117
143
 
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)
144
+ quartz_quality_note_callback = CheckLogContentsSuccess(["WARNING",
145
+ const.QUAL_NOTE_OUT_MISSING.format(const.QUAL_2D_LABEL),
146
+ const.QUAL_NOTE_OUT_MISSING.format(const.QUAL_3D_LABEL),
147
+ const.QUAL_NOTE_IN_MISSING.format(const.QUAL_CONN_LABEL)])
148
+ ethanol_quality_note_callback = CheckLogContentsSuccess(["WARNING",
149
+ "Potential data loss or extrapolation",
150
+ const.QUAL_NOTE_IN_MISSING.format(const.QUAL_CONN_LABEL)])
151
+ hemoglobin_quality_note_callback = CheckLogContentsSuccess(["WARNING",
152
+ "Potential data loss or extrapolation",
153
+ const.QUAL_NOTE_OUT_MISSING.format(const.QUAL_CONN_LABEL)])
154
+ l_all_test_specs.append(Spec(name="Quality note",
155
+ filename=["quartz.xyz", "ethanol.xyz", "hemoglobin.pdb"],
156
+ to_format=["inchi", "cml", "xyz"],
157
+ callback=[quartz_quality_note_callback,
158
+ ethanol_quality_note_callback,
159
+ hemoglobin_quality_note_callback],
160
+ ))
125
161
  """A test conversion which we expect to produce a warning for conversion quality issues, where the connections property
126
162
  isn't present in the input and has to be extrapolated, and the 2D and 3D coordinates properties aren't present in the
127
163
  output and will be lost"""
128
164
 
129
- cleanup_input_test = ConversionTestSpec(conversion_kwargs={"delete_input": True},
130
- callback=CheckFileStatus(expect_input_exists=False))
165
+ l_all_test_specs.append(Spec(name="Cleanup input",
166
+ conversion_kwargs={"delete_input": True},
167
+ callback=CheckFileStatus(expect_input_exists=False),
168
+ ))
131
169
  """A test that the input file to a conversion is deleted when cleanup is requested"""
132
170
 
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)
171
+ l_all_test_specs.append(Spec(name="Failed conversion - bad input file",
172
+ filename=["quartz_err.xyz", "cyclopropane_err.mol"],
173
+ to_format=["inchi", "xyz"],
174
+ expect_success=False,
175
+ converter_name=[CONVERTER_OB, CONVERTER_C2X],
176
+ callback=[MCB(CheckFileStatus(expect_output_exists=False,
177
+ expect_log_exists=None),
178
+ CheckException(ex_type=FileConverterAbortException,
179
+ ex_message="Problems reading an XYZ file")),
180
+ MCB(CheckFileStatus(expect_output_exists=False,
181
+ expect_log_exists=None),
182
+ CheckException(ex_type=FileConverterAbortException,
183
+ ex_message="Aborting: mol file contains no atoms"))],
184
+ ))
185
+ """A test that a conversion that fails due to an unreadable input file will properly fail"""
186
+
187
+ quartz_error_ob_callback = CheckLogContents(["ERROR",
188
+ "Problems reading an XYZ file: Could not read line #11, file error"])
189
+ l_all_test_specs.append(Spec(name="Errors in logs",
190
+ filename="quartz_err.xyz",
191
+ to_format="inchi",
192
+ converter_name=CONVERTER_OB,
193
+ expect_success=False,
194
+ callback=quartz_error_ob_callback,
195
+ ))
196
+ """A test that when a conversion fails, logs are still produced and contain the expected error message"""
197
+
198
+ l_all_test_specs.append(Spec(name="Failed conversion - invalid conversion",
199
+ filename=["Fapatite.ins", "nacl.mol"],
200
+ to_format=["cml", "xyz"],
201
+ expect_success=False,
202
+ converter_name=[CONVERTER_OB, CONVERTER_ATO],
203
+ callback=MCB(CheckFileStatus(expect_output_exists=False,
204
+ expect_log_exists=None),
205
+ CheckException(ex_type=FileConverterHelpException,
206
+ ex_message="is not supported")),
207
+ ))
208
+ """A test that a conversion that fails due an unsupported conversion will properly fail"""
209
+
210
+ l_all_test_specs.append(Spec(name="Failed Conversion - wrong input type",
211
+ filename="1NE6.mmcif",
212
+ to_format="cif",
213
+ conversion_kwargs={"from_format": "pdb"},
214
+ expect_success=False,
215
+ callback=MCB(CheckFileStatus(expect_output_exists=False,
216
+ expect_log_exists=None),
217
+ CheckException(ex_type=FileConverterAbortException,
218
+ ex_message="not a valid {} file")),
219
+ ))
220
+ """A test that a conversion which fails due to the wrong input file type will properly fail"""
221
+
222
+ l_all_test_specs.append(Spec(name="Large files",
223
+ filename=["ch3cl-esp.cub", "benzyne.molden", "periodic_dmol3.outmol",
224
+ "fullRhinovirus.pdb"],
225
+ to_format=["cdjson", "dmol", "mol", "cif"],
226
+ converter_name=[CONVERTER_OB, CONVERTER_OB, CONVERTER_OB, CONVERTER_C2X],
227
+ callback=CheckFileStatus(),
228
+ ))
229
+
230
+ max_size_callback = MCB(CheckFileStatus(expect_output_exists=False),
231
+ CheckLogContents("file exceeds maximum size"),
232
+ CheckException(ex_type=FileConverterSizeException,
233
+ ex_message="exceeds maximum size",
234
+ ex_status_code=const.STATUS_CODE_SIZE))
235
+ l_all_test_specs.append(Spec(name="Max size exceeded",
236
+ filename=["1NE6.mmcif", "caffeine-smi.tar.gz"],
237
+ to_format="pdb",
238
+ conversion_kwargs=[{"max_file_size": 0.0001}, {"max_file_size": 0.0005}],
239
+ expect_success=False,
240
+ callback=max_size_callback,
241
+ compatible_with_cla=False,
242
+ ))
163
243
  """A set of test conversion that the maximum size constraint is properly applied. In the first test, the input file
164
244
  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
245
  archive is smaller than the maximum size, but the unpacked files in it are greater, so it should fail midway through.
166
246
 
167
- NOTE: Not compatible with CLA tests, since the CLA doesn't allow the imposition of a maximum size.
247
+ Not compatible with CLA tests, since the CLA doesn't allow the imposition of a maximum size.
168
248
  """
169
249
 
170
250
 
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
- )
251
+ l_all_test_specs.append(Spec(name="Format args",
252
+ filename="caffeine.inchi",
253
+ to_format="smi",
254
+ conversion_kwargs=[{},
255
+ {"data": {"from_flags": "a"}},
256
+ {"data": {"from_flags": "a", "to_flags": "x"}},
257
+ {"data": {"from_flags": "a", "to_flags": "kx"}},
258
+ {"data": {"from_flags": "a", "to_flags": "kx",
259
+ "to_options": "f4"}},
260
+ {"data": {"from_flags": "a", "to_flags": "kx",
261
+ "to_options": "f4 l5"}}
262
+ ],
263
+ callback=[MatchOutputFile("caffeine.smi"),
264
+ MatchOutputFile("caffeine_a_in.smi"),
265
+ MatchOutputFile("caffeine_a_in_x_out.smi"),
266
+ MatchOutputFile("caffeine_a_in_kx_out.smi"),
267
+ MatchOutputFile("caffeine_a_in_kx_f4_out.smi"),
268
+ MatchOutputFile("caffeine_a_in_kx_f4_l5_out.smi")
269
+ ]
270
+ ))
190
271
  """A set of tests which checks that format args (for how to read from and write to specific file formats) are processed
191
272
  correctly, by matching tests using them to expected output files"""
192
273
 
193
274
 
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
- )
275
+ l_all_test_specs.append(Spec(name="Coord gen",
276
+ filename="caffeine.inchi",
277
+ to_format="xyz",
278
+ conversion_kwargs=[{},
279
+ {"data": {COORD_GEN_KEY: "Gen2D",
280
+ COORD_GEN_QUAL_KEY: "fastest"}},
281
+ {"data": {COORD_GEN_KEY: "Gen3D",
282
+ COORD_GEN_QUAL_KEY: "best"}}
283
+ ],
284
+ callback=[MatchOutputFile("caffeine.xyz"),
285
+ MatchOutputFile("caffeine-2D-fastest.xyz"),
286
+ MatchOutputFile("caffeine-3D-best.xyz"),
287
+ ]
288
+ ))
207
289
  """A set of tests which checks that coordinate generation options are processed correctly, by matching tests using them
208
290
  to expected output files"""
291
+
292
+ l_library_test_specs = [x for x in l_all_test_specs if x.compatible_with_library]
293
+ """All test specs which are compatible with being run on the Python library"""
294
+
295
+ l_cla_test_specs = [x for x in l_all_test_specs if x.compatible_with_cla]
296
+ """All test specs which are compatible with being run on the command-line application"""
297
+
298
+ l_gui_test_specs = [x for x in l_all_test_specs if x.compatible_with_gui]
299
+ """All test specs which are compatible with being run on the GUI"""