fastiot package

FastIoT Library

Subpackages

Submodules

fastiot.testlib module

Helpers to make writing tests easier

fastiot.testlib.populate_test_env(deployment_name='')[source]

Populates the local environment with test env vars from the test integration deployment.

It will import the .env-file from build dir and raise an error if not available. It will then overwrite these values from the .env-file within deployment dir for more robustness because sometimes the developer forgets to rebuild the config. Overwriting the env values with the deployment dir should solve it.

Parameters:

deployment_name (Optional[str]) – Optionally specify a different deployment to be used instead of the integration test

class fastiot.testlib.BackgroundProcess(service, startup_time=0.2, stop_time=0.05)[source]

Class to help with FastIoT Services as background process for tests using a separate python process.

This may help if your service already has many internal tasks and needs to act as a server for your unit or integration tests. Make sure to have a reasonable long startup time for the service to start. If in doubt use a couple seconds and slowly reduce when testing locally.

>>> from fastiot_sample_services.producer.producer_module import ExampleProducerService
>>> from fastiot.testlib import BackgroundProcess
>>>
>>> with BackgroundProcess(ExampleProducerService, startup_time=1.5):
>>>     pass  # Do some stuff with the service
>>> # Outside the context the service will be terminated and killed
__init__(service, startup_time=0.2, stop_time=0.05)[source]

Constructor

Parameters:
  • service (object) – The Service inheriting from fastiot.core.service.FastIoTService (without ())

  • startup_time (float) – The time to wait for the service to become ready, defaults to 0.2 seconds