- class DatastoreContainer(image: str = 'google/cloud-sdk:emulators', project: str = 'test-project', port: int = 8081, **kwargs)¶
Datastore container for testing managed message queues.
Example
The example will spin up a Google Cloud Datastore emulator that you can use for integration tests. The
datastoreinstance provides convenience methodsget_datastore_clientto connect to the emulator without having to set the environment variableDATASTORE_EMULATOR_HOST.>>> from testcontainers.community.google import DatastoreContainer >>> config = DatastoreContainer() >>> with config as datastore: ... datastore_client = datastore.get_datastore_client()
- class PubSubContainer(image: str = 'google/cloud-sdk:emulators', project: str = 'test-project', port: int = 8432, **kwargs)¶
PubSub container for testing managed message queues.
Example
The example will spin up a Google Cloud PubSub emulator that you can use for integration tests. The
pubsubinstance provides convenience methodsget_publisherandget_subscriberto connect to the emulator without having to set the environment variablePUBSUB_EMULATOR_HOST.>>> from testcontainers.community.google import PubSubContainer >>> config = PubSubContainer() >>> with config as pubsub: ... publisher = pubsub.get_publisher_client() ... topic_path = publisher.topic_path(pubsub.project, "my-topic") ... topic = publisher.create_topic(name=topic_path)