Skip to main content

Dependency-hungry testing helpers

Project description

coveo-testing-extras

Contains extra testing tools without dependency restrictions.

temporary resource implementation: Docker Container

The docker container temporary resource can be used to prepare short-lived containers.

  • Supports building from a dockerfile
  • Supports pulling images
  • Can signal on AWS ECR logout
  • Dynamic port mapping retrieval
  • Saves log output before removing the container

Automatic AWS ECR login example

Here's how you can enhance TemporaryDockerContainerResource with automatic ECR login:

from base64 import b64decode

import boto3
from coveo_testing_extras.temporary_resource.docker_container import (
    TemporaryDockerContainerResource, 
    ECRLogoutException,
    get_docker_client
)

class WithECR(TemporaryDockerContainerResource):
    def obtain_image(self) -> None:
        try:
            super().obtain_image()
        except ECRLogoutException:
            self._do_ecr_login()
            super().obtain_image()

    def _do_ecr_login(self) -> None:
        """ Performs an ecr login through awscli. """
        assert self.ecr_region
        ecr = boto3.client('ecr')
        account_id, *_ = self.image_name.split('.')
        assert account_id.isdigit()
        authorization_data = ecr.get_authorization_token(registryIds=[account_id])['authorizationData'][0]
        username, password = b64decode(authorization_data['authorizationToken']).decode().split(':')
        with get_docker_client() as client:
            login = client.login(username=username, password=password, registry=authorization_data['proxyEndpoint'])
        assert login['Status'] == 'Login Succeeded'

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

coveo_testing_extras-3.0.2.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

coveo_testing_extras-3.0.2-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file coveo_testing_extras-3.0.2.tar.gz.

File metadata

  • Download URL: coveo_testing_extras-3.0.2.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.9.25 Linux/6.8.0-1041-azure

File hashes

Hashes for coveo_testing_extras-3.0.2.tar.gz
Algorithm Hash digest
SHA256 d6c62686fef179be8dfbbc1adf36462eb70760c9a713e2bbfca0711700cfe118
MD5 777b2f9623e515c30309632065698794
BLAKE2b-256 03e0c940384532add1379e95553da33a0f75238ac85f74a3df016346b17f0e2f

See more details on using hashes here.

File details

Details for the file coveo_testing_extras-3.0.2-py3-none-any.whl.

File metadata

  • Download URL: coveo_testing_extras-3.0.2-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.9.25 Linux/6.8.0-1041-azure

File hashes

Hashes for coveo_testing_extras-3.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 aa41d369cbcb5025f1fe2f37e8f9d86b28fe28aa4f1917847072408e3ff196fe
MD5 ab3dd0923602aa6e451d58864703f9ef
BLAKE2b-256 8c29059f0ef03f0f29b9c3198a530c935d081bae1b6c3adeb34f9233b98922cf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page