CtrlK
CommunityDocumentationLog inGet started
Tessl Logo

tessl/pypi-gntp

tessl install tessl/pypi-gntp@1.0.0

Growl Notification Transport Protocol for Python

Agent Success

Agent success rate when using this tile

80%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.25x

Baseline

Agent success rate without this tile

64%

task.mdevals/scenario-4/

Notification System with Error Validation

Build a notification sender that validates server responses and handles various error conditions properly.

Requirements

Your task is to implement a notification system with the following features:

Core Functionality

  1. Registration: Register an application with a notification server, declaring notification types
  2. Sending Notifications: Send notifications to a registered server
  3. Response Validation: Validate server responses and handle both success and error cases

Error Handling Requirements

Your implementation must handle the following error scenarios:

  1. Network Connection Failures: Handle cases where the server cannot be reached (connection refused, timeout, host unreachable)
  2. Invalid Server Responses: Handle cases where the server returns malformed or unexpected responses
  3. Authentication Failures: Handle cases where authentication fails due to incorrect credentials
  4. Protocol Errors: Handle GNTP protocol-level errors returned by the server (e.g., invalid notification type, missing required fields)

Test Cases

  • Given an unreachable server (invalid hostname or closed port), registration should fail with an appropriate error @test
  • Given a server that returns a malformed response, the client should detect and handle the invalid response @test
  • Given incorrect authentication credentials, the client should handle the authentication failure appropriately @test

Implementation

@generates

API

class NotificationClient:
    """
    A notification client that sends notifications with proper error handling.
    """

    def __init__(self, hostname='localhost', port=23053, password=None):
        """
        Initialize the notification client.

        Args:
            hostname: The server hostname
            port: The server port
            password: Optional password for authentication
        """
        pass

    def register(self, app_name, notification_types):
        """
        Register the application with the server.

        Args:
            app_name: Name of the application
            notification_types: List of notification type names to register

        Raises:
            ConnectionError: If unable to connect to the server
            ValueError: If the server response is invalid
            AuthenticationError: If authentication fails
        """
        pass

    def send_notification(self, notification_type, title, description=''):
        """
        Send a notification to the server.

        Args:
            notification_type: The type of notification (must be registered)
            title: Notification title
            description: Optional notification description

        Raises:
            ConnectionError: If unable to connect to the server
            ValueError: If the server response is invalid or notification type not registered
            AuthenticationError: If authentication fails
        """
        pass

class AuthenticationError(Exception):
    """Raised when authentication with the server fails."""
    pass

Dependencies { .dependencies }

gntp { .dependency }

Provides GNTP protocol implementation for sending notifications.

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/gntp@1.0.x
tile.json