Skip to content

Commit 17a0319

Browse files
committed
add a couple tests to complete coverage
1 parent 107f1db commit 17a0319

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

paths_cli/tests/test_parameters.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,17 @@ def setup(self):
148148
def test_get(self, getter):
149149
self._getter_test(getter)
150150

151+
def test_cannot_guess(self):
152+
filename = self._filename('no-guess')
153+
storage = paths.Storage(filename, 'w')
154+
storage.save(self.engine)
155+
storage.save(self.other_engine.named('other'))
156+
storage.close()
157+
158+
storage = paths.Storage(filename, mode='r')
159+
with pytest.raises(RuntimeError):
160+
self.PARAMETER.get(storage, None)
161+
151162

152163
class TestSCHEME(ParamInstanceTest):
153164
PARAMETER = SCHEME
@@ -275,6 +286,17 @@ def test_get_multiple(self):
275286
assert traj0 == self.traj
276287
assert traj1 == self.other_traj
277288

289+
def test_cannot_guess(self):
290+
filename = self._filename('no-guess')
291+
storage = paths.Storage(filename, 'w')
292+
storage.save(self.traj)
293+
storage.save(self.other_traj)
294+
storage.close()
295+
296+
storage = paths.Storage(filename, 'r')
297+
with pytest.raises(RuntimeError):
298+
self.PARAMETER.get(storage, None)
299+
278300

279301
class TestINIT_SNAP(ParamInstanceTest):
280302
PARAMETER = INIT_SNAP
@@ -312,6 +334,18 @@ def test_get(self, getter):
312334
obj = self.PARAMETER.get(storage, get_arg)
313335
assert obj == expected
314336

337+
def test_simstore_single_snapshot(self):
338+
stored_functions = pre_monkey_patch()
339+
filename = os.path.join(self.tempdir, "simstore.db")
340+
storage = APPEND_FILE.get(filename)
341+
storage.save(self.init_snap)
342+
storage.close()
343+
344+
storage = INPUT_FILE.get(filename)
345+
snap = self.PARAMETER.get(storage, None)
346+
assert snap == self.init_snap
347+
undo_monkey_patch(stored_functions)
348+
315349

316350
class MultiParamInstanceTest(ParamInstanceTest):
317351
def _getter_test(self, getter):

0 commit comments

Comments
 (0)