Skip to content

Commit

Permalink
regormat with gray
Browse files Browse the repository at this point in the history
  • Loading branch information
mosquito committed Nov 11, 2021
1 parent 03c4af4 commit b16007d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
1 change: 1 addition & 0 deletions aiomisc/service/sdwatchdog.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from aiomisc.service.base import Service
from aiomisc.utils import TimeoutType


log = logging.getLogger(__name__)


Expand Down
24 changes: 12 additions & 12 deletions tests/test_sdwatchdog_service.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import asyncio
import os
from collections import deque, Counter, defaultdict
from collections import Counter, defaultdict, deque
from pathlib import Path
from socket import AF_UNIX, SOCK_DGRAM
from tempfile import TemporaryDirectory
Expand All @@ -9,8 +9,8 @@

import aiomisc
from aiomisc import bind_socket
from aiomisc.service import UDPServer
from aiomisc.service import sdwatchdog
from aiomisc.service import UDPServer, sdwatchdog


pytestmark = pytest.mark.catch_loop_exceptions

Expand All @@ -28,21 +28,21 @@ def handle_datagram(self, data: bytes, addr: tuple) -> None:

with bind_socket(AF_UNIX, SOCK_DGRAM, address=sock_path) as sock:
try:
os.environ['NOTIFY_SOCKET'] = sock_path
os.environ['WATCHDOG_USEC'] = "100000"
os.environ["NOTIFY_SOCKET"] = sock_path
os.environ["WATCHDOG_USEC"] = "100000"

service = sdwatchdog.SDWatchdogService(
watchdog_interval=sdwatchdog._get_watchdog_interval()
watchdog_interval=sdwatchdog._get_watchdog_interval(),
)

assert service.watchdog_interval == 0.1

with aiomisc.entrypoint(
FakeJournald(sock=sock), service, loop=loop
FakeJournald(sock=sock), service, loop=loop,
):
loop.run_until_complete(asyncio.sleep(1))
finally:
for key in ('NOTIFY_SOCKET', 'WATCHDOG_USEC'):
for key in ("NOTIFY_SOCKET", "WATCHDOG_USEC"):
os.environ.pop(key)

assert packets
Expand All @@ -55,7 +55,7 @@ def handle_datagram(self, data: bytes, addr: tuple) -> None:
messages_count[key] += 1
messages[key].add(value)

assert 5 < messages_count['WATCHDOG'] < 25
assert messages_count['STATUS'] == 2
assert messages_count['WATCHDOG_USEC'] == 1
assert tuple(messages['WATCHDOG_USEC'])[0] == '100000'
assert 5 < messages_count["WATCHDOG"] < 25
assert messages_count["STATUS"] == 2
assert messages_count["WATCHDOG_USEC"] == 1
assert tuple(messages["WATCHDOG_USEC"])[0] == "100000"

0 comments on commit b16007d

Please sign in to comment.