Helpers for testing nti.webhooks.

class nti.webhooks.testing.DoctestTransaction(db=None)[source]

Bases: nti.testing.zodb.mock_db_trans

Like nti.testing.zodb.mock_db_trans, but with methods that are prettier for use in doctests.

Parameters:db – The ZODB.DB to open. If none is given, then the ZODBLayer.db will be used.
class nti.webhooks.testing.InterestingClass[source]

Bases: object

A class we refer to (and manipulate) in documentation.

Do not depend on anything specific about this class other than its existence.

class nti.webhooks.testing.SequentialExecutorService[source]

Bases: object

Runs tasks one at a time, and only when waited on.

The preferred interface to this is begin_synchronous_delivery().

class nti.webhooks.testing.UsingMocks(*args, **kwargs)[source]

Bases: object

Mocks requests using responses.

This is similar to the context manager supplied with responses, but a little bit less ugly to use in doctests.

Creating the object automatically establishes mocks. You must explicitly finish() it to end the mocking.

class nti.webhooks.testing.ZODBFixture[source]

Bases: object

Like nti.testing.zodb.ZODBLayer, but not a layer and meant for doctests.


Alternate name for begin_synchronous_delivery that may be more descriptive in some circumstances.


Cause the global IWebhookDeliveryManager to begin delivering new shipments synchronously.

All deliveries are queued until waitForPendingDeliveries is called; exceptions will be raised from that function.

This remains in effect until the test is torn down with zope.testing.cleanup.


A context manager, during which delivery attempts will fail with an exception from the HTTP layer.


A context manager, during which processing results of delivery attempts will fail with an unexpected exception.


A context manager, during which the default webhook validator will fail all target lookups.


Queries the current nti.webhooks.interfaces.IWebhookDeliveryManager and asks it to wait for all pending deliveries.