openpectus.test.protocol.test_aggregator_engine

Attributes

logger

Classes

ProtocolIntegrationTestCase

A class whose instances are single test cases.

ProtocolIntegrationTest

A class whose instances are single test cases.

AggregatorErrorTest

A class whose instances are single test cases.

AggregatorTestDispatcher

Aggregator dispatcher for the Aggregator-Engine Protocol using REST + WebSocket RPC.

EngineTestDispatcher

Engine dispatcher for the Aggregator-Engine Protocol.

MessageTest

A class whose instances are single test cases.

Module Contents

openpectus.test.protocol.test_aggregator_engine.logger
class openpectus.test.protocol.test_aggregator_engine.ProtocolIntegrationTestCase(methodName='runTest')

Bases: unittest.IsolatedAsyncioTestCase

A class whose instances are single test cases.

By default, the test code itself should be placed in a method named ‘runTest’.

If the fixture may be used for many test cases, create as many test methods as are needed. When instantiating such a TestCase subclass, specify in the constructor arguments the name of the test method that the instance is to execute.

Test authors should subclass TestCase for their own tests. Construction and deconstruction of the test’s environment (‘fixture’) can be implemented by overriding the ‘setUp’ and ‘tearDown’ methods respectively.

If it is necessary to override the __init__ method, the base class __init__ method must always be called. It is important that subclasses should not change the signature of their __init__ method, since instances of the classes are instantiated automatically by parts of the framework in order to be run.

When subclassing TestCase, you can set these attributes: * failureException: determines which exception will be raised when

the instance’s assertion methods fail; test methods raising this exception will be deemed to have ‘failed’ rather than ‘errored’.

  • longMessage: determines whether long messages (including repr of

    objects used in assert methods) will be printed on failure in addition to any explicit message passed.

  • maxDiff: sets the maximum length of a diff in failure messages

    by assert methods using difflib. It is looked up as an instance attribute so can be configured by individual tests if required.

ctx: ProtocolIntegrationTestCase | None = None
class Context

Test helper class

engine: openpectus.engine.engine.Engine
engineDispatcher: EngineTestDispatcher
engineRunner: openpectus.engine.engine_runner.EngineRunner
engineMessageHandlers: openpectus.engine.engine_message_handlers.EngineMessageHandlers
aggregatorDispatcher: AggregatorTestDispatcher
frontendPublisher: openpectus.aggregator.frontend_publisher.FrontendPublisher
aggregator: openpectus.aggregator.aggregator.Aggregator
async asyncSetUp()
Return type:

None

async asyncTeardown()
Return type:

None

async start_engine()
async stop()
async register()
Return type:

str

class openpectus.test.protocol.test_aggregator_engine.ProtocolIntegrationTest(methodName='runTest')

Bases: ProtocolIntegrationTestCase

A class whose instances are single test cases.

By default, the test code itself should be placed in a method named ‘runTest’.

If the fixture may be used for many test cases, create as many test methods as are needed. When instantiating such a TestCase subclass, specify in the constructor arguments the name of the test method that the instance is to execute.

Test authors should subclass TestCase for their own tests. Construction and deconstruction of the test’s environment (‘fixture’) can be implemented by overriding the ‘setUp’ and ‘tearDown’ methods respectively.

If it is necessary to override the __init__ method, the base class __init__ method must always be called. It is important that subclasses should not change the signature of their __init__ method, since instances of the classes are instantiated automatically by parts of the framework in order to be run.

When subclassing TestCase, you can set these attributes: * failureException: determines which exception will be raised when

the instance’s assertion methods fail; test methods raising this exception will be deemed to have ‘failed’ rather than ‘errored’.

  • longMessage: determines whether long messages (including repr of

    objects used in assert methods) will be printed on failure in addition to any explicit message passed.

  • maxDiff: sets the maximum length of a diff in failure messages

    by assert methods using difflib. It is looked up as an instance attribute so can be configured by individual tests if required.

async test_can_register()
async test_can_send_tag_updates()
async test_can_detect_network_down_and_buffer_up_messages()
class openpectus.test.protocol.test_aggregator_engine.AggregatorErrorTest(methodName='runTest')

Bases: ProtocolIntegrationTestCase

A class whose instances are single test cases.

By default, the test code itself should be placed in a method named ‘runTest’.

