conftest

class conftest.AnalysisPluginTestConfig(*args, **kwargs)

Bases: BaseModel

A class configuring the analysis_plugin() fixture.

Parameters:
  • args (Any) –

  • kwargs (Any) –

Return type:

Any

init_kwargs: dict

Keyword arguments to be given to the plugin_class constructor. Not supported for AnalysisPluginV0

plugin_class

The class of the plugin to be tested. It will most probably be called AnalysisPlugin.

alias of AnalysisBasePlugin

start_processes: bool = False

Whether or not to start the workers (see AnalysisPlugin.start). Not supported for AnalysisPluginV0

conftest.analysis_plugin(request, patch_config)

Returns an instance of an AnalysisPlugin. This fixture can be configured by the supplying an instance of AnalysisPluginTestConfig as marker of the same name.

See also

The documentation of AnalysisPluginTestConfig

If this fixture does not fit your needs (which normally should not be necessary) you can define a fixture like this:

@pytest.fixture
def my_fancy_plugin(analysis_plugin)
    # Make sure the marker is defined as expected
    assert isinstance(analysis_plugin, MyFancyPlugin)
    # Patch custom things
    analysis_plugin.db_interface = CustomDbMock()
    # Return the plugin instance
    yield analysis_plugin

Note

If you want to set AnalysisPluginTestConfig.start_processes = True and want to modify plugin configuration like for example TIMEOUT you have to put the following in your test:

@pytest.mark.AnalysisPluginTestConfig(
    plugin_class=MyFancyPlugin,
    # Actually don't start the processes in the fixture
    start_processes=False,
)
def my_fancy_test(analysis_plugin, monkeypatch):
    analysis_plugin.TIMEOUT = 0
    # Now start the worker
    analysis_plugin.start()
conftest.backend_config(request, common_config, _firmware_file_storage_directory)
Return type:

Backend

conftest.common_config(request, docker_mount_base_dir)
Return type:

Common

conftest.docker_mount_base_dir()
Return type:

str

conftest.frontend_config(request, common_config)
Return type:

Frontend

conftest.patch_config(monkeypatch, common_config, backend_config, frontend_config)

This fixture will replace :py:data`config.common`, config.backend and config.frontend with the default test config.

Defaults in the test config can be overwritten with the markers backend_config_overwrite, frontend_config_overwrite and common_config_overwrite. These three markers accept a single argument of the type dict. When using backend_config_overwrite the dictionary has to contain valid keyword arguments for Backend.