In-Memory Provider
A cloud provider in memory, for tests and local development without a cloud account.
Its DNS zones, records and certificates are kept in memory, and behave like a cloud’s, so that tests exercise the service layer, and its signals, without reaching real infrastructure.
from smarter.apps.infrastructure.providers import configure_provider
from smarter.apps.infrastructure.providers.memory import InMemoryProvider
provider = InMemoryProvider()
configure_provider(lambda: provider)
provider.dns.add_zone("example.com")
provider.certificates.issue_all = True
provider.storage.objects # the private objects that were saved, by key
- class smarter.apps.infrastructure.providers.memory.InMemoryCertificateService(provider, dns, **kwargs)[source]
Bases:
CertificateServiceTLS certificates in memory, issued once their validation records exist, or at once with
issue_all.- issue_all
Issue every certificate, whether or not its validation records exist.
- class smarter.apps.infrastructure.providers.memory.InMemoryDNSService(provider, **kwargs)[source]
Bases:
DNSServiceDNS zones and records in memory.
- class smarter.apps.infrastructure.providers.memory.InMemoryProvider(ready=True, **kwargs)[source]
Bases:
CloudProviderA cloud provider in memory.
- Parameters:
ready (
bool) – Whether the provider is authenticated.
- property certificates: InMemoryCertificateService
The in-memory certificate service.
- cluster_health
The cluster’s health, or None for the one that
cluster_infodescribes.
- cluster_resources
The cloud resources of the cluster, by resource type, for the inventory.
- property dns: InMemoryDNSService
The in-memory DNS service.
- get_kubernetes_cluster_health()[source]
Return the cluster’s health that a test set in
cluster_health.Without one, it is built from
cluster_info, as the base class builds it.- Return type:
- Returns:
A copy of the health, so that a caller cannot change the test’s.
- Raises:
InfrastructureNotReadyError – If the provider is not ready.
- get_kubernetes_cluster_info()[source]
Return a copy of
cluster_info.- Return type:
- Returns:
The cluster’s description.
- Raises:
InfrastructureNotReadyError – If the provider is not ready.
- get_kubernetes_cluster_resources()[source]
Return a copy of
cluster_resources, which tests set.- Return type:
- Returns:
The cluster’s cloud resources, by resource type, or an empty dict if the provider is not ready.
- property identity: dict[str, Any] | None
A fake account identity, or None if the provider is not ready.
- name: str = 'memory'
The provider’s name, see
CloudProviders.
- property ready: bool
Whether the provider is ready, as set with the setter.
Records the authentication state, which sends a signal when it changes.
- property storage: InMemoryStorageService
The in-memory private object storage.
- class smarter.apps.infrastructure.providers.memory.InMemoryStorageService(provider, **kwargs)[source]
Bases:
StorageServicePrivate objects in memory, in
objects.Its presigned urls are fake: they name the object and when the url expires, but download nothing.
- fail
Set to make every operation fail with this error.
- objects
The objects, by key.