Skip to content
Andres Buitrago edited this page Jun 19, 2025 · 1 revision

Maple spec library

Functions

it(spec_name: str)

Initializes a new spec with a human-readable name. Every spec must begin with a call to it() to describe its intent.

def my_spec():
    mp.it("checks something important in the model")
    ...

get(selector: str, value: str) -> Chainable

Retrieves the elements from the Speckle model using a key-value selector. Returns a chainable object for further filtering or assertions.

elements = get("speckle_type", "Base")

where(self, selector: str, value: str) -> Self

Filters the elements in a Chainable object, keeping only those where the property selector equals the specified value.

elements = get("speckle_type", "Base").where("name", "Door")

its(self, property: str) -> Self

Focuses the chain on a specific nested property within the current set of elements. This is typically followed by an assertion using should().

doors = get("type", "IFCDOOR")
doors.its("properties.Dimensions.Area")
...

should(self, comparer: ComparisonOps, assertion_value) -> Self

Performs an assertion on the currently selected property using a comparison operator.

doors = get("type", "IFCDOOR")
# Check that the door’s height is greater than 2.10
doors.its("properties.Dimensions.Height").should("be.greater", 2.10)

walls = get("type", "IFCWALL")
# Check that fire rating is set to 'Class 3'
walls.its("properties.Pset_Wall_Common.FireRating").should("have.value", "Class 3")

ComparisonOps

Enumeration of valid comparison operations for use in should():

  • "be.greater": Asserts that the property is greater than the given value.

  • "be.smaller": Asserts that the property is smaller than the given value.

  • "be.equal": Asserts that the property is exactly equal to the given value.

  • "have.value": (string) Asserts that the property matches the given string value.

  • "have.length": Asserts that the number of collected items equals the given number.

def run(*specs: Callable)

Executes one or more spec functions. Functions must be passed without invoking them (i.e., without parentheses).

mp.run(spec_1, spec_2, spec_3)