Debian Codegraph @

src/Programs/tests/test_validate_cif2.py

raw symbols SCIP
1 import unittest
2 from optparse import Values
3
4 from validate_cif import execute_with_options
5
6 class TestPycifrwCIF2_0(unittest.TestCase):
7
8
9 def test_2212_stairlike_example(self):
10 '''
11 Function to test the 2212-stairlike-example.cif file. The cif file is CORRECT. The used dictionary imports
12 cif_core, cif_ms and cif_twin.
13
14 Command:
15
16 python3 validate_cif.py -d dics/DDLm -f cif_mag.dic ./cif_files/cif_2_0/2212-stairlike-example.cif
17 '''
18
19 args = ['./cif_files/cif_2_0/correct_cif/2212-stairlike-example.cif']
20 options = Values()
21
22 options.dirname = 'dics/DDLm'
23 options.dictnames = [
24 'cif_mag.dic'
25 ]
26 options.versions = None
27 options.iucr_names = None
28 options.store_flag = True
29 options.registry = 'file:cifdic.register'
30 options.use_html = False
31 options.dict_flag = False
32 options.verbose_import = False
33 options.verbose_validation = False
34
35 cc, report_str = execute_with_options(options, args)
36
37 valid_result, no_matches = cc
38
39 result = True
40
41 for block in valid_result.keys():
42 block_result = valid_result[block]
43
44 if not block_result[0]:
45 result = False
46
47 self.assertTrue(result)
48
49 def test_2212_cozn_example(self):
50 '''
51 Function to test the Cozn-example.cif file. The cif file is CORRECT. The used dictionary imports
52 cif_core, cif_ms and cif_twin.
53
54 Command:
55
56 python3 validate_cif.py -d dics/DDLm -f cif_mag.dic ./cif_files/cif_2_0/Cozn-example.cif
57 '''
58
59 args = ['./cif_files/cif_2_0/correct_cif/Cozn-example.cif']
60 options = Values()
61
62 options.dirname = 'dics/DDLm'
63 options.dictnames = [
64 'cif_mag.dic'
65 ]
66 options.versions = None
67 options.iucr_names = None
68 options.store_flag = True
69 options.registry = 'file:cifdic.register'
70 options.use_html = False
71 options.dict_flag = False
72 options.verbose_import = False
73 options.verbose_validation = False
74
75 cc, report_str = execute_with_options(options, args)
76
77 valid_result, no_matches = cc
78
79 result = True
80
81 for block in valid_result.keys():
82 block_result = valid_result[block]
83
84 if not block_result[0]:
85 result = False
86
87 self.assertTrue(result)
88
89 def test_hexabrtellurate_example(self):
90 '''
91 Function to test the hexabrtellurate_example.cif file. The cif file is CORRECT. The used dictionary imports
92 cif_core, cif_ms and cif_twin.
93
94 Command:
95
96 python3 validate_cif.py -d dics/DDLm -f cif_mag.dic ./cif_files/cif_2_0/hexabrtellurate_example.cif
97 '''
98
99 args = ['./cif_files/cif_2_0/correct_cif/hexabrtellurate-example.cif']
100 options = Values()
101
102 options.dirname = 'dics/DDLm'
103 options.dictnames = [
104 'cif_mag.dic'
105 ]
106 options.versions = None
107 options.iucr_names = None
108 options.store_flag = True
109 options.registry = 'file:cifdic.register'
110 options.use_html = False
111 options.dict_flag = False
112 options.verbose_import = False
113 options.verbose_validation = False
114
115 cc, report_str = execute_with_options(options, args)
116
117 valid_result, no_matches = cc
118
119 result = True
120
121 for block in valid_result.keys():
122 block_result = valid_result[block]
123
124 if not block_result[0]:
125 result = False
126
127 self.assertTrue(result)
128
129 def test_levyclaudite_example(self):
130 '''
131 Function to test the levyclaudite_example.cif file. The cif file is CORRECT. The used dictionary imports
132 cif_core, cif_ms and cif_twin.
133
134 Command:
135
136 python3 validate_cif.py -d dics/DDLm -f cif_mag.dic ./cif_files/cif_2_0/levyclaudite_example.cif
137 '''
138
139 args = ['./cif_files/cif_2_0/correct_cif/levyclaudite-example.cif']
140 options = Values()
141
142 options.dirname = 'dics/DDLm'
143 options.dictnames = [
144 'cif_mag.dic'
145 ]
146 options.versions = None
147 options.iucr_names = None
148 options.store_flag = True
149 options.registry = 'file:cifdic.register'
150 options.use_html = False
151 options.dict_flag = False
152 options.verbose_import = False
153 options.verbose_validation = False
154
155 cc, report_str = execute_with_options(options, args)
156
157 valid_result, no_matches = cc
158
159 result = True
160
161 for block in valid_result.keys():
162 block_result = valid_result[block]
163
164 if not block_result[0]:
165 result = False
166
167 self.assertTrue(result)
168
169 def test_lillianite_example(self):
170 '''
171 Function to test the lillianite_example.cif file. The cif file is INCORRECT. The used dictionary imports
172 cif_core, cif_ms and cif_twin.
173
174 Command:
175
176 python3 validate_cif.py -d dics/DDLm -f cif_mag.dic ./cif_files/cif_2_0/lillianite_example.cif
177 '''
178
179 args = ['./cif_files/cif_2_0/incorrect_cif/lillianite-example.cif']
180 options = Values()
181
182 options.dirname = 'dics/DDLm'
183 options.dictnames = [
184 'cif_mag.dic'
185 ]
186 options.versions = None
187 options.iucr_names = None
188 options.store_flag = True
189 options.registry = 'file:cifdic.register'
190 options.use_html = False
191 options.dict_flag = False
192 options.verbose_import = False
193 options.verbose_validation = False
194
195 cc, report_str = execute_with_options(options, args)
196
197 valid_result, no_matches = cc
198
199 result = True
200
201 for block in valid_result.keys():
202 block_result = valid_result[block]
203
204 if not block_result[0]:
205 result = False
206
207 self.assertFalse(result)
208
209 def test_nepheline_example(self):
210 '''
211 Function to test the nepheline_example.cif file. The cif file is INCORRECT. The used dictionary imports
212 cif_core, cif_ms and cif_twin.
213
214 Command:
215
216 python3 validate_cif.py -d dics/DDLm -f cif_mag.dic ./cif_files/cif_2_0/nepheline_example.cif
217 '''
218
219 args = ['./cif_files/cif_2_0/incorrect_cif/nepheline-example.cif']
220 options = Values()
221
222 options.dirname = 'dics/DDLm'
223 options.dictnames = [
224 'cif_mag.dic'
225 ]
226 options.versions = None
227 options.iucr_names = None
228 options.store_flag = True
229 options.registry = 'file:cifdic.register'
230 options.use_html = False
231 options.dict_flag = False
232 options.verbose_import = False
233 options.verbose_validation = False
234
235 cc, report_str = execute_with_options(options, args)
236
237 valid_result, no_matches = cc
238
239 result = True
240
241 for block in valid_result.keys():
242 block_result = valid_result[block]
243
244 if not block_result[0]:
245 result = False
246
247 self.assertFalse(result)
248
249
250 def test_non_harmonic_adp_example(self):
251 '''
252 Function to test the lillianite_example.cif file. The cif file is INCORRECT. The used dictionary imports
253 cif_core, cif_ms and cif_twin.
254
255 Command:
256
257 python3 validate_cif.py -d dics/DDLm -f cif_mag.dic ./cif_files/cif_2_0/Non-harmonic-ADP-example.cif
258 '''
259
260 args = ['./cif_files/cif_2_0/incorrect_cif/Non-harmonic-ADP-example.cif']
261 options = Values()
262
263 options.dirname = 'dics/DDLm'
264 options.dictnames = [
265 'cif_mag.dic'
266 ]
267 options.versions = None
268 options.iucr_names = None
269 options.store_flag = True
270 options.registry = 'file:cifdic.register'
271 options.use_html = False
272 options.dict_flag = False
273 options.verbose_import = False
274 options.verbose_validation = False
275
276 cc, report_str = execute_with_options(options, args)
277
278 valid_result, no_matches = cc
279
280 result = True
281
282 for block in valid_result.keys():
283 block_result = valid_result[block]
284
285 if not block_result[0]:
286 result = False
287
288 self.assertFalse(result)
289
290 def test_sulfone_example(self):
291 '''
292 Function to test the lillianite_example.cif file. The cif file is INCORRECT. The used dictionary imports
293 cif_core, cif_ms and cif_twin.
294
295 Command:
296
297 python3 validate_cif.py -d dics/DDLm -f cif_mag.dic ./cif_files/cif_2_0/sulfone-example.cif
298 '''
299
300 args = ['./cif_files/cif_2_0/incorrect_cif/sulfone-example.cif']
301 options = Values()
302
303 options.dirname = 'dics/DDLm'
304 options.dictnames = [
305 'cif_mag.dic'
306 ]
307 options.versions = None
308 options.iucr_names = None
309 options.store_flag = True
310 options.registry = 'file:cifdic.register'
311 options.use_html = False
312 options.dict_flag = False
313 options.verbose_import = False
314 options.verbose_validation = False
315
316 cc, report_str = execute_with_options(options, args)
317
318 valid_result, no_matches = cc
319
320 result = True
321
322 for block in valid_result.keys():
323 block_result = valid_result[block]
324
325 if not block_result[0]:
326 result = False
327
328 self.assertFalse(result)
329
330
331 if __name__ == "__main__":
332 unittest.main()