Skip to content

UnitPackage and config loading #161

@withtwoemms

Description

@withtwoemms

As an application developer integrating ucon
I want to define domain-specific units in TOML config files
So I can extend ucon at application startup without modifying library code or using global mutable state


Acceptance Criteria

  • GIVEN a valid TOML file with unit definitions
    WHEN load_package(path) is called
    THEN a frozen UnitPackage object must be returned.

  • GIVEN a UnitPackage with unit definitions
    WHEN graph.with_package(pkg) is called
    THEN a new graph must be returned with those units registered.

  • GIVEN a UnitPackage with edge definitions
    WHEN graph.with_package(pkg) is called
    THEN the new graph must have conversion edges for those definitions.

  • GIVEN a unit defined in a package
    WHEN Number(1, "custom_unit").to("base_unit") is called within using_graph(extended_graph)
    THEN the conversion must succeed using the package-defined edge.

  • GIVEN multiple packages
    WHEN graph.with_package(a).with_package(b) is called
    THEN units and edges from both packages must be available.

  • GIVEN a package with an invalid dimension name
    WHEN load_package(path) is called
    THEN PackageLoadError must be raised with a descriptive message.

  • GIVEN a package file that does not exist
    WHEN load_package(path) is called
    THEN PackageLoadError must be raised.

  • GIVEN a package file with invalid TOML syntax
    WHEN load_package(path) is called
    THEN PackageLoadError must be raised with parse error details.

  • GIVEN graph.with_package(pkg)
    WHEN the original graph is inspected
    THEN it must be unchanged (immutable composition).

  • GIVEN an extended graph
    WHEN set_default_graph(extended_graph) is called
    THEN subsequent conversions must use the extended graph by default.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions