-
Notifications
You must be signed in to change notification settings - Fork 0
Description
As a library user extending ucon with custom units
I want unit name resolution to be scoped to the active ConversionGraph
So I can define units that are visible only within a specific graph context without polluting global state
Acceptance Criteria
-
GIVEN a custom Unit registered via
graph.register_unit(unit)
WHENget_unit_by_name(name)is called withinusing_graph(graph)
THEN the custom unit must be returned. -
GIVEN a custom Unit registered on graph A
WHENget_unit_by_name(name)is called withinusing_graph(graph_b)(a different graph)
THEN the custom unit must NOT be found (raises UnknownUnitError or returns None). -
GIVEN a unit name that exists in both graph-local and global registries
WHENget_unit_by_name(name)is called withinusing_graph(graph)
THEN the graph-local unit must take precedence. -
GIVEN a unit name that exists only in the global registry
WHENget_unit_by_name(name)is called withinusing_graph(graph)
THEN the global unit must be returned (fallback behavior). -
GIVEN a ConversionGraph
WHENgraph.copy()is called
THEN a new independent graph must be returned with copied name registries. -
GIVEN the default graph built by
_build_standard_graph()
WHEN any standard unit name is queried viagraph.resolve_unit(name)
THEN the standard unit must be returned. -
GIVEN case-sensitive unit shorthands (e.g., 'm' for meter, 'M' for mega prefix)
WHENgraph.resolve_unit(name)is called
THEN case-sensitive lookup must be attempted before case-insensitive fallback. -
GIVEN nested
using_graph()contexts
WHEN the inner context exits
THEN the outer graph must be restored for both conversion and name resolution.