If the fixture may be used for many test cases, create as many test methods as are needed. When instantiating such a TestCase subclass, specify in the constructor arguments the name of the test method that the instance is to execute.

Test authors should subclass TestCase for their own tests. Construction and deconstruction of the test’s environment (‘fixture’) can be implemented by overriding the ‘setUp’ and ‘tearDown’ methods respectively.

If it is necessary to override the __init__ method, the base class __init__ method must always be called. It is important that subclasses should not change the signature of their __init__ method, since instances of the classes are instantiated automatically by parts of the framework in order to be run.

When subclassing TestCase, you can set these attributes: * failureException: determines which exception will be raised when

the instance’s assertion methods fail; test methods raising this exception will be deemed to have ‘failed’ rather than ‘errored’.

  • longMessage: determines whether long messages (including repr of

    objects used in assert methods) will be printed on failure in addition to any explicit message passed.

  • maxDiff: sets the maximum length of a diff in failure messages

    by assert methods using difflib. It is looked up as an instance attribute so can be configured by individual tests if required.

async test_can_get_engine_data_for_registered_engine()
async test_rpc_call_fail_with_network_error_engine_state_is_removed()
class openpectus.test.protocol.test_aggregator_engine.AggregatorTestDispatcher

Bases: openpectus.protocol.aggregator_dispatcher.AggregatorDispatcher

Aggregator dispatcher for the Aggregator-Engine Protocol using REST + WebSocket RPC. Allows receiving message via HTTP POST and sending messages via JSON-RPC.

engineDispatcher: openpectus.protocol.engine_dispatcher.EngineDispatcher
connected_engines: set[str]
failing_engines: set[str]
set_engine_fail(engine_id, failing)
Parameters:
  • engine_id (str)

  • failing (bool)

get_engine_fail(engine_id)
async rpc_call(engine_id, message)
Parameters:
Return type:

openpectus.protocol.messages.MessageBase

async dispatch_message(message)

Dispatch incoming message to registered handler.

Parameters:

message (openpectus.protocol.engine_messages.EngineMessage)

Return type:

openpectus.protocol.messages.MessageBase

has_connected_engine_id(engine_id)

Return a value indicating whether the engine_id is known. Abstract method.

Parameters:

engine_id (str)

Return type:

bool

class openpectus.test.protocol.test_aggregator_engine.EngineTestDispatcher

Bases: openpectus.protocol.engine_dispatcher.EngineDispatcher

Engine dispatcher for the Aggregator-Engine Protocol. Allows sending messages via HTTP POST and JSON-RPC.

aggregatorDispatcher: AggregatorTestDispatcher
network_failing = False
async connect_async()
async send_registration_msg_async(message)

Send message registration message via post

Parameters:

message (openpectus.protocol.engine_messages.RegisterEngineMsg)

Return type:

openpectus.protocol.messages.MessageBase

async send_async(message)

Send message via websocket.

Parameters:

message (openpectus.protocol.engine_messages.EngineMessage)

Return type:

openpectus.protocol.messages.MessageBase

class openpectus.test.protocol.test_aggregator_engine.MessageTest(methodName='runTest')

Bases: unittest.TestCase

A class whose instances are single test cases.

By default, the test code itself should be placed in a method named ‘runTest’.

If the fixture may be used for many test cases, create as many test methods as are needed. When instantiating such a TestCase subclass, specify in the constructor arguments the name of the test method that the instance is to execute.

Test authors should subclass TestCase for their own tests. Construction and deconstruction of the test’s environment (‘fixture’) can be implemented by overriding the ‘setUp’ and ‘tearDown’ methods respectively.

If it is necessary to override the __init__ method, the base class __init__ method must always be called. It is important that subclasses should not change the signature of their __init__ method, since instances of the classes are instantiated automatically by parts of the framework in order to be run.

When subclassing TestCase, you can set these attributes: * failureException: determines which exception will be raised when

the instance’s assertion methods fail; test methods raising this exception will be deemed to have ‘failed’ rather than ‘errored’.

  • longMessage: determines whether long messages (including repr of

    objects used in assert methods) will be printed on failure in addition to any explicit message passed.

  • maxDiff: sets the maximum length of a diff in failure messages

    by assert methods using difflib. It is looked up as an instance attribute so can be configured by individual tests if required.

test_print_sequence_range()