Skip to content

Commit

Permalink
Add test for IN_IGNORED (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
marksteward committed Nov 5, 2018
1 parent c4949b1 commit e8f61db
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/test_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ def _unlink(self, filename, *, parent=None):
path = os.path.join(parent or self.testdir, filename)
os.unlink(path)

def _mkdir(self, dirname, *, parent=None):
path = os.path.join(parent or self.testdir, dirname)
os.mkdir(path)

def _rmdir(self, dirname, *, parent=None):
path = os.path.join(parent or self.testdir, dirname)
os.rmdir(path)

def _rename(self, source, target, *, parent=None):
source_path = os.path.join(parent or self.testdir, source)
target_path = os.path.join(parent or self.testdir, target)
Expand Down Expand Up @@ -197,6 +205,24 @@ def test_rename_detection(self):
# And it's over.
yield from self._assert_no_events()

@asyncio.coroutine
def test_remove_directory(self):
""" A deleted file or directory should be unwatched."""
full_path = os.path.join(self.testdir, 'a')
self._mkdir('a')
self.watcher.watch(full_path, aionotify.Flags.IGNORED)
yield from self.watcher.setup(self.loop)

self._rmdir('a')
event = yield from self.watcher.get_event()
self._assert_file_event(event, '', flags=aionotify.Flags.IGNORED, alias=full_path)

# Make sure we can watch the same path again (#2)
self._mkdir('a')
self.watcher.watch(full_path, aionotify.Flags.IGNORED)

yield from self._assert_no_events()


class ErrorTests(AIONotifyTestCase):
"""Test error cases."""
Expand Down

0 comments on commit e8f61db

Please sign in to comment.