| 1 |
import unittest |
| 2 |
from optparse import Values |
| 3 |
|
| 4 |
from validate_cif import execute_with_options |
| 5 |
|
| 6 |
''' |
| 7 |
Input is given in the following format. |
| 8 |
|
| 9 |
Args: |
| 10 |
['./cif_files/992E7Z7oL.cif'] |
| 11 |
|
| 12 |
Options: |
| 13 |
{'dirname': 'dic_files', 'dictnames': ['cif_core_2.4.5.dic', 'cif_ms_1.0.1.dic'], |
| 14 |
'versions': None, 'iucr_names': None, 'store_flag': True, 'registry': 'file:cifdic.register', |
| 15 |
'use_html': False, 'dict_flag': False} |
| 16 |
|
| 17 |
NOTE: |
| 18 |
ALL THE FUNCTIONS MUST START WITH test_* |
| 19 |
''' |
| 20 |
|
| 21 |
class TestPycifrwCIF1_0(unittest.TestCase): |
| 22 |
|
| 23 |
def test_992E7Z7oL(self): |
| 24 |
''' |
| 25 |
Function to test the basic .cif file. The cif file is CORRECT. |
| 26 |
|
| 27 |
Command: |
| 28 |
|
| 29 |
python3 validate_cif.py -d dics/DDL1 -f cif_core_2.4.5.dic -f cif_ms_1.0.1.dic -f cif_iucr.dic |
| 30 |
-f cif_pd-mod.dic -f cif_third_party-mod.dic -f cif_twinning.dic -f jana-mod.dic |
| 31 |
./cif_files/cif_1_0/correct_cif/992E7Z7oL.cif |
| 32 |
''' |
| 33 |
|
| 34 |
args = ['./cif_files/cif_1_0/correct_cif/992E7Z7oL.cif'] |
| 35 |
options = Values() |
| 36 |
|
| 37 |
options.dirname = 'dics/DDL1' |
| 38 |
options.dictnames = [ |
| 39 |
'cif_core_2.4.5.dic', |
| 40 |
'cif_ms_1.0.1.dic', |
| 41 |
'cif_iucr.dic', |
| 42 |
'cif_pd-mod.dic', |
| 43 |
'cif_third_party-mod.dic', |
| 44 |
'cif_twinning.dic', |
| 45 |
'jana-mod.dic' |
| 46 |
] |
| 47 |
options.versions = None |
| 48 |
options.iucr_names = None |
| 49 |
options.store_flag = True |
| 50 |
options.registry = 'file:cifdic.register' |
| 51 |
options.use_html = False |
| 52 |
options.dict_flag = False |
| 53 |
options.verbose_import = False |
| 54 |
options.verbose_validation = False |
| 55 |
|
| 56 |
cc, report_str = execute_with_options(options, args) |
| 57 |
|
| 58 |
valid_result, no_matches = cc |
| 59 |
|
| 60 |
result = True |
| 61 |
|
| 62 |
for block in valid_result.keys(): |
| 63 |
block_result = valid_result[block] |
| 64 |
|
| 65 |
if not block_result[0]: |
| 66 |
result = False |
| 67 |
|
| 68 |
self.assertTrue(result) |
| 69 |
|
| 70 |
def test_Fxhs6DE1VaT(self): |
| 71 |
''' |
| 72 |
Function to test the Fxhs6DE1VaT. The cif file is CORRECT. |
| 73 |
|
| 74 |
Command: |
| 75 |
|
| 76 |
python3 validate_cif.py -d dics/DDL1 -f cif_core_2.4.5.dic -f cif_ms_1.0.1.dic -f cif_iucr.dic |
| 77 |
-f cif_pd-mod.dic -f cif_third_party-mod.dic -f cif_twinning.dic -f jana-mod.dic |
| 78 |
./cif_files/cif_1_0/correct_cif/Fxhs6DE1Vat.cif |
| 79 |
''' |
| 80 |
|
| 81 |
args = ['./cif_files/cif_1_0/correct_cif/Fxhs6DE1VaT.cif'] |
| 82 |
|
| 83 |
options = Values() |
| 84 |
|
| 85 |
options.dirname = 'dics/DDL1' |
| 86 |
options.dictnames = [ |
| 87 |
'cif_core_2.4.5.dic', |
| 88 |
'cif_ms_1.0.1.dic', |
| 89 |
'cif_iucr.dic', |
| 90 |
'cif_pd-mod.dic', |
| 91 |
'cif_third_party-mod.dic', |
| 92 |
'cif_twinning.dic', |
| 93 |
'jana-mod.dic' |
| 94 |
] |
| 95 |
options.versions = None |
| 96 |
options.iucr_names = None |
| 97 |
options.store_flag = True |
| 98 |
options.registry = 'file:cifdic.register' |
| 99 |
options.use_html = False |
| 100 |
options.dict_flag = False |
| 101 |
options.verbose_import = False |
| 102 |
options.verbose_validation = False |
| 103 |
|
| 104 |
cc, report_str = execute_with_options(options, args) |
| 105 |
|
| 106 |
valid_result, no_matches = cc |
| 107 |
|
| 108 |
result = True |
| 109 |
|
| 110 |
for block in valid_result.keys(): |
| 111 |
block_result = valid_result[block] |
| 112 |
|
| 113 |
if not block_result[0]: |
| 114 |
result = False |
| 115 |
|
| 116 |
self.assertTrue(result) |
| 117 |
|
| 118 |
def test_z034DL74QTM(self): |
| 119 |
''' |
| 120 |
Function to test the z034DL74QTM. The cif file is CORRECT. |
| 121 |
|
| 122 |
Command: |
| 123 |
|
| 124 |
python3 validate_cif.py -d dics/DDL1 -f cif_core_2.4.5.dic -f cif_ms_1.0.1.dic -f cif_iucr.dic |
| 125 |
-f cif_pd-mod.dic -f cif_third_party-mod.dic -f cif_twinning.dic -f jana-mod.dic |
| 126 |
./cif_files/cif_1_0/correct_cif/z034DL74QTM.cif |
| 127 |
''' |
| 128 |
|
| 129 |
args = ['./cif_files/cif_1_0/correct_cif/z034DL74QTM.cif'] |
| 130 |
|
| 131 |
options = Values() |
| 132 |
|
| 133 |
options.dirname = 'dics/DDL1' |
| 134 |
options.dictnames = [ |
| 135 |
'cif_core_2.4.5.dic', |
| 136 |
'cif_ms_1.0.1.dic', |
| 137 |
'cif_iucr.dic', |
| 138 |
'cif_pd-mod.dic', |
| 139 |
'cif_third_party-mod.dic', |
| 140 |
'cif_twinning.dic', |
| 141 |
'jana-mod.dic' |
| 142 |
] |
| 143 |
options.iucr_names = None |
| 144 |
options.store_flag = True |
| 145 |
options.registry = 'file:cifdic.register' |
| 146 |
options.use_html = False |
| 147 |
options.dict_flag = False |
| 148 |
options.verbose_import = False |
| 149 |
options.verbose_validation = False |
| 150 |
|
| 151 |
cc, report_str = execute_with_options(options, args) |
| 152 |
|
| 153 |
valid_result, no_matches = cc |
| 154 |
|
| 155 |
result = True |
| 156 |
|
| 157 |
for block in valid_result.keys(): |
| 158 |
block_result = valid_result[block] |
| 159 |
|
| 160 |
if not block_result[0]: |
| 161 |
result = False |
| 162 |
|
| 163 |
self.assertTrue(result) |
| 164 |
|
| 165 |
def test_992E7Z7oL_full(self): |
| 166 |
''' |
| 167 |
Function to test the 992E7Z7oL.cif.full file. The cif file is INCORRECT. |
| 168 |
|
| 169 |
Command: |
| 170 |
|
| 171 |
python3 validate_cif.py -d dics/DDL1 -f cif_core_2.4.5.dic -f cif_ms_1.0.1.dic -f cif_iucr.dic |
| 172 |
-f cif_pd-mod.dic -f cif_third_party-mod.dic -f cif_twinning.dic -f jana-mod.dic |
| 173 |
./cif_files/cif_1_0/incorrect_cif/992E7Z7oL.cif.full |
| 174 |
''' |
| 175 |
|
| 176 |
args = ['./cif_files/cif_1_0/incorrect_cif/992E7Z7oL.cif.full'] |
| 177 |
|
| 178 |
options = Values() |
| 179 |
|
| 180 |
options.dirname = 'dics/DDL1' |
| 181 |
options.dictnames = [ |
| 182 |
'cif_core_2.4.5.dic', |
| 183 |
'cif_ms_1.0.1.dic', |
| 184 |
'cif_iucr.dic', |
| 185 |
'cif_pd-mod.dic', |
| 186 |
'cif_third_party-mod.dic', |
| 187 |
'cif_twinning.dic', |
| 188 |
'jana-mod.dic' |
| 189 |
] |
| 190 |
options.versions = None |
| 191 |
options.iucr_names = None |
| 192 |
options.store_flag = True |
| 193 |
options.registry = 'file:cifdic.register' |
| 194 |
options.use_html = False |
| 195 |
options.dict_flag = False |
| 196 |
options.verbose_import = False |
| 197 |
options.verbose_validation = False |
| 198 |
|
| 199 |
cc, report_str = execute_with_options(options, args) |
| 200 |
|
| 201 |
valid_result, no_matches = cc |
| 202 |
|
| 203 |
result = True |
| 204 |
|
| 205 |
for block in valid_result.keys(): |
| 206 |
block_result = valid_result[block] |
| 207 |
|
| 208 |
if not block_result[0]: |
| 209 |
result = False |
| 210 |
|
| 211 |
|
| 212 |
self.assertFalse(result) |
| 213 |
|
| 214 |
def test_a7JwDmTmunB(self): |
| 215 |
''' |
| 216 |
Function to test the a7JwDmTmunB.cif file. The cif file is INCORRECT. |
| 217 |
|
| 218 |
Command: |
| 219 |
|
| 220 |
python3 validate_cif.py -d dics/DDL1 -f cif_core_2.4.5.dic -f cif_ms_1.0.1.dic -f cif_iucr.dic |
| 221 |
-f cif_pd-mod.dic -f cif_third_party-mod.dic -f cif_twinning.dic -f jana-mod.dic |
| 222 |
./cif_files/cif_1_0/incorrect_cif/a7JwDmTmunB.cif |
| 223 |
''' |
| 224 |
|
| 225 |
args = ['./cif_files/cif_1_0/incorrect_cif/a7JwDmTmunB.cif'] |
| 226 |
options = Values() |
| 227 |
|
| 228 |
options.dirname = 'dics/DDL1' |
| 229 |
options.dictnames = [ |
| 230 |
'cif_core_2.4.5.dic', |
| 231 |
'cif_ms_1.0.1.dic', |
| 232 |
'cif_iucr.dic', |
| 233 |
'cif_pd-mod.dic', |
| 234 |
'cif_third_party-mod.dic', |
| 235 |
'cif_twinning.dic', |
| 236 |
'jana-mod.dic' |
| 237 |
] |
| 238 |
options.versions = None |
| 239 |
options.iucr_names = None |
| 240 |
options.store_flag = True |
| 241 |
options.registry = 'file:cifdic.register' |
| 242 |
options.use_html = False |
| 243 |
options.dict_flag = False |
| 244 |
options.verbose_import = False |
| 245 |
options.verbose_validation = False |
| 246 |
|
| 247 |
cc, report_str = execute_with_options(options, args) |
| 248 |
|
| 249 |
valid_result, no_matches = cc |
| 250 |
|
| 251 |
result = True |
| 252 |
|
| 253 |
for block in valid_result.keys(): |
| 254 |
block_result = valid_result[block] |
| 255 |
|
| 256 |
if not block_result[0]: |
| 257 |
result = False |
| 258 |
|
| 259 |
|
| 260 |
self.assertFalse(result) |
| 261 |
|
| 262 |
def test_ferro_embedded(self): |
| 263 |
''' |
| 264 |
Function to test the ferro_embedded.cif file. The cif file is INCORRECT. |
| 265 |
|
| 266 |
Command: |
| 267 |
|
| 268 |
python3 validate_cif.py -d dics/DDL1 -f cif_core_2.4.5.dic -f cif_ms_1.0.1.dic -f cif_iucr.dic |
| 269 |
-f cif_pd-mod.dic -f cif_third_party-mod.dic -f cif_twinning.dic -f jana-mod.dic |
| 270 |
./cif_files/cif_1_0/incorrect_cif/ferro_embedded.cif |
| 271 |
''' |
| 272 |
|
| 273 |
args = ['./cif_files/cif_1_0/incorrect_cif/ferro_embedded.cif'] |
| 274 |
options = Values() |
| 275 |
|
| 276 |
options.dirname = 'dics/DDL1' |
| 277 |
options.dictnames = [ |
| 278 |
'cif_core_2.4.5.dic', |
| 279 |
'cif_ms_1.0.1.dic', |
| 280 |
'cif_iucr.dic', |
| 281 |
'cif_pd-mod.dic', |
| 282 |
'cif_third_party-mod.dic', |
| 283 |
'cif_twinning.dic', |
| 284 |
'jana-mod.dic' |
| 285 |
] |
| 286 |
options.versions = None |
| 287 |
options.iucr_names = None |
| 288 |
options.store_flag = True |
| 289 |
options.registry = 'file:cifdic.register' |
| 290 |
options.use_html = False |
| 291 |
options.dict_flag = False |
| 292 |
options.verbose_import = False |
| 293 |
options.verbose_validation = False |
| 294 |
|
| 295 |
cc, report_str = execute_with_options(options, args) |
| 296 |
|
| 297 |
valid_result, no_matches = cc |
| 298 |
|
| 299 |
result = True |
| 300 |
|
| 301 |
for block in valid_result.keys(): |
| 302 |
block_result = valid_result[block] |
| 303 |
|
| 304 |
if not block_result[0]: |
| 305 |
result = False |
| 306 |
|
| 307 |
|
| 308 |
self.assertFalse(result) |
| 309 |
|
| 310 |
|
| 311 |
if __name__ == "__main__": |
| 312 |
unittest.main() |