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