caspia.meadow.testing namespace

Submodules

caspia.meadow.testing.connection module

class caspia.meadow.testing.connection.MockConsumerConnection[source]

Bases: caspia.meadow.client.connection.consumer.ConsumerConnection

async attach_subscriber(subscriber)[source]

Attach the subscriber and return immediatelly.

The subscriber will be ready sometime in future. To wait for that, use await self.subscriber_ready(s).

property connected
detach_subscriber(subscriber)

Detach the subscriber (with immediate effect).

async ensure_connected()
listen_writes(service, characteristic, target)

Listen for writes on a given characteristic.

This is a way for one client to observe, that another client issued a write. This is not for responding to write commands (see GatewayConnection instead).

async mock_gateway_register(gateways)[source]
async mock_gateways(gateways)[source]
on_connect(client, userdata, flags, rc)
on_disconnect(client, userdata, rc)
on_message(client, userdata, message)
on_publish(client, userdata, mid)
on_subscribe(client, userdata, mid, granted_qos)
on_unsubscribe(client, userdata, mid)
async read(service, characteristic, timeout=None, req_id=None)[source]
async request_rules(gateway, rules)

Request activation of rules from a gateway.

Use subscribe_active_rules to see activated rules.

Parameters

rules – iterable of serialized Rule instances

async run_forever()

Never return. Main runloop of the client managing its connection.

async subscribe(service, characteristic, on_value, on_error=None)[source]

Subscribe for characteristic notification on service.

Parameters
  • service – Service name or None for all services.

  • characteristic – Characteristic or None for all characteristics.

  • on_value – callable(value=, extra=, service=, characteristic=)

  • on_error – callable(error=, service=, characteristic=) or None

Returns

An subscription object with .unsubscribe method.

async subscribe_gateways_update(target)[source]
async subscribe_rules_update(gateway, target)

Subscribe for rule activation updates from a gateway.

Parameters

target – callable(rules: list of serialized Rule instances)

Returns

an object with .unsubscribe() method.

async subscriber_ready(subscriber)

Await the subscriber to be ready.

async write(service, characteristic, value, extra=None, timeout=None, req_id=None)[source]