Skip to content

Commit 282fa8f

Browse files
committed
Add tests for warning logs when folder is empty or not present
1 parent 6f957ea commit 282fa8f

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

neo/test/rawiotest/test_alphaomegarawio.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class and a full test will be done to test if the new coded IO
2323
"""
2424

2525
import logging
26+
import tempfile
2627
import unittest
2728

2829
from pathlib import Path
@@ -46,6 +47,10 @@ class TestAlphaOmegaRawIO(BaseTestRawIO, unittest.TestCase):
4647
"alphaomega/mpx_map_version4",
4748
]
4849

50+
def setUp(self):
51+
super().setUp()
52+
self.logger = logging.getLogger("neo.rawio.alphaomegarawio.AlphaOmegaRawIO")
53+
4954
def test_explore_folder(self):
5055
"""We just check that we index all *.lsx files and that all *.mpx files
5156
are referenced somewhere. We should maybe check that *.lsx files are
@@ -63,6 +68,20 @@ def test_explore_folder(self):
6368
all_mpx = sorted(list(path.glob("*.mpx")))
6469
self.assertSequenceEqual(all_filenames, all_mpx)
6570

71+
def test_explore_no_folder(self):
72+
with tempfile.TemporaryDirectory() as tmpdir:
73+
# just create a temporary folder that is removed
74+
pass
75+
with self.assertLogs(logger=self.logger, level="ERROR") as cm:
76+
reader = AlphaOmegaRawIO(dirname=tmpdir)
77+
self.assertIn("is not a folder", cm.output[0])
78+
79+
def test_empty_folder(self):
80+
with tempfile.TemporaryDirectory() as tmpdir:
81+
with self.assertLogs(logger=self.logger, level="ERROR") as cm:
82+
reader = AlphaOmegaRawIO(dirname=tmpdir)
83+
self.assertIn("Found no AlphaOmega *.mpx files in", cm.output[0])
84+
6685
def test_read_file_blocks(self):
6786
"""Superficial test that check it returns all types of channels"""
6887
path = Path(self.get_local_path("alphaomega/mpx_map_version4"))

0 commit comments

Comments
 (0)