From 5d5f64b3b42f21d3d5b0e44cdde2aa4f497a9796 Mon Sep 17 00:00:00 2001 From: bstrausser Date: Thu, 29 Feb 2024 10:38:47 -0500 Subject: [PATCH 01/10] Adds AsyncRedis support --- .../redis/testcontainers/redis/__init__.py | 32 ++++++++++ modules/redis/tests/test_redis.py | 63 ++++++++++++++++++- poetry.lock | 42 ++++++++++++- pyproject.toml | 1 + 4 files changed, 133 insertions(+), 5 deletions(-) diff --git a/modules/redis/testcontainers/redis/__init__.py b/modules/redis/testcontainers/redis/__init__.py index fba24be15..498e68a05 100644 --- a/modules/redis/testcontainers/redis/__init__.py +++ b/modules/redis/testcontainers/redis/__init__.py @@ -14,6 +14,7 @@ from typing import Optional import redis +from redis.asyncio import Redis as asyncRedis from testcontainers.core.container import DockerContainer from testcontainers.core.utils import raise_for_deprecated_parameter from testcontainers.core.waiting_utils import wait_container_is_ready @@ -69,3 +70,34 @@ def start(self) -> "RedisContainer": super().start() self._connect() return self + + + +class AsyncRedisContainer(RedisContainer): + """ + Redis container. + + Example + ------- + .. doctest:: + + >>> from testcontainers.redis import AsyncRedisContainer + + >>> with AsyncRedisContainer() as redis_container: + ... redis_client =await redis_container.get_async_client() + """ + + def __init__( + self, image="redis:latest", port_to_expose=6379, password=None, **kwargs + ): + super(AsyncRedisContainer, self).__init__( + image, port_to_expose, password, **kwargs + ) + + async def get_async_client(self, **kwargs): + return await asyncRedis( + host=self.get_container_host_ip(), + port=self.get_exposed_port(self.port), + password=self.password, + **kwargs, + ) diff --git a/modules/redis/tests/test_redis.py b/modules/redis/tests/test_redis.py index 7dc56aa46..b05a81674 100644 --- a/modules/redis/tests/test_redis.py +++ b/modules/redis/tests/test_redis.py @@ -1,6 +1,10 @@ import time -from testcontainers.redis import RedisContainer +from testcontainers.redis import RedisContainer, AsyncRedisContainer +import redis +import pytest + + def test_docker_run_redis(): @@ -22,6 +26,61 @@ def test_docker_run_redis_with_password(): client.set("hello", "world") assert client.get("hello") == "world" +pytest.mark.usefixtures('anyio_backend') +@pytest.mark.parametrize('anyio_backend', ['asyncio']) +async def test_key_set_in_async_redis(anyio_backend): + with AsyncRedisContainer() as container: + async_redis_client: redis.Redis = await container.get_async_client( + decode_responses=True + ) + key = "key" + expected_value = 1 + await async_redis_client.set(key, expected_value) + actual_value = await async_redis_client.get(key) + assert int(actual_value) == expected_value + +pytest.mark.usefixtures('anyio_backend') +@pytest.mark.parametrize('anyio_backend', ['asyncio']) +@pytest.mark.skip(reason="Need to sort out async pub/sub") +async def test_docker_run_async_redis(anyio_backend): + config = AsyncRedisContainer() + with config as container: + client: redis.Redis = await container.get_async_client( + decode_responses=True + ) + p = await client.pubsub() + await p.subscribe("test") + await client.publish("test", "new_msg") + msg = wait_for_message(p) + assert "data" in msg + assert b"new_msg", msg["data"] + +pytest.mark.usefixtures('anyio_backend') +@pytest.mark.parametrize('anyio_backend', ['asyncio']) +async def test_docker_run_async_redis_with_password(anyio_backend): + config = AsyncRedisContainer(password="mypass") + with config as container: + client: redis.Redis = await container.get_async_client( + decode_responses=True + ) + await client.set("hello", "world") + assert await client.get("hello") == "world" + + + +pytest.mark.usefixtures('anyio_backend') +@pytest.mark.parametrize('anyio_backend', ['asyncio']) +async def test_key_set_in_async(anyio_backend): + with AsyncRedisContainer() as container: + async_redis_client: redis.Redis = await container.get_async_client( + decode_responses=True + ) + key = "key" + expected_value = 1 + await async_redis_client.set(key, expected_value) + actual_value = await async_redis_client.get(key) + assert int(actual_value) == expected_value + def wait_for_message(pubsub, timeout=1, ignore_subscribe_messages=True): now = time.time() @@ -32,4 +91,4 @@ def wait_for_message(pubsub, timeout=1, ignore_subscribe_messages=True): return message time.sleep(0.01) now = time.time() - return None + return None \ No newline at end of file diff --git a/poetry.lock b/poetry.lock index 5cf56c8cb..d728a3191 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.7.0 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.1 and should not be changed by hand. [[package]] name = "alabaster" @@ -11,6 +11,28 @@ files = [ {file = "alabaster-0.7.16.tar.gz", hash = "sha256:75a8b99c28a5dad50dd7f8ccdd447a121ddb3892da9e53d1ca5cca3106d58d65"}, ] +[[package]] +name = "anyio" +version = "4.3.0" +description = "High level compatibility layer for multiple asynchronous event loop implementations" +optional = false +python-versions = ">=3.8" +files = [ + {file = "anyio-4.3.0-py3-none-any.whl", hash = "sha256:048e05d0f6caeed70d731f3db756d35dcc1f35747c8c403364a8332c630441b8"}, + {file = "anyio-4.3.0.tar.gz", hash = "sha256:f75253795a87df48568485fd18cdd2a3fa5c4f7c5be8e5e36637733fce06fed6"}, +] + +[package.dependencies] +exceptiongroup = {version = ">=1.0.2", markers = "python_version < \"3.11\""} +idna = ">=2.8" +sniffio = ">=1.1" +typing-extensions = {version = ">=4.1", markers = "python_version < \"3.11\""} + +[package.extras] +doc = ["Sphinx (>=7)", "packaging", "sphinx-autodoc-typehints (>=1.2.0)", "sphinx-rtd-theme"] +test = ["anyio[trio]", "coverage[toml] (>=7)", "exceptiongroup (>=1.2.0)", "hypothesis (>=4.0)", "psutil (>=5.9)", "pytest (>=7.0)", "pytest-mock (>=3.6.1)", "trustme", "uvloop (>=0.17)"] +trio = ["trio (>=0.23)"] + [[package]] name = "argon2-cffi" version = "23.1.0" @@ -1655,6 +1677,7 @@ files = [ {file = "psycopg2_binary-2.9.9-cp311-cp311-win32.whl", hash = "sha256:dc4926288b2a3e9fd7b50dc6a1909a13bbdadfc67d93f3374d984e56f885579d"}, {file = "psycopg2_binary-2.9.9-cp311-cp311-win_amd64.whl", hash = "sha256:b76bedd166805480ab069612119ea636f5ab8f8771e640ae103e05a4aae3e417"}, {file = "psycopg2_binary-2.9.9-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:8532fd6e6e2dc57bcb3bc90b079c60de896d2128c5d9d6f24a63875a95a088cf"}, + {file = "psycopg2_binary-2.9.9-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:b0605eaed3eb239e87df0d5e3c6489daae3f7388d455d0c0b4df899519c6a38d"}, {file = "psycopg2_binary-2.9.9-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8f8544b092a29a6ddd72f3556a9fcf249ec412e10ad28be6a0c0d948924f2212"}, {file = "psycopg2_binary-2.9.9-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:2d423c8d8a3c82d08fe8af900ad5b613ce3632a1249fd6a223941d0735fce493"}, {file = "psycopg2_binary-2.9.9-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:2e5afae772c00980525f6d6ecf7cbca55676296b580c0e6abb407f15f3706996"}, @@ -1663,6 +1686,8 @@ files = [ {file = "psycopg2_binary-2.9.9-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:cb16c65dcb648d0a43a2521f2f0a2300f40639f6f8c1ecbc662141e4e3e1ee07"}, {file = "psycopg2_binary-2.9.9-cp312-cp312-musllinux_1_1_ppc64le.whl", hash = "sha256:911dda9c487075abd54e644ccdf5e5c16773470a6a5d3826fda76699410066fb"}, {file = "psycopg2_binary-2.9.9-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:57fede879f08d23c85140a360c6a77709113efd1c993923c59fde17aa27599fe"}, + {file = "psycopg2_binary-2.9.9-cp312-cp312-win32.whl", hash = "sha256:64cf30263844fa208851ebb13b0732ce674d8ec6a0c86a4e160495d299ba3c93"}, + {file = "psycopg2_binary-2.9.9-cp312-cp312-win_amd64.whl", hash = "sha256:81ff62668af011f9a48787564ab7eded4e9fb17a4a6a74af5ffa6a457400d2ab"}, {file = "psycopg2_binary-2.9.9-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:2293b001e319ab0d869d660a704942c9e2cce19745262a8aba2115ef41a0a42a"}, {file = "psycopg2_binary-2.9.9-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:03ef7df18daf2c4c07e2695e8cfd5ee7f748a1d54d802330985a78d2a5a6dca9"}, {file = "psycopg2_binary-2.9.9-cp37-cp37m-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:0a602ea5aff39bb9fac6308e9c9d82b9a35c2bf288e184a816002c9fae930b77"}, @@ -2194,6 +2219,7 @@ files = [ {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:69b023b2b4daa7548bcfbd4aa3da05b3a74b772db9e23b982788168117739938"}, {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:81e0b275a9ecc9c0c0c07b4b90ba548307583c125f54d5b6946cfee6360c733d"}, {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ba336e390cd8e4d1739f42dfe9bb83a3cc2e80f567d8805e11b46f4a943f5515"}, + {file = "PyYAML-6.0.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:326c013efe8048858a6d312ddd31d56e468118ad4cdeda36c719bf5bb6192290"}, {file = "PyYAML-6.0.1-cp310-cp310-win32.whl", hash = "sha256:bd4af7373a854424dabd882decdc5579653d7868b8fb26dc7d0e99f823aa5924"}, {file = "PyYAML-6.0.1-cp310-cp310-win_amd64.whl", hash = "sha256:fd1592b3fdf65fff2ad0004b5e363300ef59ced41c2e6b3a99d4089fa8c5435d"}, {file = "PyYAML-6.0.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:6965a7bc3cf88e5a1c3bd2e0b5c22f8d677dc88a455344035f03399034eb3007"}, @@ -2201,8 +2227,16 @@ files = [ {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:42f8152b8dbc4fe7d96729ec2b99c7097d656dc1213a3229ca5383f973a5ed6d"}, {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:062582fca9fabdd2c8b54a3ef1c978d786e0f6b3a1510e0ac93ef59e0ddae2bc"}, {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d2b04aac4d386b172d5b9692e2d2da8de7bfb6c387fa4f801fbf6fb2e6ba4673"}, + {file = "PyYAML-6.0.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:e7d73685e87afe9f3b36c799222440d6cf362062f78be1013661b00c5c6f678b"}, {file = "PyYAML-6.0.1-cp311-cp311-win32.whl", hash = "sha256:1635fd110e8d85d55237ab316b5b011de701ea0f29d07611174a1b42f1444741"}, {file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"}, + {file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"}, + {file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"}, + {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a08c6f0fe150303c1c6b71ebcd7213c2858041a7e01975da3a99aed1e7a378ef"}, + {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"}, + {file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"}, + {file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"}, + {file = "PyYAML-6.0.1-cp312-cp312-win_amd64.whl", hash = "sha256:0d3304d8c0adc42be59c5f8a4d9e3d7379e6955ad754aa9d6ab7a398b59dd1df"}, {file = "PyYAML-6.0.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:50550eb667afee136e9a77d6dc71ae76a44df8b3e51e41b77f6de2932bfe0f47"}, {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1fe35611261b29bd1de0070f0b2f47cb6ff71fa6595c077e42bd0c419fa27b98"}, {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:704219a11b772aea0d8ecd7058d0082713c3562b4e271b849ad7dc4a5c90c13c"}, @@ -2219,6 +2253,7 @@ files = [ {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a0cd17c15d3bb3fa06978b4e8958dcdc6e0174ccea823003a106c7d4d7899ac5"}, {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:28c119d996beec18c05208a8bd78cbe4007878c6dd15091efb73a30e90539696"}, {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7e07cbde391ba96ab58e532ff4803f79c4129397514e1413a7dc761ccd755735"}, + {file = "PyYAML-6.0.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:49a183be227561de579b4a36efbb21b3eab9651dd81b1858589f796549873dd6"}, {file = "PyYAML-6.0.1-cp38-cp38-win32.whl", hash = "sha256:184c5108a2aca3c5b3d3bf9395d50893a7ab82a38004c8f61c258d4428e80206"}, {file = "PyYAML-6.0.1-cp38-cp38-win_amd64.whl", hash = "sha256:1e2722cc9fbb45d9b87631ac70924c11d3a401b2d7f410cc0e3bbf249f2dca62"}, {file = "PyYAML-6.0.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:9eb6caa9a297fc2c2fb8862bc5370d0303ddba53ba97e71f08023b6cd73d16a8"}, @@ -2226,6 +2261,7 @@ files = [ {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5773183b6446b2c99bb77e77595dd486303b4faab2b086e7b17bc6bef28865f6"}, {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b786eecbdf8499b9ca1d697215862083bd6d2a99965554781d0d8d1ad31e13a0"}, {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bc1bf2925a1ecd43da378f4db9e4f799775d6367bdb94671027b73b393a7c42c"}, + {file = "PyYAML-6.0.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:04ac92ad1925b2cff1db0cfebffb6ffc43457495c9b3c39d3fcae417d7125dc5"}, {file = "PyYAML-6.0.1-cp39-cp39-win32.whl", hash = "sha256:faca3bdcf85b2fc05d06ff3fbc1f83e1391b3e724afa3feba7d13eeab355484c"}, {file = "PyYAML-6.0.1-cp39-cp39-win_amd64.whl", hash = "sha256:510c9deebc5c0225e8c96813043e62b680ba2f9c50a08d3724c7f28a747d1486"}, {file = "PyYAML-6.0.1.tar.gz", hash = "sha256:bfdf460b1736c775f2ba9f6a92bca30bc2095067b8a9d77876d1fad6cc3b4a43"}, @@ -2462,7 +2498,7 @@ files = [ name = "sniffio" version = "1.3.0" description = "Sniff out which async library your code is running under" -optional = true +optional = false python-versions = ">=3.7" files = [ {file = "sniffio-1.3.0-py3-none-any.whl", hash = "sha256:eecefdce1e5bbfb7ad2eeaabf7c1eeb404d7757c379bd1f7e5cce9d8bf425384"}, @@ -3004,4 +3040,4 @@ selenium = ["selenium"] [metadata] lock-version = "2.0" python-versions = ">=3.9,<4.0" -content-hash = "0316bbdbb2824f6086c32cb9ed00a23507896bf48494a38d086e281faf1f8189" +content-hash = "bad8d37b2f1eeda277e29edd10db3bb1c7848ec29cf20375fccb1f308b460fbf" diff --git a/pyproject.toml b/pyproject.toml index 2059926c9..508d9329b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -83,6 +83,7 @@ psycopg2-binary = { version = "*", optional = true } pika = { version = "*", optional = true } redis = { version = "*", optional = true } selenium = { version = "*", optional = true } +anyio = "^4.3.0" [tool.poetry.extras] arangodb = ["python-arango"] From fb5c24d2c1310ca9ac9e1ca6cea643efd2529286 Mon Sep 17 00:00:00 2001 From: bstrausser Date: Thu, 29 Feb 2024 11:48:49 -0500 Subject: [PATCH 02/10] Fix super call --- modules/redis/testcontainers/redis/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/redis/testcontainers/redis/__init__.py b/modules/redis/testcontainers/redis/__init__.py index 498e68a05..6ee9ca7f6 100644 --- a/modules/redis/testcontainers/redis/__init__.py +++ b/modules/redis/testcontainers/redis/__init__.py @@ -90,7 +90,7 @@ class AsyncRedisContainer(RedisContainer): def __init__( self, image="redis:latest", port_to_expose=6379, password=None, **kwargs ): - super(AsyncRedisContainer, self).__init__( + super().__init__( image, port_to_expose, password, **kwargs ) From 43d69f11f9c55aa77ca1e6efc393d80c23515c45 Mon Sep 17 00:00:00 2001 From: bstrausser Date: Thu, 29 Feb 2024 14:54:23 -0500 Subject: [PATCH 03/10] Loosen python version on precommit so make lint works --- .pre-commit-config.yaml | 2 +- .../redis/testcontainers/redis/__init__.py | 9 +- modules/redis/tests/test_redis.py | 72 +++++----- poetry.lock | 125 +++++++++++++++++- pyproject.toml | 1 + 5 files changed, 162 insertions(+), 47 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0d2a53b63..a960cc85e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,5 +1,5 @@ default_language_version: - python: python3.9 + python: python3 repos: - repo: https://github.com/pre-commit/pre-commit-hooks diff --git a/modules/redis/testcontainers/redis/__init__.py b/modules/redis/testcontainers/redis/__init__.py index 6ee9ca7f6..7a4d46613 100644 --- a/modules/redis/testcontainers/redis/__init__.py +++ b/modules/redis/testcontainers/redis/__init__.py @@ -72,7 +72,6 @@ def start(self) -> "RedisContainer": return self - class AsyncRedisContainer(RedisContainer): """ Redis container. @@ -87,12 +86,8 @@ class AsyncRedisContainer(RedisContainer): ... redis_client =await redis_container.get_async_client() """ - def __init__( - self, image="redis:latest", port_to_expose=6379, password=None, **kwargs - ): - super().__init__( - image, port_to_expose, password, **kwargs - ) + def __init__(self, image="redis:latest", port_to_expose=6379, password=None, **kwargs): + super().__init__(image, port_to_expose, password, **kwargs) async def get_async_client(self, **kwargs): return await asyncRedis( diff --git a/modules/redis/tests/test_redis.py b/modules/redis/tests/test_redis.py index b05a81674..24926d0ba 100644 --- a/modules/redis/tests/test_redis.py +++ b/modules/redis/tests/test_redis.py @@ -5,8 +5,6 @@ import pytest - - def test_docker_run_redis(): config = RedisContainer() with config as redis: @@ -26,28 +24,30 @@ def test_docker_run_redis_with_password(): client.set("hello", "world") assert client.get("hello") == "world" -pytest.mark.usefixtures('anyio_backend') -@pytest.mark.parametrize('anyio_backend', ['asyncio']) + +pytest.mark.usefixtures("anyio_backend") + + +@pytest.mark.parametrize("anyio_backend", ["asyncio"]) async def test_key_set_in_async_redis(anyio_backend): - with AsyncRedisContainer() as container: - async_redis_client: redis.Redis = await container.get_async_client( - decode_responses=True - ) - key = "key" - expected_value = 1 - await async_redis_client.set(key, expected_value) - actual_value = await async_redis_client.get(key) - assert int(actual_value) == expected_value - -pytest.mark.usefixtures('anyio_backend') -@pytest.mark.parametrize('anyio_backend', ['asyncio']) + with AsyncRedisContainer() as container: + async_redis_client: redis.Redis = await container.get_async_client(decode_responses=True) + key = "key" + expected_value = 1 + await async_redis_client.set(key, expected_value) + actual_value = await async_redis_client.get(key) + assert int(actual_value) == expected_value + + +pytest.mark.usefixtures("anyio_backend") + + +@pytest.mark.parametrize("anyio_backend", ["asyncio"]) @pytest.mark.skip(reason="Need to sort out async pub/sub") async def test_docker_run_async_redis(anyio_backend): config = AsyncRedisContainer() with config as container: - client: redis.Redis = await container.get_async_client( - decode_responses=True - ) + client: redis.Redis = await container.get_async_client(decode_responses=True) p = await client.pubsub() await p.subscribe("test") await client.publish("test", "new_msg") @@ -55,31 +55,31 @@ async def test_docker_run_async_redis(anyio_backend): assert "data" in msg assert b"new_msg", msg["data"] -pytest.mark.usefixtures('anyio_backend') -@pytest.mark.parametrize('anyio_backend', ['asyncio']) + +pytest.mark.usefixtures("anyio_backend") + + +@pytest.mark.parametrize("anyio_backend", ["asyncio"]) async def test_docker_run_async_redis_with_password(anyio_backend): config = AsyncRedisContainer(password="mypass") with config as container: - client: redis.Redis = await container.get_async_client( - decode_responses=True - ) + client: redis.Redis = await container.get_async_client(decode_responses=True) await client.set("hello", "world") assert await client.get("hello") == "world" +pytest.mark.usefixtures("anyio_backend") + -pytest.mark.usefixtures('anyio_backend') -@pytest.mark.parametrize('anyio_backend', ['asyncio']) +@pytest.mark.parametrize("anyio_backend", ["asyncio"]) async def test_key_set_in_async(anyio_backend): - with AsyncRedisContainer() as container: - async_redis_client: redis.Redis = await container.get_async_client( - decode_responses=True - ) - key = "key" - expected_value = 1 - await async_redis_client.set(key, expected_value) - actual_value = await async_redis_client.get(key) - assert int(actual_value) == expected_value + with AsyncRedisContainer() as container: + async_redis_client: redis.Redis = await container.get_async_client(decode_responses=True) + key = "key" + expected_value = 1 + await async_redis_client.set(key, expected_value) + actual_value = await async_redis_client.get(key) + assert int(actual_value) == expected_value def wait_for_message(pubsub, timeout=1, ignore_subscribe_messages=True): @@ -91,4 +91,4 @@ def wait_for_message(pubsub, timeout=1, ignore_subscribe_messages=True): return message time.sleep(0.01) now = time.time() - return None \ No newline at end of file + return None diff --git a/poetry.lock b/poetry.lock index d728a3191..7bfb26f62 100644 --- a/poetry.lock +++ b/poetry.lock @@ -311,6 +311,17 @@ files = [ [package.dependencies] pycparser = "*" +[[package]] +name = "cfgv" +version = "3.4.0" +description = "Validate configuration and produce human readable error messages." +optional = false +python-versions = ">=3.8" +files = [ + {file = "cfgv-3.4.0-py2.py3-none-any.whl", hash = "sha256:b7265b1f29fd3316bfcd2b330d63d024f2bfd8bcb8b0272f8e19a504856c48f9"}, + {file = "cfgv-3.4.0.tar.gz", hash = "sha256:e52591d4c5f5dead8e0f673fb16db7949d2cfb3f7da4582893288f0ded8fe560"}, +] + [[package]] name = "charset-normalizer" version = "3.3.2" @@ -698,6 +709,17 @@ files = [ [package.dependencies] packaging = "*" +[[package]] +name = "distlib" +version = "0.3.8" +description = "Distribution utilities" +optional = false +python-versions = "*" +files = [ + {file = "distlib-0.3.8-py2.py3-none-any.whl", hash = "sha256:034db59a0b96f8ca18035f36290806a9a6e6bd9d1ff91e45a7f172eb17e51784"}, + {file = "distlib-0.3.8.tar.gz", hash = "sha256:1530ea13e350031b6312d8580ddb6b27a104275a31106523b8f123787f494f64"}, +] + [[package]] name = "dnspython" version = "2.5.0" @@ -782,6 +804,22 @@ files = [ [package.extras] test = ["pytest (>=6)"] +[[package]] +name = "filelock" +version = "3.13.1" +description = "A platform independent file lock." +optional = false +python-versions = ">=3.8" +files = [ + {file = "filelock-3.13.1-py3-none-any.whl", hash = "sha256:57dbda9b35157b05fb3e58ee91448612eb674172fab98ee235ccb0b5bee19a1c"}, + {file = "filelock-3.13.1.tar.gz", hash = "sha256:521f5f56c50f8426f5e03ad3b281b490a87ef15bc6c526f168290f0c7148d44e"}, +] + +[package.extras] +docs = ["furo (>=2023.9.10)", "sphinx (>=7.2.6)", "sphinx-autodoc-typehints (>=1.24)"] +testing = ["covdefaults (>=2.3)", "coverage (>=7.3.2)", "diff-cover (>=8)", "pytest (>=7.4.3)", "pytest-cov (>=4.1)", "pytest-mock (>=3.12)", "pytest-timeout (>=2.2)"] +typing = ["typing-extensions (>=4.8)"] + [[package]] name = "google-api-core" version = "2.15.0" @@ -1058,6 +1096,20 @@ files = [ {file = "h11-0.14.0.tar.gz", hash = "sha256:8f19fbbe99e72420ff35c00b27a34cb9937e902a8b810e2c88300c6f0a3b699d"}, ] +[[package]] +name = "identify" +version = "2.5.35" +description = "File identification library for Python" +optional = false +python-versions = ">=3.8" +files = [ + {file = "identify-2.5.35-py2.py3-none-any.whl", hash = "sha256:c4de0081837b211594f8e877a6b4fad7ca32bbfc1a9307fdd61c28bfe923f13e"}, + {file = "identify-2.5.35.tar.gz", hash = "sha256:10a7ca245cfcd756a554a7288159f72ff105ad233c7c4b9c6f0f4d108f5f6791"}, +] + +[package.extras] +license = ["ukkonen"] + [[package]] name = "idna" version = "3.6" @@ -1482,6 +1534,20 @@ files = [ {file = "nh3-0.2.15.tar.gz", hash = "sha256:d1e30ff2d8d58fb2a14961f7aac1bbb1c51f9bdd7da727be35c63826060b0bf3"}, ] +[[package]] +name = "nodeenv" +version = "1.8.0" +description = "Node.js virtual environment builder" +optional = false +python-versions = ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*" +files = [ + {file = "nodeenv-1.8.0-py2.py3-none-any.whl", hash = "sha256:df865724bb3c3adc86b3876fa209771517b0cfe596beff01a92700e0e8be4cec"}, + {file = "nodeenv-1.8.0.tar.gz", hash = "sha256:d51e0c37e64fbf47d017feac3145cdbb58836d7eee8c6f6d3b6880c5456227d2"}, +] + +[package.dependencies] +setuptools = "*" + [[package]] name = "oauthlib" version = "3.2.2" @@ -1592,6 +1658,21 @@ files = [ [package.extras] testing = ["pytest", "pytest-cov"] +[[package]] +name = "platformdirs" +version = "4.2.0" +description = "A small Python package for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." +optional = false +python-versions = ">=3.8" +files = [ + {file = "platformdirs-4.2.0-py3-none-any.whl", hash = "sha256:0614df2a2f37e1a662acbd8e2b25b92ccf8632929bc6d43467e17fe89c75e068"}, + {file = "platformdirs-4.2.0.tar.gz", hash = "sha256:ef0cc731df711022c174543cb70a9b5bd22e5a9337c8624ef2c2ceb8ddad8768"}, +] + +[package.extras] +docs = ["furo (>=2023.9.10)", "proselint (>=0.13)", "sphinx (>=7.2.6)", "sphinx-autodoc-typehints (>=1.25.2)"] +test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=7.4.3)", "pytest-cov (>=4.1)", "pytest-mock (>=3.12)"] + [[package]] name = "pluggy" version = "1.4.0" @@ -1607,6 +1688,24 @@ files = [ dev = ["pre-commit", "tox"] testing = ["pytest", "pytest-benchmark"] +[[package]] +name = "pre-commit" +version = "3.6.2" +description = "A framework for managing and maintaining multi-language pre-commit hooks." +optional = false +python-versions = ">=3.9" +files = [ + {file = "pre_commit-3.6.2-py2.py3-none-any.whl", hash = "sha256:ba637c2d7a670c10daedc059f5c49b5bd0aadbccfcd7ec15592cf9665117532c"}, + {file = "pre_commit-3.6.2.tar.gz", hash = "sha256:c3ef34f463045c88658c5b99f38c1e297abdcc0ff13f98d3370055fbbfabc67e"}, +] + +[package.dependencies] +cfgv = ">=2.0.0" +identify = ">=1.0.0" +nodeenv = ">=0.11.1" +pyyaml = ">=5.1" +virtualenv = ">=20.10.0" + [[package]] name = "proto-plus" version = "1.23.0" @@ -2211,7 +2310,7 @@ files = [ name = "pyyaml" version = "6.0.1" description = "YAML parser and emitter for Python" -optional = true +optional = false python-versions = ">=3.6" files = [ {file = "PyYAML-6.0.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d858aa552c999bc8a8d57426ed01e40bef403cd8ccdd0fc5f6f04a00414cac2a"}, @@ -2471,7 +2570,7 @@ urllib3 = {version = ">=1.26,<3", extras = ["socks"]} name = "setuptools" version = "69.0.3" description = "Easily download, build, install, upgrade, and uninstall Python packages" -optional = true +optional = false python-versions = ">=3.8" files = [ {file = "setuptools-69.0.3-py3-none-any.whl", hash = "sha256:385eb4edd9c9d5c17540511303e39a147ce2fc04bc55289c322b9e5904fe2c05"}, @@ -2890,6 +2989,26 @@ secure = ["certifi", "cryptography (>=1.9)", "idna (>=2.0.0)", "pyopenssl (>=17. socks = ["pysocks (>=1.5.6,!=1.5.7,<2.0)"] zstd = ["zstandard (>=0.18.0)"] +[[package]] +name = "virtualenv" +version = "20.25.1" +description = "Virtual Python Environment builder" +optional = false +python-versions = ">=3.7" +files = [ + {file = "virtualenv-20.25.1-py3-none-any.whl", hash = "sha256:961c026ac520bac5f69acb8ea063e8a4f071bcc9457b9c1f28f6b085c511583a"}, + {file = "virtualenv-20.25.1.tar.gz", hash = "sha256:e08e13ecdca7a0bd53798f356d5831434afa5b07b93f0abdf0797b7a06ffe197"}, +] + +[package.dependencies] +distlib = ">=0.3.7,<1" +filelock = ">=3.12.2,<4" +platformdirs = ">=3.9.1,<5" + +[package.extras] +docs = ["furo (>=2023.7.26)", "proselint (>=0.13)", "sphinx (>=7.1.2)", "sphinx-argparse (>=0.4)", "sphinxcontrib-towncrier (>=0.2.1a0)", "towncrier (>=23.6)"] +test = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "coverage-enable-subprocess (>=1)", "flaky (>=3.7)", "packaging (>=23.1)", "pytest (>=7.4)", "pytest-env (>=0.8.2)", "pytest-freezer (>=0.4.8)", "pytest-mock (>=3.11.1)", "pytest-randomly (>=3.12)", "pytest-timeout (>=2.1)", "setuptools (>=68)", "time-machine (>=2.10)"] + [[package]] name = "websocket-client" version = "1.7.0" @@ -3040,4 +3159,4 @@ selenium = ["selenium"] [metadata] lock-version = "2.0" python-versions = ">=3.9,<4.0" -content-hash = "bad8d37b2f1eeda277e29edd10db3bb1c7848ec29cf20375fccb1f308b460fbf" +content-hash = "3d53d9cf801104ed0e1d830d658059c789f7ab8d81e9206027528611dd0866ac" diff --git a/pyproject.toml b/pyproject.toml index 508d9329b..70b14d123 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -84,6 +84,7 @@ pika = { version = "*", optional = true } redis = { version = "*", optional = true } selenium = { version = "*", optional = true } anyio = "^4.3.0" +pre-commit = "^3.6.2" [tool.poetry.extras] arangodb = ["python-arango"] From b380c4fea3c540ca4291cd74b977fdabba74ae43 Mon Sep 17 00:00:00 2001 From: bstrausser Date: Fri, 1 Mar 2024 19:32:45 -0500 Subject: [PATCH 04/10] Fix dependencies --- poetry.lock | 125 ++----------------------------------------------- pyproject.toml | 3 +- 2 files changed, 4 insertions(+), 124 deletions(-) diff --git a/poetry.lock b/poetry.lock index 7bfb26f62..9e6ea1b78 100644 --- a/poetry.lock +++ b/poetry.lock @@ -311,17 +311,6 @@ files = [ [package.dependencies] pycparser = "*" -[[package]] -name = "cfgv" -version = "3.4.0" -description = "Validate configuration and produce human readable error messages." -optional = false -python-versions = ">=3.8" -files = [ - {file = "cfgv-3.4.0-py2.py3-none-any.whl", hash = "sha256:b7265b1f29fd3316bfcd2b330d63d024f2bfd8bcb8b0272f8e19a504856c48f9"}, - {file = "cfgv-3.4.0.tar.gz", hash = "sha256:e52591d4c5f5dead8e0f673fb16db7949d2cfb3f7da4582893288f0ded8fe560"}, -] - [[package]] name = "charset-normalizer" version = "3.3.2" @@ -709,17 +698,6 @@ files = [ [package.dependencies] packaging = "*" -[[package]] -name = "distlib" -version = "0.3.8" -description = "Distribution utilities" -optional = false -python-versions = "*" -files = [ - {file = "distlib-0.3.8-py2.py3-none-any.whl", hash = "sha256:034db59a0b96f8ca18035f36290806a9a6e6bd9d1ff91e45a7f172eb17e51784"}, - {file = "distlib-0.3.8.tar.gz", hash = "sha256:1530ea13e350031b6312d8580ddb6b27a104275a31106523b8f123787f494f64"}, -] - [[package]] name = "dnspython" version = "2.5.0" @@ -804,22 +782,6 @@ files = [ [package.extras] test = ["pytest (>=6)"] -[[package]] -name = "filelock" -version = "3.13.1" -description = "A platform independent file lock." -optional = false -python-versions = ">=3.8" -files = [ - {file = "filelock-3.13.1-py3-none-any.whl", hash = "sha256:57dbda9b35157b05fb3e58ee91448612eb674172fab98ee235ccb0b5bee19a1c"}, - {file = "filelock-3.13.1.tar.gz", hash = "sha256:521f5f56c50f8426f5e03ad3b281b490a87ef15bc6c526f168290f0c7148d44e"}, -] - -[package.extras] -docs = ["furo (>=2023.9.10)", "sphinx (>=7.2.6)", "sphinx-autodoc-typehints (>=1.24)"] -testing = ["covdefaults (>=2.3)", "coverage (>=7.3.2)", "diff-cover (>=8)", "pytest (>=7.4.3)", "pytest-cov (>=4.1)", "pytest-mock (>=3.12)", "pytest-timeout (>=2.2)"] -typing = ["typing-extensions (>=4.8)"] - [[package]] name = "google-api-core" version = "2.15.0" @@ -1096,20 +1058,6 @@ files = [ {file = "h11-0.14.0.tar.gz", hash = "sha256:8f19fbbe99e72420ff35c00b27a34cb9937e902a8b810e2c88300c6f0a3b699d"}, ] -[[package]] -name = "identify" -version = "2.5.35" -description = "File identification library for Python" -optional = false -python-versions = ">=3.8" -files = [ - {file = "identify-2.5.35-py2.py3-none-any.whl", hash = "sha256:c4de0081837b211594f8e877a6b4fad7ca32bbfc1a9307fdd61c28bfe923f13e"}, - {file = "identify-2.5.35.tar.gz", hash = "sha256:10a7ca245cfcd756a554a7288159f72ff105ad233c7c4b9c6f0f4d108f5f6791"}, -] - -[package.extras] -license = ["ukkonen"] - [[package]] name = "idna" version = "3.6" @@ -1534,20 +1482,6 @@ files = [ {file = "nh3-0.2.15.tar.gz", hash = "sha256:d1e30ff2d8d58fb2a14961f7aac1bbb1c51f9bdd7da727be35c63826060b0bf3"}, ] -[[package]] -name = "nodeenv" -version = "1.8.0" -description = "Node.js virtual environment builder" -optional = false -python-versions = ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*" -files = [ - {file = "nodeenv-1.8.0-py2.py3-none-any.whl", hash = "sha256:df865724bb3c3adc86b3876fa209771517b0cfe596beff01a92700e0e8be4cec"}, - {file = "nodeenv-1.8.0.tar.gz", hash = "sha256:d51e0c37e64fbf47d017feac3145cdbb58836d7eee8c6f6d3b6880c5456227d2"}, -] - -[package.dependencies] -setuptools = "*" - [[package]] name = "oauthlib" version = "3.2.2" @@ -1658,21 +1592,6 @@ files = [ [package.extras] testing = ["pytest", "pytest-cov"] -[[package]] -name = "platformdirs" -version = "4.2.0" -description = "A small Python package for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." -optional = false -python-versions = ">=3.8" -files = [ - {file = "platformdirs-4.2.0-py3-none-any.whl", hash = "sha256:0614df2a2f37e1a662acbd8e2b25b92ccf8632929bc6d43467e17fe89c75e068"}, - {file = "platformdirs-4.2.0.tar.gz", hash = "sha256:ef0cc731df711022c174543cb70a9b5bd22e5a9337c8624ef2c2ceb8ddad8768"}, -] - -[package.extras] -docs = ["furo (>=2023.9.10)", "proselint (>=0.13)", "sphinx (>=7.2.6)", "sphinx-autodoc-typehints (>=1.25.2)"] -test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=7.4.3)", "pytest-cov (>=4.1)", "pytest-mock (>=3.12)"] - [[package]] name = "pluggy" version = "1.4.0" @@ -1688,24 +1607,6 @@ files = [ dev = ["pre-commit", "tox"] testing = ["pytest", "pytest-benchmark"] -[[package]] -name = "pre-commit" -version = "3.6.2" -description = "A framework for managing and maintaining multi-language pre-commit hooks." -optional = false -python-versions = ">=3.9" -files = [ - {file = "pre_commit-3.6.2-py2.py3-none-any.whl", hash = "sha256:ba637c2d7a670c10daedc059f5c49b5bd0aadbccfcd7ec15592cf9665117532c"}, - {file = "pre_commit-3.6.2.tar.gz", hash = "sha256:c3ef34f463045c88658c5b99f38c1e297abdcc0ff13f98d3370055fbbfabc67e"}, -] - -[package.dependencies] -cfgv = ">=2.0.0" -identify = ">=1.0.0" -nodeenv = ">=0.11.1" -pyyaml = ">=5.1" -virtualenv = ">=20.10.0" - [[package]] name = "proto-plus" version = "1.23.0" @@ -2310,7 +2211,7 @@ files = [ name = "pyyaml" version = "6.0.1" description = "YAML parser and emitter for Python" -optional = false +optional = true python-versions = ">=3.6" files = [ {file = "PyYAML-6.0.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d858aa552c999bc8a8d57426ed01e40bef403cd8ccdd0fc5f6f04a00414cac2a"}, @@ -2570,7 +2471,7 @@ urllib3 = {version = ">=1.26,<3", extras = ["socks"]} name = "setuptools" version = "69.0.3" description = "Easily download, build, install, upgrade, and uninstall Python packages" -optional = false +optional = true python-versions = ">=3.8" files = [ {file = "setuptools-69.0.3-py3-none-any.whl", hash = "sha256:385eb4edd9c9d5c17540511303e39a147ce2fc04bc55289c322b9e5904fe2c05"}, @@ -2989,26 +2890,6 @@ secure = ["certifi", "cryptography (>=1.9)", "idna (>=2.0.0)", "pyopenssl (>=17. socks = ["pysocks (>=1.5.6,!=1.5.7,<2.0)"] zstd = ["zstandard (>=0.18.0)"] -[[package]] -name = "virtualenv" -version = "20.25.1" -description = "Virtual Python Environment builder" -optional = false -python-versions = ">=3.7" -files = [ - {file = "virtualenv-20.25.1-py3-none-any.whl", hash = "sha256:961c026ac520bac5f69acb8ea063e8a4f071bcc9457b9c1f28f6b085c511583a"}, - {file = "virtualenv-20.25.1.tar.gz", hash = "sha256:e08e13ecdca7a0bd53798f356d5831434afa5b07b93f0abdf0797b7a06ffe197"}, -] - -[package.dependencies] -distlib = ">=0.3.7,<1" -filelock = ">=3.12.2,<4" -platformdirs = ">=3.9.1,<5" - -[package.extras] -docs = ["furo (>=2023.7.26)", "proselint (>=0.13)", "sphinx (>=7.1.2)", "sphinx-argparse (>=0.4)", "sphinxcontrib-towncrier (>=0.2.1a0)", "towncrier (>=23.6)"] -test = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "coverage-enable-subprocess (>=1)", "flaky (>=3.7)", "packaging (>=23.1)", "pytest (>=7.4)", "pytest-env (>=0.8.2)", "pytest-freezer (>=0.4.8)", "pytest-mock (>=3.11.1)", "pytest-randomly (>=3.12)", "pytest-timeout (>=2.1)", "setuptools (>=68)", "time-machine (>=2.10)"] - [[package]] name = "websocket-client" version = "1.7.0" @@ -3159,4 +3040,4 @@ selenium = ["selenium"] [metadata] lock-version = "2.0" python-versions = ">=3.9,<4.0" -content-hash = "3d53d9cf801104ed0e1d830d658059c789f7ab8d81e9206027528611dd0866ac" +content-hash = "f9f8789f22b62ef78529e7cfaeaae7df3ca509d9446213f0327608a2b0d49893" diff --git a/pyproject.toml b/pyproject.toml index 70b14d123..83f13c9ff 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -83,8 +83,6 @@ psycopg2-binary = { version = "*", optional = true } pika = { version = "*", optional = true } redis = { version = "*", optional = true } selenium = { version = "*", optional = true } -anyio = "^4.3.0" -pre-commit = "^3.6.2" [tool.poetry.extras] arangodb = ["python-arango"] @@ -116,6 +114,7 @@ sphinx = "^7.2.6" pg8000 = "*" twine = "^4.0.2" mypy = "1.7.1" +anyio = "^4.3.0" [[tool.poetry.source]] name = "PyPI" From 7eb4e73cc9cf881ee1acd1cc952035ae20daaa75 Mon Sep 17 00:00:00 2001 From: Max Pfeiffer Date: Mon, 4 Mar 2024 09:49:05 +0100 Subject: [PATCH 05/10] fix(build): add `pre-commit` as a dev dependency to simplify local dev and CI (#438) I could not install pre-commit handler because the package was missing in [tool.poetry.group.dev.dependencies]. I also updated the configuration for the pre-commit handler as black and ruff packages were outdated. Also removed deprecation for ruff v0.3.0 config in pyproject.toml. --------- Co-authored-by: Balint Bartha <39852431+totallyzen@users.noreply.github.com> --- .github/workflows/ci-lint.yml | 8 +-- .pre-commit-config.yaml | 4 +- poetry.lock | 123 +++++++++++++++++++++++++++++++++- pyproject.toml | 14 ++-- 4 files changed, 134 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci-lint.yml b/.github/workflows/ci-lint.yml index 0a9f4e265..a02136ece 100644 --- a/.github/workflows/ci-lint.yml +++ b/.github/workflows/ci-lint.yml @@ -18,8 +18,6 @@ jobs: with: python-version: "3.9" # the pre-commit is hooked in as 3.9 - name: Install Python dependencies - run: poetry install - - name: Install pre-commit - run: pip install pre-commit - - name: Run linter - run: pre-commit run -a + run: poetry install --no-interaction + - name: Execute pre-commit handler + run: poetry run pre-commit run -a diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a960cc85e..c5b94bdde 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,13 +10,13 @@ repos: - id: end-of-file-fixer - repo: https://github.com/psf/black-pre-commit-mirror - rev: '24.1.1' + rev: '24.2.0' hooks: - id: black args: [ '--config', 'pyproject.toml' ] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: 'v0.1.14' + rev: 'v0.3.0' hooks: - id: ruff # Explicitly setting config to prevent Ruff from using `pyproject.toml` in sub packages. diff --git a/poetry.lock b/poetry.lock index 9e6ea1b78..188970ab1 100644 --- a/poetry.lock +++ b/poetry.lock @@ -311,6 +311,17 @@ files = [ [package.dependencies] pycparser = "*" +[[package]] +name = "cfgv" +version = "3.4.0" +description = "Validate configuration and produce human readable error messages." +optional = false +python-versions = ">=3.8" +files = [ + {file = "cfgv-3.4.0-py2.py3-none-any.whl", hash = "sha256:b7265b1f29fd3316bfcd2b330d63d024f2bfd8bcb8b0272f8e19a504856c48f9"}, + {file = "cfgv-3.4.0.tar.gz", hash = "sha256:e52591d4c5f5dead8e0f673fb16db7949d2cfb3f7da4582893288f0ded8fe560"}, +] + [[package]] name = "charset-normalizer" version = "3.3.2" @@ -698,6 +709,17 @@ files = [ [package.dependencies] packaging = "*" +[[package]] +name = "distlib" +version = "0.3.8" +description = "Distribution utilities" +optional = false +python-versions = "*" +files = [ + {file = "distlib-0.3.8-py2.py3-none-any.whl", hash = "sha256:034db59a0b96f8ca18035f36290806a9a6e6bd9d1ff91e45a7f172eb17e51784"}, + {file = "distlib-0.3.8.tar.gz", hash = "sha256:1530ea13e350031b6312d8580ddb6b27a104275a31106523b8f123787f494f64"}, +] + [[package]] name = "dnspython" version = "2.5.0" @@ -782,6 +804,22 @@ files = [ [package.extras] test = ["pytest (>=6)"] +[[package]] +name = "filelock" +version = "3.13.1" +description = "A platform independent file lock." +optional = false +python-versions = ">=3.8" +files = [ + {file = "filelock-3.13.1-py3-none-any.whl", hash = "sha256:57dbda9b35157b05fb3e58ee91448612eb674172fab98ee235ccb0b5bee19a1c"}, + {file = "filelock-3.13.1.tar.gz", hash = "sha256:521f5f56c50f8426f5e03ad3b281b490a87ef15bc6c526f168290f0c7148d44e"}, +] + +[package.extras] +docs = ["furo (>=2023.9.10)", "sphinx (>=7.2.6)", "sphinx-autodoc-typehints (>=1.24)"] +testing = ["covdefaults (>=2.3)", "coverage (>=7.3.2)", "diff-cover (>=8)", "pytest (>=7.4.3)", "pytest-cov (>=4.1)", "pytest-mock (>=3.12)", "pytest-timeout (>=2.2)"] +typing = ["typing-extensions (>=4.8)"] + [[package]] name = "google-api-core" version = "2.15.0" @@ -1058,6 +1096,20 @@ files = [ {file = "h11-0.14.0.tar.gz", hash = "sha256:8f19fbbe99e72420ff35c00b27a34cb9937e902a8b810e2c88300c6f0a3b699d"}, ] +[[package]] +name = "identify" +version = "2.5.35" +description = "File identification library for Python" +optional = false +python-versions = ">=3.8" +files = [ + {file = "identify-2.5.35-py2.py3-none-any.whl", hash = "sha256:c4de0081837b211594f8e877a6b4fad7ca32bbfc1a9307fdd61c28bfe923f13e"}, + {file = "identify-2.5.35.tar.gz", hash = "sha256:10a7ca245cfcd756a554a7288159f72ff105ad233c7c4b9c6f0f4d108f5f6791"}, +] + +[package.extras] +license = ["ukkonen"] + [[package]] name = "idna" version = "3.6" @@ -1482,6 +1534,20 @@ files = [ {file = "nh3-0.2.15.tar.gz", hash = "sha256:d1e30ff2d8d58fb2a14961f7aac1bbb1c51f9bdd7da727be35c63826060b0bf3"}, ] +[[package]] +name = "nodeenv" +version = "1.8.0" +description = "Node.js virtual environment builder" +optional = false +python-versions = ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*" +files = [ + {file = "nodeenv-1.8.0-py2.py3-none-any.whl", hash = "sha256:df865724bb3c3adc86b3876fa209771517b0cfe596beff01a92700e0e8be4cec"}, + {file = "nodeenv-1.8.0.tar.gz", hash = "sha256:d51e0c37e64fbf47d017feac3145cdbb58836d7eee8c6f6d3b6880c5456227d2"}, +] + +[package.dependencies] +setuptools = "*" + [[package]] name = "oauthlib" version = "3.2.2" @@ -1592,6 +1658,21 @@ files = [ [package.extras] testing = ["pytest", "pytest-cov"] +[[package]] +name = "platformdirs" +version = "4.2.0" +description = "A small Python package for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." +optional = false +python-versions = ">=3.8" +files = [ + {file = "platformdirs-4.2.0-py3-none-any.whl", hash = "sha256:0614df2a2f37e1a662acbd8e2b25b92ccf8632929bc6d43467e17fe89c75e068"}, + {file = "platformdirs-4.2.0.tar.gz", hash = "sha256:ef0cc731df711022c174543cb70a9b5bd22e5a9337c8624ef2c2ceb8ddad8768"}, +] + +[package.extras] +docs = ["furo (>=2023.9.10)", "proselint (>=0.13)", "sphinx (>=7.2.6)", "sphinx-autodoc-typehints (>=1.25.2)"] +test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=7.4.3)", "pytest-cov (>=4.1)", "pytest-mock (>=3.12)"] + [[package]] name = "pluggy" version = "1.4.0" @@ -1607,6 +1688,24 @@ files = [ dev = ["pre-commit", "tox"] testing = ["pytest", "pytest-benchmark"] +[[package]] +name = "pre-commit" +version = "3.6.2" +description = "A framework for managing and maintaining multi-language pre-commit hooks." +optional = false +python-versions = ">=3.9" +files = [ + {file = "pre_commit-3.6.2-py2.py3-none-any.whl", hash = "sha256:ba637c2d7a670c10daedc059f5c49b5bd0aadbccfcd7ec15592cf9665117532c"}, + {file = "pre_commit-3.6.2.tar.gz", hash = "sha256:c3ef34f463045c88658c5b99f38c1e297abdcc0ff13f98d3370055fbbfabc67e"}, +] + +[package.dependencies] +cfgv = ">=2.0.0" +identify = ">=1.0.0" +nodeenv = ">=0.11.1" +pyyaml = ">=5.1" +virtualenv = ">=20.10.0" + [[package]] name = "proto-plus" version = "1.23.0" @@ -2211,7 +2310,7 @@ files = [ name = "pyyaml" version = "6.0.1" description = "YAML parser and emitter for Python" -optional = true +optional = false python-versions = ">=3.6" files = [ {file = "PyYAML-6.0.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d858aa552c999bc8a8d57426ed01e40bef403cd8ccdd0fc5f6f04a00414cac2a"}, @@ -2471,7 +2570,7 @@ urllib3 = {version = ">=1.26,<3", extras = ["socks"]} name = "setuptools" version = "69.0.3" description = "Easily download, build, install, upgrade, and uninstall Python packages" -optional = true +optional = false python-versions = ">=3.8" files = [ {file = "setuptools-69.0.3-py3-none-any.whl", hash = "sha256:385eb4edd9c9d5c17540511303e39a147ce2fc04bc55289c322b9e5904fe2c05"}, @@ -2890,6 +2989,26 @@ secure = ["certifi", "cryptography (>=1.9)", "idna (>=2.0.0)", "pyopenssl (>=17. socks = ["pysocks (>=1.5.6,!=1.5.7,<2.0)"] zstd = ["zstandard (>=0.18.0)"] +[[package]] +name = "virtualenv" +version = "20.25.1" +description = "Virtual Python Environment builder" +optional = false +python-versions = ">=3.7" +files = [ + {file = "virtualenv-20.25.1-py3-none-any.whl", hash = "sha256:961c026ac520bac5f69acb8ea063e8a4f071bcc9457b9c1f28f6b085c511583a"}, + {file = "virtualenv-20.25.1.tar.gz", hash = "sha256:e08e13ecdca7a0bd53798f356d5831434afa5b07b93f0abdf0797b7a06ffe197"}, +] + +[package.dependencies] +distlib = ">=0.3.7,<1" +filelock = ">=3.12.2,<4" +platformdirs = ">=3.9.1,<5" + +[package.extras] +docs = ["furo (>=2023.7.26)", "proselint (>=0.13)", "sphinx (>=7.1.2)", "sphinx-argparse (>=0.4)", "sphinxcontrib-towncrier (>=0.2.1a0)", "towncrier (>=23.6)"] +test = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "coverage-enable-subprocess (>=1)", "flaky (>=3.7)", "packaging (>=23.1)", "pytest (>=7.4)", "pytest-env (>=0.8.2)", "pytest-freezer (>=0.4.8)", "pytest-mock (>=3.11.1)", "pytest-randomly (>=3.12)", "pytest-timeout (>=2.1)", "setuptools (>=68)", "time-machine (>=2.10)"] + [[package]] name = "websocket-client" version = "1.7.0" diff --git a/pyproject.toml b/pyproject.toml index 83f13c9ff..7afb4cd96 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -108,12 +108,13 @@ redis = ["redis"] selenium = ["selenium"] [tool.poetry.group.dev.dependencies] +mypy = "1.7.1" +pre-commit = "^3.6" +pg8000 = "*" pytest = "7.4.3" pytest-cov = "4.1.0" sphinx = "^7.2.6" -pg8000 = "*" twine = "^4.0.2" -mypy = "1.7.1" anyio = "^4.3.0" [[tool.poetry.source]] @@ -140,15 +141,14 @@ exclude_lines = [ "raise NotImplementedError" # TODO: used in core/generic.py, not sure we need DbContainer ] -[tool.ruff.flake8-type-checking] -strict = true - [tool.ruff] target-version = "py39" line-length = 120 fix = true -fixable = ["I"] src = ["core", "modules/*"] + +[tool.ruff.lint] +fixable = ["I"] exclude = ["**/tests/**/*.py"] select = [ # flake8-2020 @@ -195,6 +195,8 @@ ignore = [ "INP001" ] +[tool.ruff.lint.flake8-type-checking] +strict = true [tool.mypy] python_version = "3.9" From de06568c78ff3a4a50568f595709235ccbb38054 Mon Sep 17 00:00:00 2001 From: bstrausser Date: Thu, 29 Feb 2024 10:38:47 -0500 Subject: [PATCH 06/10] Adds AsyncRedis support --- .../redis/testcontainers/redis/__init__.py | 9 ++- modules/redis/tests/test_redis.py | 59 ++++++++++++++++++- poetry.lock | 2 +- pyproject.toml | 1 + 4 files changed, 67 insertions(+), 4 deletions(-) diff --git a/modules/redis/testcontainers/redis/__init__.py b/modules/redis/testcontainers/redis/__init__.py index 7a4d46613..498e68a05 100644 --- a/modules/redis/testcontainers/redis/__init__.py +++ b/modules/redis/testcontainers/redis/__init__.py @@ -72,6 +72,7 @@ def start(self) -> "RedisContainer": return self + class AsyncRedisContainer(RedisContainer): """ Redis container. @@ -86,8 +87,12 @@ class AsyncRedisContainer(RedisContainer): ... redis_client =await redis_container.get_async_client() """ - def __init__(self, image="redis:latest", port_to_expose=6379, password=None, **kwargs): - super().__init__(image, port_to_expose, password, **kwargs) + def __init__( + self, image="redis:latest", port_to_expose=6379, password=None, **kwargs + ): + super(AsyncRedisContainer, self).__init__( + image, port_to_expose, password, **kwargs + ) async def get_async_client(self, **kwargs): return await asyncRedis( diff --git a/modules/redis/tests/test_redis.py b/modules/redis/tests/test_redis.py index 24926d0ba..260be5699 100644 --- a/modules/redis/tests/test_redis.py +++ b/modules/redis/tests/test_redis.py @@ -5,6 +5,8 @@ import pytest + + def test_docker_run_redis(): config = RedisContainer() with config as redis: @@ -81,6 +83,61 @@ async def test_key_set_in_async(anyio_backend): actual_value = await async_redis_client.get(key) assert int(actual_value) == expected_value +pytest.mark.usefixtures('anyio_backend') +@pytest.mark.parametrize('anyio_backend', ['asyncio']) +async def test_key_set_in_async_redis(anyio_backend): + with AsyncRedisContainer() as container: + async_redis_client: redis.Redis = await container.get_async_client( + decode_responses=True + ) + key = "key" + expected_value = 1 + await async_redis_client.set(key, expected_value) + actual_value = await async_redis_client.get(key) + assert int(actual_value) == expected_value + +pytest.mark.usefixtures('anyio_backend') +@pytest.mark.parametrize('anyio_backend', ['asyncio']) +@pytest.mark.skip(reason="Need to sort out async pub/sub") +async def test_docker_run_async_redis(anyio_backend): + config = AsyncRedisContainer() + with config as container: + client: redis.Redis = await container.get_async_client( + decode_responses=True + ) + p = await client.pubsub() + await p.subscribe("test") + await client.publish("test", "new_msg") + msg = wait_for_message(p) + assert "data" in msg + assert b"new_msg", msg["data"] + +pytest.mark.usefixtures('anyio_backend') +@pytest.mark.parametrize('anyio_backend', ['asyncio']) +async def test_docker_run_async_redis_with_password(anyio_backend): + config = AsyncRedisContainer(password="mypass") + with config as container: + client: redis.Redis = await container.get_async_client( + decode_responses=True + ) + await client.set("hello", "world") + assert await client.get("hello") == "world" + + + +pytest.mark.usefixtures('anyio_backend') +@pytest.mark.parametrize('anyio_backend', ['asyncio']) +async def test_key_set_in_async(anyio_backend): + with AsyncRedisContainer() as container: + async_redis_client: redis.Redis = await container.get_async_client( + decode_responses=True + ) + key = "key" + expected_value = 1 + await async_redis_client.set(key, expected_value) + actual_value = await async_redis_client.get(key) + assert int(actual_value) == expected_value + def wait_for_message(pubsub, timeout=1, ignore_subscribe_messages=True): now = time.time() @@ -91,4 +148,4 @@ def wait_for_message(pubsub, timeout=1, ignore_subscribe_messages=True): return message time.sleep(0.01) now = time.time() - return None + return None \ No newline at end of file diff --git a/poetry.lock b/poetry.lock index 188970ab1..9bdf65e4f 100644 --- a/poetry.lock +++ b/poetry.lock @@ -3159,4 +3159,4 @@ selenium = ["selenium"] [metadata] lock-version = "2.0" python-versions = ">=3.9,<4.0" -content-hash = "f9f8789f22b62ef78529e7cfaeaae7df3ca509d9446213f0327608a2b0d49893" +content-hash = "bad8d37b2f1eeda277e29edd10db3bb1c7848ec29cf20375fccb1f308b460fbf" diff --git a/pyproject.toml b/pyproject.toml index 7afb4cd96..0cb2be7ef 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -83,6 +83,7 @@ psycopg2-binary = { version = "*", optional = true } pika = { version = "*", optional = true } redis = { version = "*", optional = true } selenium = { version = "*", optional = true } +anyio = "^4.3.0" [tool.poetry.extras] arangodb = ["python-arango"] From a1acd7c4eded69ed4338817553ef2830e477a28c Mon Sep 17 00:00:00 2001 From: bstrausser Date: Thu, 29 Feb 2024 14:54:23 -0500 Subject: [PATCH 07/10] Loosen python version on precommit so make lint works --- .../redis/testcontainers/redis/__init__.py | 9 +-- modules/redis/tests/test_redis.py | 67 +++++++++---------- poetry.lock | 2 +- pyproject.toml | 1 + 4 files changed, 35 insertions(+), 44 deletions(-) diff --git a/modules/redis/testcontainers/redis/__init__.py b/modules/redis/testcontainers/redis/__init__.py index 498e68a05..7a4d46613 100644 --- a/modules/redis/testcontainers/redis/__init__.py +++ b/modules/redis/testcontainers/redis/__init__.py @@ -72,7 +72,6 @@ def start(self) -> "RedisContainer": return self - class AsyncRedisContainer(RedisContainer): """ Redis container. @@ -87,12 +86,8 @@ class AsyncRedisContainer(RedisContainer): ... redis_client =await redis_container.get_async_client() """ - def __init__( - self, image="redis:latest", port_to_expose=6379, password=None, **kwargs - ): - super(AsyncRedisContainer, self).__init__( - image, port_to_expose, password, **kwargs - ) + def __init__(self, image="redis:latest", port_to_expose=6379, password=None, **kwargs): + super().__init__(image, port_to_expose, password, **kwargs) async def get_async_client(self, **kwargs): return await asyncRedis( diff --git a/modules/redis/tests/test_redis.py b/modules/redis/tests/test_redis.py index 260be5699..d27efce57 100644 --- a/modules/redis/tests/test_redis.py +++ b/modules/redis/tests/test_redis.py @@ -5,8 +5,6 @@ import pytest - - def test_docker_run_redis(): config = RedisContainer() with config as redis: @@ -83,28 +81,25 @@ async def test_key_set_in_async(anyio_backend): actual_value = await async_redis_client.get(key) assert int(actual_value) == expected_value -pytest.mark.usefixtures('anyio_backend') -@pytest.mark.parametrize('anyio_backend', ['asyncio']) async def test_key_set_in_async_redis(anyio_backend): - with AsyncRedisContainer() as container: - async_redis_client: redis.Redis = await container.get_async_client( - decode_responses=True - ) - key = "key" - expected_value = 1 - await async_redis_client.set(key, expected_value) - actual_value = await async_redis_client.get(key) - assert int(actual_value) == expected_value - -pytest.mark.usefixtures('anyio_backend') -@pytest.mark.parametrize('anyio_backend', ['asyncio']) + with AsyncRedisContainer() as container: + async_redis_client: redis.Redis = await container.get_async_client(decode_responses=True) + key = "key" + expected_value = 1 + await async_redis_client.set(key, expected_value) + actual_value = await async_redis_client.get(key) + assert int(actual_value) == expected_value + + +pytest.mark.usefixtures("anyio_backend") + + +@pytest.mark.parametrize("anyio_backend", ["asyncio"]) @pytest.mark.skip(reason="Need to sort out async pub/sub") async def test_docker_run_async_redis(anyio_backend): config = AsyncRedisContainer() with config as container: - client: redis.Redis = await container.get_async_client( - decode_responses=True - ) + client: redis.Redis = await container.get_async_client(decode_responses=True) p = await client.pubsub() await p.subscribe("test") await client.publish("test", "new_msg") @@ -112,31 +107,31 @@ async def test_docker_run_async_redis(anyio_backend): assert "data" in msg assert b"new_msg", msg["data"] -pytest.mark.usefixtures('anyio_backend') -@pytest.mark.parametrize('anyio_backend', ['asyncio']) + +pytest.mark.usefixtures("anyio_backend") + + +@pytest.mark.parametrize("anyio_backend", ["asyncio"]) async def test_docker_run_async_redis_with_password(anyio_backend): config = AsyncRedisContainer(password="mypass") with config as container: - client: redis.Redis = await container.get_async_client( - decode_responses=True - ) + client: redis.Redis = await container.get_async_client(decode_responses=True) await client.set("hello", "world") assert await client.get("hello") == "world" +pytest.mark.usefixtures("anyio_backend") + -pytest.mark.usefixtures('anyio_backend') -@pytest.mark.parametrize('anyio_backend', ['asyncio']) +@pytest.mark.parametrize("anyio_backend", ["asyncio"]) async def test_key_set_in_async(anyio_backend): - with AsyncRedisContainer() as container: - async_redis_client: redis.Redis = await container.get_async_client( - decode_responses=True - ) - key = "key" - expected_value = 1 - await async_redis_client.set(key, expected_value) - actual_value = await async_redis_client.get(key) - assert int(actual_value) == expected_value + with AsyncRedisContainer() as container: + async_redis_client: redis.Redis = await container.get_async_client(decode_responses=True) + key = "key" + expected_value = 1 + await async_redis_client.set(key, expected_value) + actual_value = await async_redis_client.get(key) + assert int(actual_value) == expected_value def wait_for_message(pubsub, timeout=1, ignore_subscribe_messages=True): @@ -148,4 +143,4 @@ def wait_for_message(pubsub, timeout=1, ignore_subscribe_messages=True): return message time.sleep(0.01) now = time.time() - return None \ No newline at end of file + return None diff --git a/poetry.lock b/poetry.lock index 9bdf65e4f..7bfb26f62 100644 --- a/poetry.lock +++ b/poetry.lock @@ -3159,4 +3159,4 @@ selenium = ["selenium"] [metadata] lock-version = "2.0" python-versions = ">=3.9,<4.0" -content-hash = "bad8d37b2f1eeda277e29edd10db3bb1c7848ec29cf20375fccb1f308b460fbf" +content-hash = "3d53d9cf801104ed0e1d830d658059c789f7ab8d81e9206027528611dd0866ac" diff --git a/pyproject.toml b/pyproject.toml index 0cb2be7ef..9fec5c418 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -84,6 +84,7 @@ pika = { version = "*", optional = true } redis = { version = "*", optional = true } selenium = { version = "*", optional = true } anyio = "^4.3.0" +pre-commit = "^3.6.2" [tool.poetry.extras] arangodb = ["python-arango"] From c1ab1d2eca98e741135048ca6b313093605bd1b6 Mon Sep 17 00:00:00 2001 From: bstrausser Date: Fri, 1 Mar 2024 19:32:45 -0500 Subject: [PATCH 08/10] Fix dependencies --- poetry.lock | 125 ++----------------------------------------------- pyproject.toml | 2 - 2 files changed, 3 insertions(+), 124 deletions(-) diff --git a/poetry.lock b/poetry.lock index 7bfb26f62..9e6ea1b78 100644 --- a/poetry.lock +++ b/poetry.lock @@ -311,17 +311,6 @@ files = [ [package.dependencies] pycparser = "*" -[[package]] -name = "cfgv" -version = "3.4.0" -description = "Validate configuration and produce human readable error messages." -optional = false -python-versions = ">=3.8" -files = [ - {file = "cfgv-3.4.0-py2.py3-none-any.whl", hash = "sha256:b7265b1f29fd3316bfcd2b330d63d024f2bfd8bcb8b0272f8e19a504856c48f9"}, - {file = "cfgv-3.4.0.tar.gz", hash = "sha256:e52591d4c5f5dead8e0f673fb16db7949d2cfb3f7da4582893288f0ded8fe560"}, -] - [[package]] name = "charset-normalizer" version = "3.3.2" @@ -709,17 +698,6 @@ files = [ [package.dependencies] packaging = "*" -[[package]] -name = "distlib" -version = "0.3.8" -description = "Distribution utilities" -optional = false -python-versions = "*" -files = [ - {file = "distlib-0.3.8-py2.py3-none-any.whl", hash = "sha256:034db59a0b96f8ca18035f36290806a9a6e6bd9d1ff91e45a7f172eb17e51784"}, - {file = "distlib-0.3.8.tar.gz", hash = "sha256:1530ea13e350031b6312d8580ddb6b27a104275a31106523b8f123787f494f64"}, -] - [[package]] name = "dnspython" version = "2.5.0" @@ -804,22 +782,6 @@ files = [ [package.extras] test = ["pytest (>=6)"] -[[package]] -name = "filelock" -version = "3.13.1" -description = "A platform independent file lock." -optional = false -python-versions = ">=3.8" -files = [ - {file = "filelock-3.13.1-py3-none-any.whl", hash = "sha256:57dbda9b35157b05fb3e58ee91448612eb674172fab98ee235ccb0b5bee19a1c"}, - {file = "filelock-3.13.1.tar.gz", hash = "sha256:521f5f56c50f8426f5e03ad3b281b490a87ef15bc6c526f168290f0c7148d44e"}, -] - -[package.extras] -docs = ["furo (>=2023.9.10)", "sphinx (>=7.2.6)", "sphinx-autodoc-typehints (>=1.24)"] -testing = ["covdefaults (>=2.3)", "coverage (>=7.3.2)", "diff-cover (>=8)", "pytest (>=7.4.3)", "pytest-cov (>=4.1)", "pytest-mock (>=3.12)", "pytest-timeout (>=2.2)"] -typing = ["typing-extensions (>=4.8)"] - [[package]] name = "google-api-core" version = "2.15.0" @@ -1096,20 +1058,6 @@ files = [ {file = "h11-0.14.0.tar.gz", hash = "sha256:8f19fbbe99e72420ff35c00b27a34cb9937e902a8b810e2c88300c6f0a3b699d"}, ] -[[package]] -name = "identify" -version = "2.5.35" -description = "File identification library for Python" -optional = false -python-versions = ">=3.8" -files = [ - {file = "identify-2.5.35-py2.py3-none-any.whl", hash = "sha256:c4de0081837b211594f8e877a6b4fad7ca32bbfc1a9307fdd61c28bfe923f13e"}, - {file = "identify-2.5.35.tar.gz", hash = "sha256:10a7ca245cfcd756a554a7288159f72ff105ad233c7c4b9c6f0f4d108f5f6791"}, -] - -[package.extras] -license = ["ukkonen"] - [[package]] name = "idna" version = "3.6" @@ -1534,20 +1482,6 @@ files = [ {file = "nh3-0.2.15.tar.gz", hash = "sha256:d1e30ff2d8d58fb2a14961f7aac1bbb1c51f9bdd7da727be35c63826060b0bf3"}, ] -[[package]] -name = "nodeenv" -version = "1.8.0" -description = "Node.js virtual environment builder" -optional = false -python-versions = ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*" -files = [ - {file = "nodeenv-1.8.0-py2.py3-none-any.whl", hash = "sha256:df865724bb3c3adc86b3876fa209771517b0cfe596beff01a92700e0e8be4cec"}, - {file = "nodeenv-1.8.0.tar.gz", hash = "sha256:d51e0c37e64fbf47d017feac3145cdbb58836d7eee8c6f6d3b6880c5456227d2"}, -] - -[package.dependencies] -setuptools = "*" - [[package]] name = "oauthlib" version = "3.2.2" @@ -1658,21 +1592,6 @@ files = [ [package.extras] testing = ["pytest", "pytest-cov"] -[[package]] -name = "platformdirs" -version = "4.2.0" -description = "A small Python package for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." -optional = false -python-versions = ">=3.8" -files = [ - {file = "platformdirs-4.2.0-py3-none-any.whl", hash = "sha256:0614df2a2f37e1a662acbd8e2b25b92ccf8632929bc6d43467e17fe89c75e068"}, - {file = "platformdirs-4.2.0.tar.gz", hash = "sha256:ef0cc731df711022c174543cb70a9b5bd22e5a9337c8624ef2c2ceb8ddad8768"}, -] - -[package.extras] -docs = ["furo (>=2023.9.10)", "proselint (>=0.13)", "sphinx (>=7.2.6)", "sphinx-autodoc-typehints (>=1.25.2)"] -test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=7.4.3)", "pytest-cov (>=4.1)", "pytest-mock (>=3.12)"] - [[package]] name = "pluggy" version = "1.4.0" @@ -1688,24 +1607,6 @@ files = [ dev = ["pre-commit", "tox"] testing = ["pytest", "pytest-benchmark"] -[[package]] -name = "pre-commit" -version = "3.6.2" -description = "A framework for managing and maintaining multi-language pre-commit hooks." -optional = false -python-versions = ">=3.9" -files = [ - {file = "pre_commit-3.6.2-py2.py3-none-any.whl", hash = "sha256:ba637c2d7a670c10daedc059f5c49b5bd0aadbccfcd7ec15592cf9665117532c"}, - {file = "pre_commit-3.6.2.tar.gz", hash = "sha256:c3ef34f463045c88658c5b99f38c1e297abdcc0ff13f98d3370055fbbfabc67e"}, -] - -[package.dependencies] -cfgv = ">=2.0.0" -identify = ">=1.0.0" -nodeenv = ">=0.11.1" -pyyaml = ">=5.1" -virtualenv = ">=20.10.0" - [[package]] name = "proto-plus" version = "1.23.0" @@ -2310,7 +2211,7 @@ files = [ name = "pyyaml" version = "6.0.1" description = "YAML parser and emitter for Python" -optional = false +optional = true python-versions = ">=3.6" files = [ {file = "PyYAML-6.0.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d858aa552c999bc8a8d57426ed01e40bef403cd8ccdd0fc5f6f04a00414cac2a"}, @@ -2570,7 +2471,7 @@ urllib3 = {version = ">=1.26,<3", extras = ["socks"]} name = "setuptools" version = "69.0.3" description = "Easily download, build, install, upgrade, and uninstall Python packages" -optional = false +optional = true python-versions = ">=3.8" files = [ {file = "setuptools-69.0.3-py3-none-any.whl", hash = "sha256:385eb4edd9c9d5c17540511303e39a147ce2fc04bc55289c322b9e5904fe2c05"}, @@ -2989,26 +2890,6 @@ secure = ["certifi", "cryptography (>=1.9)", "idna (>=2.0.0)", "pyopenssl (>=17. socks = ["pysocks (>=1.5.6,!=1.5.7,<2.0)"] zstd = ["zstandard (>=0.18.0)"] -[[package]] -name = "virtualenv" -version = "20.25.1" -description = "Virtual Python Environment builder" -optional = false -python-versions = ">=3.7" -files = [ - {file = "virtualenv-20.25.1-py3-none-any.whl", hash = "sha256:961c026ac520bac5f69acb8ea063e8a4f071bcc9457b9c1f28f6b085c511583a"}, - {file = "virtualenv-20.25.1.tar.gz", hash = "sha256:e08e13ecdca7a0bd53798f356d5831434afa5b07b93f0abdf0797b7a06ffe197"}, -] - -[package.dependencies] -distlib = ">=0.3.7,<1" -filelock = ">=3.12.2,<4" -platformdirs = ">=3.9.1,<5" - -[package.extras] -docs = ["furo (>=2023.7.26)", "proselint (>=0.13)", "sphinx (>=7.1.2)", "sphinx-argparse (>=0.4)", "sphinxcontrib-towncrier (>=0.2.1a0)", "towncrier (>=23.6)"] -test = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "coverage-enable-subprocess (>=1)", "flaky (>=3.7)", "packaging (>=23.1)", "pytest (>=7.4)", "pytest-env (>=0.8.2)", "pytest-freezer (>=0.4.8)", "pytest-mock (>=3.11.1)", "pytest-randomly (>=3.12)", "pytest-timeout (>=2.1)", "setuptools (>=68)", "time-machine (>=2.10)"] - [[package]] name = "websocket-client" version = "1.7.0" @@ -3159,4 +3040,4 @@ selenium = ["selenium"] [metadata] lock-version = "2.0" python-versions = ">=3.9,<4.0" -content-hash = "3d53d9cf801104ed0e1d830d658059c789f7ab8d81e9206027528611dd0866ac" +content-hash = "f9f8789f22b62ef78529e7cfaeaae7df3ca509d9446213f0327608a2b0d49893" diff --git a/pyproject.toml b/pyproject.toml index 9fec5c418..7afb4cd96 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -83,8 +83,6 @@ psycopg2-binary = { version = "*", optional = true } pika = { version = "*", optional = true } redis = { version = "*", optional = true } selenium = { version = "*", optional = true } -anyio = "^4.3.0" -pre-commit = "^3.6.2" [tool.poetry.extras] arangodb = ["python-arango"] From 253a04cb066e8d75843b7d00197d5395402b6b86 Mon Sep 17 00:00:00 2001 From: bstrausser Date: Mon, 4 Mar 2024 18:54:43 -0500 Subject: [PATCH 09/10] Update lock --- poetry.lock | 127 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 123 insertions(+), 4 deletions(-) diff --git a/poetry.lock b/poetry.lock index 9e6ea1b78..f97690266 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.8.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand. [[package]] name = "alabaster" @@ -311,6 +311,17 @@ files = [ [package.dependencies] pycparser = "*" +[[package]] +name = "cfgv" +version = "3.4.0" +description = "Validate configuration and produce human readable error messages." +optional = false +python-versions = ">=3.8" +files = [ + {file = "cfgv-3.4.0-py2.py3-none-any.whl", hash = "sha256:b7265b1f29fd3316bfcd2b330d63d024f2bfd8bcb8b0272f8e19a504856c48f9"}, + {file = "cfgv-3.4.0.tar.gz", hash = "sha256:e52591d4c5f5dead8e0f673fb16db7949d2cfb3f7da4582893288f0ded8fe560"}, +] + [[package]] name = "charset-normalizer" version = "3.3.2" @@ -698,6 +709,17 @@ files = [ [package.dependencies] packaging = "*" +[[package]] +name = "distlib" +version = "0.3.8" +description = "Distribution utilities" +optional = false +python-versions = "*" +files = [ + {file = "distlib-0.3.8-py2.py3-none-any.whl", hash = "sha256:034db59a0b96f8ca18035f36290806a9a6e6bd9d1ff91e45a7f172eb17e51784"}, + {file = "distlib-0.3.8.tar.gz", hash = "sha256:1530ea13e350031b6312d8580ddb6b27a104275a31106523b8f123787f494f64"}, +] + [[package]] name = "dnspython" version = "2.5.0" @@ -782,6 +804,22 @@ files = [ [package.extras] test = ["pytest (>=6)"] +[[package]] +name = "filelock" +version = "3.13.1" +description = "A platform independent file lock." +optional = false +python-versions = ">=3.8" +files = [ + {file = "filelock-3.13.1-py3-none-any.whl", hash = "sha256:57dbda9b35157b05fb3e58ee91448612eb674172fab98ee235ccb0b5bee19a1c"}, + {file = "filelock-3.13.1.tar.gz", hash = "sha256:521f5f56c50f8426f5e03ad3b281b490a87ef15bc6c526f168290f0c7148d44e"}, +] + +[package.extras] +docs = ["furo (>=2023.9.10)", "sphinx (>=7.2.6)", "sphinx-autodoc-typehints (>=1.24)"] +testing = ["covdefaults (>=2.3)", "coverage (>=7.3.2)", "diff-cover (>=8)", "pytest (>=7.4.3)", "pytest-cov (>=4.1)", "pytest-mock (>=3.12)", "pytest-timeout (>=2.2)"] +typing = ["typing-extensions (>=4.8)"] + [[package]] name = "google-api-core" version = "2.15.0" @@ -1058,6 +1096,20 @@ files = [ {file = "h11-0.14.0.tar.gz", hash = "sha256:8f19fbbe99e72420ff35c00b27a34cb9937e902a8b810e2c88300c6f0a3b699d"}, ] +[[package]] +name = "identify" +version = "2.5.35" +description = "File identification library for Python" +optional = false +python-versions = ">=3.8" +files = [ + {file = "identify-2.5.35-py2.py3-none-any.whl", hash = "sha256:c4de0081837b211594f8e877a6b4fad7ca32bbfc1a9307fdd61c28bfe923f13e"}, + {file = "identify-2.5.35.tar.gz", hash = "sha256:10a7ca245cfcd756a554a7288159f72ff105ad233c7c4b9c6f0f4d108f5f6791"}, +] + +[package.extras] +license = ["ukkonen"] + [[package]] name = "idna" version = "3.6" @@ -1482,6 +1534,20 @@ files = [ {file = "nh3-0.2.15.tar.gz", hash = "sha256:d1e30ff2d8d58fb2a14961f7aac1bbb1c51f9bdd7da727be35c63826060b0bf3"}, ] +[[package]] +name = "nodeenv" +version = "1.8.0" +description = "Node.js virtual environment builder" +optional = false +python-versions = ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*" +files = [ + {file = "nodeenv-1.8.0-py2.py3-none-any.whl", hash = "sha256:df865724bb3c3adc86b3876fa209771517b0cfe596beff01a92700e0e8be4cec"}, + {file = "nodeenv-1.8.0.tar.gz", hash = "sha256:d51e0c37e64fbf47d017feac3145cdbb58836d7eee8c6f6d3b6880c5456227d2"}, +] + +[package.dependencies] +setuptools = "*" + [[package]] name = "oauthlib" version = "3.2.2" @@ -1592,6 +1658,21 @@ files = [ [package.extras] testing = ["pytest", "pytest-cov"] +[[package]] +name = "platformdirs" +version = "4.2.0" +description = "A small Python package for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." +optional = false +python-versions = ">=3.8" +files = [ + {file = "platformdirs-4.2.0-py3-none-any.whl", hash = "sha256:0614df2a2f37e1a662acbd8e2b25b92ccf8632929bc6d43467e17fe89c75e068"}, + {file = "platformdirs-4.2.0.tar.gz", hash = "sha256:ef0cc731df711022c174543cb70a9b5bd22e5a9337c8624ef2c2ceb8ddad8768"}, +] + +[package.extras] +docs = ["furo (>=2023.9.10)", "proselint (>=0.13)", "sphinx (>=7.2.6)", "sphinx-autodoc-typehints (>=1.25.2)"] +test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=7.4.3)", "pytest-cov (>=4.1)", "pytest-mock (>=3.12)"] + [[package]] name = "pluggy" version = "1.4.0" @@ -1607,6 +1688,24 @@ files = [ dev = ["pre-commit", "tox"] testing = ["pytest", "pytest-benchmark"] +[[package]] +name = "pre-commit" +version = "3.6.2" +description = "A framework for managing and maintaining multi-language pre-commit hooks." +optional = false +python-versions = ">=3.9" +files = [ + {file = "pre_commit-3.6.2-py2.py3-none-any.whl", hash = "sha256:ba637c2d7a670c10daedc059f5c49b5bd0aadbccfcd7ec15592cf9665117532c"}, + {file = "pre_commit-3.6.2.tar.gz", hash = "sha256:c3ef34f463045c88658c5b99f38c1e297abdcc0ff13f98d3370055fbbfabc67e"}, +] + +[package.dependencies] +cfgv = ">=2.0.0" +identify = ">=1.0.0" +nodeenv = ">=0.11.1" +pyyaml = ">=5.1" +virtualenv = ">=20.10.0" + [[package]] name = "proto-plus" version = "1.23.0" @@ -2211,7 +2310,7 @@ files = [ name = "pyyaml" version = "6.0.1" description = "YAML parser and emitter for Python" -optional = true +optional = false python-versions = ">=3.6" files = [ {file = "PyYAML-6.0.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d858aa552c999bc8a8d57426ed01e40bef403cd8ccdd0fc5f6f04a00414cac2a"}, @@ -2471,7 +2570,7 @@ urllib3 = {version = ">=1.26,<3", extras = ["socks"]} name = "setuptools" version = "69.0.3" description = "Easily download, build, install, upgrade, and uninstall Python packages" -optional = true +optional = false python-versions = ">=3.8" files = [ {file = "setuptools-69.0.3-py3-none-any.whl", hash = "sha256:385eb4edd9c9d5c17540511303e39a147ce2fc04bc55289c322b9e5904fe2c05"}, @@ -2890,6 +2989,26 @@ secure = ["certifi", "cryptography (>=1.9)", "idna (>=2.0.0)", "pyopenssl (>=17. socks = ["pysocks (>=1.5.6,!=1.5.7,<2.0)"] zstd = ["zstandard (>=0.18.0)"] +[[package]] +name = "virtualenv" +version = "20.25.1" +description = "Virtual Python Environment builder" +optional = false +python-versions = ">=3.7" +files = [ + {file = "virtualenv-20.25.1-py3-none-any.whl", hash = "sha256:961c026ac520bac5f69acb8ea063e8a4f071bcc9457b9c1f28f6b085c511583a"}, + {file = "virtualenv-20.25.1.tar.gz", hash = "sha256:e08e13ecdca7a0bd53798f356d5831434afa5b07b93f0abdf0797b7a06ffe197"}, +] + +[package.dependencies] +distlib = ">=0.3.7,<1" +filelock = ">=3.12.2,<4" +platformdirs = ">=3.9.1,<5" + +[package.extras] +docs = ["furo (>=2023.7.26)", "proselint (>=0.13)", "sphinx (>=7.1.2)", "sphinx-argparse (>=0.4)", "sphinxcontrib-towncrier (>=0.2.1a0)", "towncrier (>=23.6)"] +test = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "coverage-enable-subprocess (>=1)", "flaky (>=3.7)", "packaging (>=23.1)", "pytest (>=7.4)", "pytest-env (>=0.8.2)", "pytest-freezer (>=0.4.8)", "pytest-mock (>=3.11.1)", "pytest-randomly (>=3.12)", "pytest-timeout (>=2.1)", "setuptools (>=68)", "time-machine (>=2.10)"] + [[package]] name = "websocket-client" version = "1.7.0" @@ -3040,4 +3159,4 @@ selenium = ["selenium"] [metadata] lock-version = "2.0" python-versions = ">=3.9,<4.0" -content-hash = "f9f8789f22b62ef78529e7cfaeaae7df3ca509d9446213f0327608a2b0d49893" +content-hash = "f4cb027301e265217ccb581b0ddd06fe6d91319fbcfbc3d20504a1fdbc45d7b1" From cee082a9678fdd2b4937b3f61d3bb2aa326e0fb3 Mon Sep 17 00:00:00 2001 From: bstrausser Date: Mon, 4 Mar 2024 19:05:06 -0500 Subject: [PATCH 10/10] Fix test after merge --- modules/redis/tests/test_redis.py | 52 ------------------------------- 1 file changed, 52 deletions(-) diff --git a/modules/redis/tests/test_redis.py b/modules/redis/tests/test_redis.py index d27efce57..24926d0ba 100644 --- a/modules/redis/tests/test_redis.py +++ b/modules/redis/tests/test_redis.py @@ -71,58 +71,6 @@ async def test_docker_run_async_redis_with_password(anyio_backend): pytest.mark.usefixtures("anyio_backend") -@pytest.mark.parametrize("anyio_backend", ["asyncio"]) -async def test_key_set_in_async(anyio_backend): - with AsyncRedisContainer() as container: - async_redis_client: redis.Redis = await container.get_async_client(decode_responses=True) - key = "key" - expected_value = 1 - await async_redis_client.set(key, expected_value) - actual_value = await async_redis_client.get(key) - assert int(actual_value) == expected_value - -async def test_key_set_in_async_redis(anyio_backend): - with AsyncRedisContainer() as container: - async_redis_client: redis.Redis = await container.get_async_client(decode_responses=True) - key = "key" - expected_value = 1 - await async_redis_client.set(key, expected_value) - actual_value = await async_redis_client.get(key) - assert int(actual_value) == expected_value - - -pytest.mark.usefixtures("anyio_backend") - - -@pytest.mark.parametrize("anyio_backend", ["asyncio"]) -@pytest.mark.skip(reason="Need to sort out async pub/sub") -async def test_docker_run_async_redis(anyio_backend): - config = AsyncRedisContainer() - with config as container: - client: redis.Redis = await container.get_async_client(decode_responses=True) - p = await client.pubsub() - await p.subscribe("test") - await client.publish("test", "new_msg") - msg = wait_for_message(p) - assert "data" in msg - assert b"new_msg", msg["data"] - - -pytest.mark.usefixtures("anyio_backend") - - -@pytest.mark.parametrize("anyio_backend", ["asyncio"]) -async def test_docker_run_async_redis_with_password(anyio_backend): - config = AsyncRedisContainer(password="mypass") - with config as container: - client: redis.Redis = await container.get_async_client(decode_responses=True) - await client.set("hello", "world") - assert await client.get("hello") == "world" - - -pytest.mark.usefixtures("anyio_backend") - - @pytest.mark.parametrize("anyio_backend", ["asyncio"]) async def test_key_set_in_async(anyio_backend): with AsyncRedisContainer() as container: