or run

npx @tessl/cli init
Log in

Version

Files

tile.json

task.mdevals/scenario-5/

Memory-Efficient Configuration Manager

Build a configuration management system that uses slotted classes for memory efficiency. The system should serialize and deserialize configuration objects that use __slots__ to optimize memory usage in resource-constrained environments.

Requirements

Implement a configuration system with the following components:

  1. ServerConfig class: A slotted class that stores server configuration

    • Must use __slots__ to define exactly these attributes: host, port, timeout
    • Should support serialization to dictionary format
    • Should support deserialization from dictionary format
  2. DatabaseConfig class: A slotted class that stores database configuration

    • Must use __slots__ to define exactly these attributes: connection_string, pool_size, retry_attempts
    • Should support serialization to dictionary format
    • Should support deserialization from dictionary format
  3. ApplicationConfig class: A slotted class that combines both server and database configs

    • Must use __slots__ to define exactly these attributes: app_name, server, database
    • The server attribute should hold a ServerConfig instance
    • The database attribute should hold a DatabaseConfig instance
    • Should support serialization to dictionary format including nested objects
    • Should support deserialization from dictionary format including nested objects

Implementation Files

  • Main implementation: src/config_manager.py
  • Tests: test/test_config_serialization.py

Test Cases

All test cases should be implemented in test/test_config_serialization.py:

  • Serialize a ServerConfig instance with host="localhost", port=8080, timeout=30 to a dictionary and verify the result contains all three attributes with correct values @test

  • Deserialize a dictionary {"host": "api.example.com", "port": 443, "timeout": 60} into a ServerConfig instance and verify all attributes are correctly set @test

  • Serialize a DatabaseConfig instance with connection_string="postgresql://localhost/db", pool_size=10, retry_attempts=3 to a dictionary and verify all attributes are present @test

  • Deserialize a dictionary {"connection_string": "mysql://localhost/app", "pool_size": 5, "retry_attempts": 2} into a DatabaseConfig instance and verify all attributes match @test

  • Serialize an ApplicationConfig instance containing nested ServerConfig and DatabaseConfig objects, and verify the output dictionary contains correctly nested structures @test

  • Deserialize a nested dictionary structure into an ApplicationConfig instance and verify that both the app_name and nested server and database configurations are correctly reconstructed @test

Dependencies { .dependencies }

jsons { .dependency }

A Python serialization/deserialization library for converting Python objects to and from JSON-compatible dictionaries. Provides support for slotted classes and nested object serialization.

@satisfied-by