Fixed formatting.
CI / Formatting (push) Successful in 5s
CI / Linting (push) Successful in 5s
CI / Tests (push) Successful in 27s
CI / Type Checking (push) Successful in 8s
CI / Spelling (push) Successful in 5s

This commit is contained in:
2026-05-17 14:49:37 -04:00
parent 0620c675d9
commit 33cc434354
6 changed files with 12 additions and 28 deletions
+2 -3
View File
@@ -77,7 +77,7 @@ def _format_duration(timestamp_str: str, now: datetime) -> str:
return f"{hours} hour{'s' if hours != 1 else ''}" return f"{hours} hour{'s' if hours != 1 else ''}"
days = seconds // 86400 days = seconds // 86400
return f"{days} day{'s' if days != 1 else ''}" return f"{days} day{'s' if days != 1 else ''}"
except (TypeError, ValueError): except TypeError, ValueError:
return "unknown duration" return "unknown duration"
@@ -133,8 +133,7 @@ class CommandHandler:
) )
except NotSubscribedError as e: except NotSubscribedError as e:
await evt.reply( await evt.reply(
"This room is already not subscribed to " f"This room is already not subscribed to notifications for {e.domain}."
f"notifications for {e.domain}."
) )
return return
+2 -5
View File
@@ -120,8 +120,7 @@ class OwncastClient:
async with self.session.get(url, allow_redirects=False) as response: async with self.session.get(url, allow_redirects=False) as response:
if response.status != 200: if response.status != 200:
self.log.warning( self.log.warning(
"[%s] Response to request on %s was not 200, " "[%s] Response to request on %s was not 200, got %s instead.",
"got %s instead.",
domain, domain,
path, path,
response.status, response.status,
@@ -159,9 +158,7 @@ class OwncastClient:
) )
return None return None
except (aiohttp.ClientError, TimeoutError, OSError) as e: except (aiohttp.ClientError, TimeoutError, OSError) as e:
self.log.warning( self.log.warning("[%s] Error making GET request to %s: %s", domain, path, e)
"[%s] Error making GET request to %s: %s", domain, path, e
)
return None return None
async def get_stream_state(self, domain: str) -> StreamState | None: async def get_stream_state(self, domain: str) -> StreamState | None:
+2 -4
View File
@@ -377,8 +377,7 @@ class StreamMonitor:
# Check for 90-day deletion threshold # Check for 90-day deletion threshold
if counter >= _CLEANUP_DELETE_THRESHOLD: if counter >= _CLEANUP_DELETE_THRESHOLD:
self.log.warning( self.log.warning(
"[%s] Reached 90-day deletion threshold. " "[%s] Reached 90-day deletion threshold. Removing all subscriptions.",
"Removing all subscriptions.",
domain, domain,
) )
# Send deletion notification # Send deletion notification
@@ -393,8 +392,7 @@ class StreamMonitor:
self.notification_service.clear_notification_state(domain) self.notification_service.clear_notification_state(domain)
self.log.info( self.log.info(
"[%s] Cleanup complete. Deleted %s subscriptions " "[%s] Cleanup complete. Deleted %s subscriptions and stream record.",
"and stream record.",
domain, domain,
deleted_count, deleted_count,
) )
+2 -6
View File
@@ -87,9 +87,7 @@ class SubscriptionManager:
if await self.stream_repo.create(stream_domain): if await self.stream_repo.create(stream_domain):
self.log.info("[%s] Discovered new stream!", stream_domain) self.log.info("[%s] Discovered new stream!", stream_domain)
self.log.info( self.log.info("[%s] Subscription added for room %s.", stream_domain, room_id)
"[%s] Subscription added for room %s.", stream_domain, room_id
)
return stream_domain return stream_domain
async def unsubscribe(self, room_id: str, url: str) -> str: async def unsubscribe(self, room_id: str, url: str) -> str:
@@ -103,9 +101,7 @@ class SubscriptionManager:
stream_domain = _domainify(url) stream_domain = _domainify(url)
await self.subscription_repo.remove(stream_domain, room_id) await self.subscription_repo.remove(stream_domain, room_id)
self.log.info( self.log.info("[%s] Subscription removed for room %s.", stream_domain, room_id)
"[%s] Subscription removed for room %s.", stream_domain, room_id
)
return stream_domain return stream_domain
async def list_room_subscriptions(self, room_id: str) -> list[RoomSubscription]: async def list_room_subscriptions(self, room_id: str) -> list[RoomSubscription]:
+3 -7
View File
@@ -423,9 +423,7 @@ class TestResponseTimeMetrics:
) )
await client.get_stream_state("example.com") await client.get_stream_state("example.com")
output = generate_metrics_output(metrics) output = generate_metrics_output(metrics)
assert ( assert 'owncastsentry_api_response_seconds{domain="example.com"}' in output
'owncastsentry_api_response_seconds{domain="example.com"}' in output
)
finally: finally:
await client.close() await client.close()
@@ -446,8 +444,7 @@ class TestResponseTimeMetrics:
await client.get_stream_state("example.com") await client.get_stream_state("example.com")
output = generate_metrics_output(metrics) output = generate_metrics_output(metrics)
assert ( assert (
'owncastsentry_api_response_seconds{domain="example.com"}' 'owncastsentry_api_response_seconds{domain="example.com"}' not in output
not in output
) )
finally: finally:
await client.close() await client.close()
@@ -469,8 +466,7 @@ class TestResponseTimeMetrics:
await client.get_stream_state("example.com") await client.get_stream_state("example.com")
output = generate_metrics_output(metrics) output = generate_metrics_output(metrics)
assert ( assert (
'owncastsentry_api_response_seconds{domain="example.com"}' 'owncastsentry_api_response_seconds{domain="example.com"}' not in output
not in output
) )
finally: finally:
await client.close() await client.close()
+1 -3
View File
@@ -117,9 +117,7 @@ class TestHasRoomSubscriptions:
self, subscription_repo: SubscriptionRepository self, subscription_repo: SubscriptionRepository
) -> None: ) -> None:
"""Return False when the room has no subscriptions.""" """Return False when the room has no subscriptions."""
assert not await subscription_repo.has_room_subscriptions( assert not await subscription_repo.has_room_subscriptions("!nobody:example.com")
"!nobody:example.com"
)
class TestGetRoomSubscriptions: class TestGetRoomSubscriptions: