Utilities

This section shows general objects and helper functions that are used with this package.

General

class balderhub.crud.lib.utils.unset._UNSET_TYPE

Bases: object

Type for UNSET values. This object is used within FieldFillerCallback to define that a field should explicitly be unset.

Field Callbacks

Field Callbacks are used to read/write data field values to a remote device.

class balderhub.crud.lib.utils.field_callbacks.base_field_callback.BaseFieldCallback(*args, **kwargs)

Bases: ABC

Base class for data item field callbacks.

These callbacks will be called for every field while interacting with the system-under-test.

abstract execute(**kwargs) Any

This method executes the callback.

class balderhub.crud.lib.utils.field_callbacks.FieldCollectorCallback(*args, type_convert_cb: Callable[[Any], Any] | None = None, **kwargs)

Bases: BaseFieldCallback, ABC

Specific data item field callback for collecting the value of a specific field

execute(feature: AbstractDataItemRelatedFeature, abs_field_name: LookupFieldString | str, element_object: CallbackElementObjectT, already_collected_data: dict[str, Any], **kwargs) Any

Executes the collecting of the specific field value.

Parameters:
  • feature – the balder feature that calls this callback

  • abs_field_name – the field name

  • element_object – the working element describing one single container the data can be collected

  • already_collected_data – all data that was already collected

Returns:

the collected field value

class balderhub.crud.lib.utils.field_callbacks.FieldFillerCallback(*args, **kwargs)

Bases: BaseFieldCallback, ABC

Specific data item field callback for filling a specific value into a specific field

execute(feature: AbstractDataItemRelatedFeature, abs_field_name: LookupFieldString | str, element_object: CallbackElementObjectT, field_value_to_fill: Any, already_filled_data: dict[str, Any], **kwargs) Any

Executes the filling of the specific field value.

Parameters:
  • feature – the balder feature that calls this callback

  • abs_field_name – the field name

  • element_object – the working element describing one single container the data can be filled in

  • field_value_to_fill – the field data that should be filled in

  • already_filled_data – a dictionary with all field names and values that has already been filled

Returns:

the filled field value

class balderhub.crud.lib.utils.field_callbacks.Nested(_forward_none=True, _unset_callback=None, **kwargs)

Bases: BaseFieldCallback

Helper class to define nested field callbacks.

execute(feature: AbstractDataItemRelatedFeature, abs_field_name: str, element_object: CallbackElementObjectT, **kwargs) Any

Executes the nested statement with all its inner callbacks.

Parameters:
  • feature – the balder feature that calls this callback

  • abs_field_name – the field name

  • element_object – the working element describing one single container the data can be collected or filled in

property inner_callback_type: type[balderhub.crud.lib.utils.field_callbacks.base_field_callback.BaseFieldCallback]
Returns:

returns the inner callback type (either FieldCollectorCallback or FieldFillerCallback depending on the inner fields)

Exceptions

class balderhub.crud.lib.utils.exceptions.CallbackExecutionError

Bases: Exception

exception that will be thrown if there was an execution error in a field-callback