8
8
9
9
from hikari .dataframes import BaseFrame , CifBlock , CifFrame , HklFrame , \
10
10
UBaseFrame
11
- from hikari .resources import nacl_fcf , nacl_hkl , nacl_cif , cif_core_dict
11
+ from hikari .dataframes . cif import CifValidator
12
12
from hikari .symmetry import PG
13
13
14
14
rad60 = 1.0471975511965976
@@ -37,10 +37,9 @@ def __init__(self, name, content):
37
37
self .file .write (content )
38
38
39
39
40
- nacl_cif_file = TempFile ('nacl.cif' , nacl_cif )
41
- nacl_fcf_file = TempFile ('nacl.fcf' , nacl_fcf )
42
- nacl_hkl_file = TempFile ('nacl.hkl' , nacl_hkl )
43
- cif_core_dict_file = TempFile ('core.cif' , cif_core_dict )
40
+ nacl_cif_path = str (pathlib .Path (__file__ ).parent .joinpath ('NaCl.cif' ))
41
+ nacl_fcf_path = str (pathlib .Path (__file__ ).parent .joinpath ('NaCl.fcf' ))
42
+ nacl_hkl_path = str (pathlib .Path (__file__ ).parent .joinpath ('NaCl.hkl' ))
44
43
45
44
46
45
class TestBaseFrame (unittest .TestCase ):
@@ -115,7 +114,7 @@ def test_volumes(self):
115
114
116
115
class TestCifBlockRead (unittest .TestCase ):
117
116
def test_read (self ):
118
- CifBlock ().read (path = nacl_cif_file . path , block = 'NaCl' )
117
+ CifBlock ().read (path = nacl_cif_path , block = 'NaCl' )
119
118
120
119
121
120
class TestCifBlockGeneral (unittest .TestCase ):
@@ -124,7 +123,7 @@ class TestCifBlockGeneral(unittest.TestCase):
124
123
@classmethod
125
124
def setUpClass (cls ) -> None :
126
125
super ().setUpClass ()
127
- cls .b .read (path = nacl_cif_file . path , block = 'NaCl' )
126
+ cls .b .read (path = nacl_cif_path , block = 'NaCl' )
128
127
129
128
def test_access (self ):
130
129
self .assertIn ('_cell_length_a' , self .b )
@@ -167,36 +166,37 @@ class TestCifBlockInterface(unittest.TestCase):
167
166
b = CifBlock ()
168
167
169
168
def test_base_frame_fill_from_cif_block_robust (self ):
170
- self .b .read (path = nacl_cif_file . path , block = 'NaCl' )
169
+ self .b .read (path = nacl_cif_path , block = 'NaCl' )
171
170
base = BaseFrame ()
172
171
base .fill_from_cif_block (self .b , fragile = False )
173
172
self .assertAlmostEqual (base .v_d , 179.51018149594705 )
174
173
self .assertAlmostEqual (base .orientation [0 , 0 ], - 0.0617076000 )
175
174
176
175
def test_base_frame_fill_from_cif_block_fragile (self ):
177
- self .b .read (path = nacl_cif_file . path , block = 'NaCl_olex2_C2/m' )
176
+ self .b .read (path = nacl_cif_path , block = 'NaCl_olex2_C2/m' )
178
177
base = BaseFrame ()
179
178
with self .assertRaises (KeyError ):
180
179
base .fill_from_cif_block (self .b , fragile = True )
181
180
182
181
182
+ class TestCifValidator (unittest .TestCase ):
183
+ def test_validator (self ):
184
+ c = CifValidator ()
185
+ self .assertIn ('_atom_site_label' , c )
186
+ self .assertIsInstance (c ['_atom_site_label' ], CifBlock )
187
+
188
+
183
189
class TestCifFrame (unittest .TestCase ):
184
190
c_cif = CifFrame ()
185
- c_dic = CifFrame ()
186
191
c_fcf = CifFrame ()
187
192
188
193
def test_read_cif_file (self ):
189
- self .c_cif .read (nacl_fcf_file . path )
194
+ self .c_cif .read (nacl_cif_path )
190
195
self .assertIn ('NaCl' , self .c_cif )
191
196
self .assertIsInstance (self .c_cif ['NaCl' ], CifBlock )
192
197
193
- def test_read_dic_file (self ):
194
- self .c_dic .read (cif_core_dict_file .path )
195
- self .assertIn ('atom_site_label' , self .c_dic )
196
- self .assertIsInstance (self .c_dic ['atom_site_label' ], CifBlock )
197
-
198
198
def test_read_fcf_file (self ):
199
- self .c_fcf .read (nacl_fcf_file . path )
199
+ self .c_fcf .read (nacl_fcf_path )
200
200
self .assertIn ('NaCl' , self .c_fcf )
201
201
self .assertIsInstance (self .c_fcf ['NaCl' ], CifBlock )
202
202
@@ -207,7 +207,7 @@ class TestHklFrame(unittest.TestCase):
207
207
208
208
@classmethod
209
209
def setUpClass (cls ) -> None :
210
- cls .h1 .read (nacl_hkl_file . path , hkl_format = 'shelx_4' )
210
+ cls .h1 .read (nacl_hkl_path , hkl_format = 'shelx_4' )
211
211
cls .h1 .edit_cell (a = 5.64109 , b = 5.64109 , c = 5.64109 )
212
212
213
213
def setUp (self ) -> None :
@@ -228,7 +228,7 @@ def test_str(self):
228
228
self .assertIn ('419.465' , str_h [- 300 :])
229
229
230
230
def test_read (self ):
231
- self .h2 .read (nacl_hkl_file . path , hkl_format = 'free_4' )
231
+ self .h2 .read (nacl_hkl_path , hkl_format = 'free_4' )
232
232
self .assertEqual (self .h2 .table .__len__ (), 8578 )
233
233
234
234
def test_la_and_r_lim (self ):
0 commit comments