class Tab1: string_from_first_tab = String(caption="first", value="1") @group(caption="This is a Group") class GroupMain: string_from_first_tab_inside_group = String( caption="Caption From Group", value="Inside Group" )
def test_string(): from alfasim_sdk._internal.types import String with pytest.raises( TypeError, match="missing 1 required keyword-only argument: 'caption'"): String(value="acme") with pytest.raises(TypeError, match=re.escape( "'caption' must be 'str' (got 1 that is a 'int')")): String(value="acme", caption=1) with pytest.raises( TypeError, match=re.escape("'value' must be 'str' (got 1 that is a 'int')")): String(value=1, caption="caption")
class ValidClass: string_from_main = String(caption="Caption from Root", value="Root") @group(caption="This is a Group") class GroupMain: string_from_group = String( caption="Caption From Group", value="Inside Group" )
class Main: a = String(caption="1", value="2") @tab(caption="Fist Tab") class Tab1: pass @tab(caption="Second Tab") class Tab2: pass
class ValidClass: string_from_main = String(caption="main", value="2") @tabs() class TabsMain: @tab(caption="Fist Tab") class Tab1: string_from_first_tab = String(caption="first", value="2") @tab(caption="Second Tab") class Tab2: string_from_second_tab = String(caption="second", value="2")
def test_enable_expr_and_visible_expr(expression_type): from alfasim_sdk._internal.types import String inputs = {"value": "value", "caption": "caption", expression_type: ""} with pytest.raises(TypeError, match=f"'{expression_type}' must be callable"): String(**inputs) def function_definition(): # pragma: no cover pass valid_input_1 = { "value": "value", "caption": "caption", expression_type: None } valid_input_2 = { "value": "value", "caption": "caption", expression_type: function_definition, } String(**valid_input_1) String(**valid_input_2)
class Tab2: string_from_second_tab = String(caption="second", value="2")
class Tab1: string_from_first_tab = String(caption="first", value="2")
class GroupMain: string_from_first_tab_inside_group = String( caption="Caption From Group", value="Inside Group" )
class Model: boolean = Boolean(value=True, caption="caption") data_reference = Reference(ref_type=TracerType, caption="caption") enum = Enum(values=["value_1", "value_2"], caption="caption") string = String(value="value", caption="caption") quantity = Quantity(value=1, unit="m", caption="caption")