API Reference¶
- class testservices.service.T¶
The type of an object that represents a service
alias of TypeVar(‘T’)
- class testservices.service.Service¶
This is the basic thing that testservices manages. It often ends up representing a TCP port and some credential to connect to it, but, conceptually, can be anything from a piece of hardware to a simple file on disk.
- possible() bool¶
Returns
Trueif it’s possible to create this service or check if it already exists.
- class testservices.provider.T¶
The type of object returned by services in this
Provider.alias of TypeVar(‘T’)
- exception testservices.provider.NoAvailableService¶
- class testservices.provider.Provider(*services: Service[T])¶
This provides a single service from a selection of alternatives. The intention is to provide the first service that is
possiblein the current context,createit if doesn’t alreadyexistand then returnthe objectrepresenting it.
Databases¶
- class testservices.services.databases.Database(host: str, port: int | None, username: str, password: str | None, database: str | None, dialect: str | None = None, driver: str | None = None)¶
The credentials to connect to a database.
- class testservices.services.databases.DatabaseContainer(image: str, version: str, port: int, dialect: str, start_wait: float = 0.05, ready_phrases: Sequence[bytes] = (), ready_poll_wait: float = 0.01, ready_timeout: float = 5, driver: str | None = None, volumes: Dict[str, Dict[str, str]] | None = None, always_pull: bool = False, env: Dict[str, str] | None = None, name: str | None = None)¶
- class testservices.services.databases.PostgresContainer(image: str = 'docker.io/library/postgres', version: str = 'latest', driver: str = 'psycopg', always_pull: bool = False)¶
- class testservices.services.databases.MariadbContainer(image: str = 'docker.io/library/mariadb', version: str = 'latest', driver: str | None = None, always_pull: bool = False)¶
- class testservices.services.databases.ClickhouseContainer(image: str = 'docker.io/clickhouse/clickhouse-server', version: str = 'latest', driver: str | None = None, database: str | None = None, always_pull: bool = False)¶
- class testservices.services.databases.DatabaseFromEnvironment(url: str = 'DB_URL', *, check: bool = True, timeout: float = 5, poll_frequency: float = 0.05)¶
A
Databaseservice where the credentials are extracted from an environment variable.