Skip to content

0.3.7

Compare
Choose a tag to compare
@jlubken jlubken released this 18 Dec 15:04

Add batch_cls as a property of a service, and as a parameter to the constructor.

Allow users to subclass service and substitute the class used for the batch by changing the default parameter:

class MockBatch(Batch):

    def __init__(self, ...):
        # add new properties here
        super().__init__(...)

class MockService(..., Service):

    def __init__(self, **kwargs):
        super().__init__(batch_cls=MockBatch, **kwargs)

... alternatively pass a pseudo constructor function that returns a configured Mock:

def mock_batch():
    """Likely this is a test fixture.
    batch = Batch(...)
    # monkey patch up batch here...
    return batch

class MockService(..., Service):

    def __init__(self, **kwargs):
        super().__init__(batch_cls=mock_batch, **kwargs)