# 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:
```python
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'
```
Raw data
{
"_id": null,
"home_page": "https://github.com/coveooss/coveo-python-oss/tree/main/coveo-testing-extras",
"name": "coveo-testing-extras",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": null,
"author": "Jonathan Pich\u00e9",
"author_email": "tools@coveo.com",
"download_url": "https://files.pythonhosted.org/packages/48/79/c5b02be2f30ab8ecac922d7dc24855a4f6dd386fb236c357059140e85b61/coveo_testing_extras-2.1.12.tar.gz",
"platform": null,
"description": "# coveo-testing-extras\n\nContains extra testing tools without dependency restrictions.\n\n\n## temporary resource implementation: Docker Container\n\nThe docker container temporary resource can be used to prepare short-lived containers.\n\n- Supports building from a dockerfile\n- Supports pulling images\n- Can signal on AWS ECR logout\n- Dynamic port mapping retrieval\n- Saves log output before removing the container\n\n\n### Automatic AWS ECR login example\n\nHere's how you can enhance `TemporaryDockerContainerResource` with automatic ECR login:\n\n```python\nfrom base64 import b64decode\n\nimport boto3\nfrom coveo_testing_extras.temporary_resource.docker_container import (\n TemporaryDockerContainerResource, \n ECRLogoutException,\n get_docker_client\n)\n\nclass WithECR(TemporaryDockerContainerResource):\n def obtain_image(self) -> None:\n try:\n super().obtain_image()\n except ECRLogoutException:\n self._do_ecr_login()\n super().obtain_image()\n\n def _do_ecr_login(self) -> None:\n \"\"\" Performs an ecr login through awscli. \"\"\"\n assert self.ecr_region\n ecr = boto3.client('ecr')\n account_id, *_ = self.image_name.split('.')\n assert account_id.isdigit()\n authorization_data = ecr.get_authorization_token(registryIds=[account_id])['authorizationData'][0]\n username, password = b64decode(authorization_data['authorizationToken']).decode().split(':')\n with get_docker_client() as client:\n login = client.login(username=username, password=password, registry=authorization_data['proxyEndpoint'])\n assert login['Status'] == 'Login Succeeded'\n```\n\n\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "Dependency-hungry testing helpers",
"version": "2.1.12",
"project_urls": {
"Homepage": "https://github.com/coveooss/coveo-python-oss/tree/main/coveo-testing-extras",
"Repository": "https://github.com/coveooss/coveo-python-oss/tree/main/coveo-testing-extras"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "88b3812575d5b05a8709374f12591e0c2bf1a99eb6e711cba3a4f85bfeffebdc",
"md5": "18508853f23987a7a0dd2d89b7a3a16b",
"sha256": "e9442af18b1e0a16d9e242328583ef2a712700bf51acd8b25893644c8d335b28"
},
"downloads": -1,
"filename": "coveo_testing_extras-2.1.12-py3-none-any.whl",
"has_sig": false,
"md5_digest": "18508853f23987a7a0dd2d89b7a3a16b",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 5990,
"upload_time": "2024-05-27T11:39:11",
"upload_time_iso_8601": "2024-05-27T11:39:11.363549Z",
"url": "https://files.pythonhosted.org/packages/88/b3/812575d5b05a8709374f12591e0c2bf1a99eb6e711cba3a4f85bfeffebdc/coveo_testing_extras-2.1.12-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "4879c5b02be2f30ab8ecac922d7dc24855a4f6dd386fb236c357059140e85b61",
"md5": "27d3d71baf80b38559e5d3a5432dea68",
"sha256": "0b0bb61828162ad1287573d673695c395f2a0124966b61ae9ee6e9ead9e0b329"
},
"downloads": -1,
"filename": "coveo_testing_extras-2.1.12.tar.gz",
"has_sig": false,
"md5_digest": "27d3d71baf80b38559e5d3a5432dea68",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 5238,
"upload_time": "2024-05-27T11:39:12",
"upload_time_iso_8601": "2024-05-27T11:39:12.970502Z",
"url": "https://files.pythonhosted.org/packages/48/79/c5b02be2f30ab8ecac922d7dc24855a4f6dd386fb236c357059140e85b61/coveo_testing_extras-2.1.12.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-27 11:39:12",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "coveooss",
"github_project": "coveo-python-oss",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "coveo-testing-extras"
}