mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-12-22 07:21:56 +00:00
Fix pipe deletion check
This commit is contained in:
parent
517684e84a
commit
57ce35d99d
@ -28,13 +28,12 @@ class PipeConnector:
|
||||
|
||||
def _on_any_event(self, event):
|
||||
path = event.src_path
|
||||
if self._is_pipe(path):
|
||||
if isinstance(event, InotifyFileCreatedEvent):
|
||||
self._on_create_pipe(path)
|
||||
LOG.debug('Connected to new pipe "%s"', path)
|
||||
elif isinstance(event, InotifyFileDeletedEvent):
|
||||
self._on_delete_pipe(path)
|
||||
LOG.debug('Disconnected from deleted pipe "%s"', path)
|
||||
if self._is_pipe(path) and isinstance(event, InotifyFileCreatedEvent):
|
||||
self._on_create_pipe(path)
|
||||
LOG.debug('Connected to new pipe "%s"', path)
|
||||
elif isinstance(event, InotifyFileDeletedEvent):
|
||||
self._on_delete_pipe(path)
|
||||
LOG.debug('Disconnected from deleted pipe "%s"', path)
|
||||
|
||||
@staticmethod
|
||||
def _is_pipe(path):
|
||||
|
@ -3,7 +3,7 @@ from enum import Enum
|
||||
from dataclasses import dataclass
|
||||
from json import dumps
|
||||
from secrets import token_urlsafe
|
||||
from os import urandom, mkfifo, mkdir
|
||||
from os import urandom, mkfifo, mkdir, remove
|
||||
from os.path import join
|
||||
from pathlib import Path
|
||||
from tempfile import TemporaryDirectory
|
||||
@ -117,6 +117,7 @@ def test_pipe_creation_deletion(mock_context):
|
||||
path = mock_context.emit_pipe_creation_event(action, mkfifo)
|
||||
assert events[-1] == path
|
||||
assert path in pipes.keys()
|
||||
remove(path)
|
||||
mock_context.pipes.observer.on_any_event(InotifyFileDeletedEvent(path))
|
||||
assert path not in pipes.keys()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user