Skip to content

Commit 2413ac7

Browse files
committed
Tests now use NaCl files in test folder instead of resources
1 parent 4f4d25d commit 2413ac7

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

hikari/dataframes/cif.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,11 @@ def __init__(self):
116116

117117
@staticmethod
118118
def _expand_names(dict_):
119-
expanded_items = CifBlock()
119+
expanded_items = OrderedDict()
120120
for data_block_name, data_block in dict_.items():
121121
names = data_block.get('_name', None)
122122
if names:
123-
data_block_without_name_item = OrderedDict()
123+
data_block_without_name_item = CifBlock()
124124
for data_name, data_value in data_block.items():
125125
if data_name is not '_name':
126126
data_block_without_name_item[data_name] = data_value

test/test_dataframes.py

+19-19
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from hikari.dataframes import BaseFrame, CifBlock, CifFrame, HklFrame, \
1010
UBaseFrame
11-
from hikari.resources import nacl_fcf, nacl_hkl, nacl_cif, cif_core_dict
11+
from hikari.dataframes.cif import CifValidator
1212
from hikari.symmetry import PG
1313

1414
rad60 = 1.0471975511965976
@@ -37,10 +37,9 @@ def __init__(self, name, content):
3737
self.file.write(content)
3838

3939

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'))
4443

4544

4645
class TestBaseFrame(unittest.TestCase):
@@ -115,7 +114,7 @@ def test_volumes(self):
115114

116115
class TestCifBlockRead(unittest.TestCase):
117116
def test_read(self):
118-
CifBlock().read(path=nacl_cif_file.path, block='NaCl')
117+
CifBlock().read(path=nacl_cif_path, block='NaCl')
119118

120119

121120
class TestCifBlockGeneral(unittest.TestCase):
@@ -124,7 +123,7 @@ class TestCifBlockGeneral(unittest.TestCase):
124123
@classmethod
125124
def setUpClass(cls) -> None:
126125
super().setUpClass()
127-
cls.b.read(path=nacl_cif_file.path, block='NaCl')
126+
cls.b.read(path=nacl_cif_path, block='NaCl')
128127

129128
def test_access(self):
130129
self.assertIn('_cell_length_a', self.b)
@@ -167,36 +166,37 @@ class TestCifBlockInterface(unittest.TestCase):
167166
b = CifBlock()
168167

169168
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')
171170
base = BaseFrame()
172171
base.fill_from_cif_block(self.b, fragile=False)
173172
self.assertAlmostEqual(base.v_d, 179.51018149594705)
174173
self.assertAlmostEqual(base.orientation[0, 0], -0.0617076000)
175174

176175
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')
178177
base = BaseFrame()
179178
with self.assertRaises(KeyError):
180179
base.fill_from_cif_block(self.b, fragile=True)
181180

182181

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+
183189
class TestCifFrame(unittest.TestCase):
184190
c_cif = CifFrame()
185-
c_dic = CifFrame()
186191
c_fcf = CifFrame()
187192

188193
def test_read_cif_file(self):
189-
self.c_cif.read(nacl_fcf_file.path)
194+
self.c_cif.read(nacl_cif_path)
190195
self.assertIn('NaCl', self.c_cif)
191196
self.assertIsInstance(self.c_cif['NaCl'], CifBlock)
192197

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-
198198
def test_read_fcf_file(self):
199-
self.c_fcf.read(nacl_fcf_file.path)
199+
self.c_fcf.read(nacl_fcf_path)
200200
self.assertIn('NaCl', self.c_fcf)
201201
self.assertIsInstance(self.c_fcf['NaCl'], CifBlock)
202202

@@ -207,7 +207,7 @@ class TestHklFrame(unittest.TestCase):
207207

208208
@classmethod
209209
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')
211211
cls.h1.edit_cell(a=5.64109, b=5.64109, c=5.64109)
212212

213213
def setUp(self) -> None:
@@ -228,7 +228,7 @@ def test_str(self):
228228
self.assertIn('419.465', str_h[-300:])
229229

230230
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')
232232
self.assertEqual(self.h2.table.__len__(), 8578)
233233

234234
def test_la_and_r_lim(self):

0 commit comments

Comments
 (0)