coveo-testing-extras-2.1.2
توضیحات
Dependency-hungry testing helpers
| ویژگی | مقدار |
|---|---|
| سیستم عامل | - |
| نام فایل | coveo-testing-extras-2.1.2 |
| نام | coveo-testing-extras |
| نسخه کتابخانه | 2.1.2 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Jonathan Piché |
| ایمیل نویسنده | tools@coveo.com |
| آدرس صفحه اصلی | https://github.com/coveooss/coveo-python-oss/tree/main/coveo-testing-extras |
| آدرس اینترنتی | https://pypi.org/project/coveo-testing-extras/ |
| مجوز | Apache-2.0 |
# 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'
```
نیازمندی
| مقدار | نام |
|---|---|
| - | coveo-functools |
| - | coveo-settings |
| - | coveo-systools |
| - | coveo-testing |
| - | docker |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.8,<3.10 | Python |
نحوه نصب
نصب پکیج whl coveo-testing-extras-2.1.2:
pip install coveo-testing-extras-2.1.2.whl
نصب پکیج tar.gz coveo-testing-extras-2.1.2:
pip install coveo-testing-extras-2.1.2.tar.gz