Ejemplo n.º 1
0
def test_updating_component():
    brown_sugar = Component.create("brown_sugar", kind="solid", units=100)

    old_units = brown_sugar.units

    brown_sugar.update(units=200)

    new_units = brown_sugar.units

    assert old_units != new_units
Ejemplo n.º 2
0
def test_create_components(kwargs):
    Component.create(**kwargs)
Ejemplo n.º 3
0
def test_create_components_exception():
    with raises(Exception, match="Kind must be set"):
        Component.create("Vodka")
Ejemplo n.º 4
0
        assert units, "Units must be set"
        assert kind in ("solid", "liquid"), "Kind must be either solid or liquid"

        if component or (component := state.components.get(name.lower())):
            component.update(
                kind=kind,
                units=units,
                attrs=attrs,
                components=components
            )
            print(f"Updating {name}")

        else:
            component = Component.create(
                name,
                kind=kind,
                units=units,
                attrs=attrs,
                components=components
            )
            created = True

            print(f"Creating {name}")

        state.components[name] = component

        return component, created

    def detail_compound(self, compound):
        display_details(compound)