mirror of
https://github.com/void-linux/void-packages.git
synced 2025-08-02 19:02:57 +02:00
New package: python3-hishel-0.1.2
This commit is contained in:
parent
1168f11a0e
commit
443fd8708d
2 changed files with 282 additions and 0 deletions
|
@ -0,0 +1,262 @@
|
|||
From 8ce61a6e604d5ae948b5eb68d1e9fc8e640a71dd Mon Sep 17 00:00:00 2001
|
||||
From: Komeil Parseh <komeilparseh@disroot.org>
|
||||
Date: Wed, 2 Jul 2025 16:17:36 +0330
|
||||
Subject: [PATCH] skip anysqlite, yaml and redis tests if optional deps are
|
||||
missing
|
||||
|
||||
---
|
||||
tests/_async/test_storages.py | 29 ++++++++++++++++++++++++++++-
|
||||
tests/_sync/test_storages.py | 29 ++++++++++++++++++++++++++++-
|
||||
tests/test_serializers.py | 10 ++++++++++
|
||||
3 files changed, 66 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/tests/_async/test_storages.py b/tests/_async/test_storages.py
|
||||
index b780185..08087b0 100644
|
||||
--- a/tests/_async/test_storages.py
|
||||
+++ b/tests/_async/test_storages.py
|
||||
@@ -2,7 +2,6 @@ import datetime
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
-import anysqlite
|
||||
import pytest
|
||||
from httpcore import Request, Response
|
||||
|
||||
@@ -10,6 +9,16 @@ from hishel import AsyncFileStorage, AsyncInMemoryStorage, AsyncRedisStorage, As
|
||||
from hishel._serializers import Metadata
|
||||
from hishel._utils import asleep, generate_key
|
||||
|
||||
+try:
|
||||
+ import anysqlite
|
||||
+except ImportError:
|
||||
+ anysqlite = None # type: ignore
|
||||
+
|
||||
+try:
|
||||
+ import redis
|
||||
+except ImportError:
|
||||
+ redis = None # type: ignore
|
||||
+
|
||||
dummy_metadata = Metadata(cache_key="test", number_of_uses=0, created_at=datetime.datetime.now(datetime.timezone.utc))
|
||||
|
||||
|
||||
@@ -48,6 +57,8 @@ async def test_filestorage(use_temp_dir):
|
||||
|
||||
@pytest.mark.parametrize("anyio_backend", ["asyncio"])
|
||||
async def test_redisstorage(anyio_backend):
|
||||
+ if redis is None: # pragma: no cover
|
||||
+ pytest.skip("redis is not installed")
|
||||
if await is_redis_down(): # pragma: no cover
|
||||
pytest.fail("Redis server was not found")
|
||||
storage = AsyncRedisStorage()
|
||||
@@ -73,6 +84,8 @@ async def test_redisstorage(anyio_backend):
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_sqlitestorage():
|
||||
+ if anysqlite is None: # pragma: no cover
|
||||
+ pytest.skip("anysqlite not installed")
|
||||
storage = AsyncSQLiteStorage(connection=await anysqlite.connect(":memory:"))
|
||||
|
||||
request = Request(b"GET", "https://example.com")
|
||||
@@ -196,6 +209,8 @@ async def test_filestorage_ttl_after_hits(use_temp_dir, anyio_backend):
|
||||
|
||||
@pytest.mark.parametrize("anyio_backend", ["asyncio"])
|
||||
async def test_redisstorage_expired(anyio_backend):
|
||||
+ if redis is None: # pragma: no cover
|
||||
+ pytest.skip("redis is not installed")
|
||||
if await is_redis_down(): # pragma: no cover
|
||||
pytest.fail("Redis server was not found")
|
||||
storage = AsyncRedisStorage(ttl=0.1)
|
||||
@@ -219,6 +234,10 @@ async def test_redisstorage_expired(anyio_backend):
|
||||
|
||||
@pytest.mark.parametrize("anyio_backend", ["asyncio"])
|
||||
async def test_redis_ttl_after_hits(use_temp_dir, anyio_backend):
|
||||
+ if redis is None: # pragma: no cover
|
||||
+ pytest.skip("redis not installed")
|
||||
+ if await is_redis_down(): # pragma: no cover
|
||||
+ pytest.fail("Redis server was not found")
|
||||
storage = AsyncRedisStorage(ttl=0.2)
|
||||
|
||||
request = Request(b"GET", "https://example.com")
|
||||
@@ -249,6 +268,8 @@ async def test_redis_ttl_after_hits(use_temp_dir, anyio_backend):
|
||||
|
||||
@pytest.mark.parametrize("anyio_backend", ["asyncio"])
|
||||
async def test_sqlite_expired(anyio_backend):
|
||||
+ if anysqlite is None: # pragma: no cover
|
||||
+ pytest.skip("anysqlite not installed")
|
||||
storage = AsyncSQLiteStorage(ttl=0.1, connection=await anysqlite.connect(":memory:"))
|
||||
first_request = Request(b"GET", "https://example.com")
|
||||
second_request = Request(b"GET", "https://anotherexample.com")
|
||||
@@ -271,6 +292,8 @@ async def test_sqlite_expired(anyio_backend):
|
||||
@pytest.mark.xfail
|
||||
@pytest.mark.parametrize("anyio_backend", ["asyncio"])
|
||||
async def test_sqlite_ttl_after_hits(use_temp_dir, anyio_backend):
|
||||
+ if anysqlite is None: # pragma: no cover
|
||||
+ pytest.skip("anysqlite not installed")
|
||||
storage = AsyncSQLiteStorage(ttl=0.2)
|
||||
|
||||
request = Request(b"GET", "https://example.com")
|
||||
@@ -390,6 +413,8 @@ async def test_filestorage_remove(use_temp_dir):
|
||||
|
||||
@pytest.mark.parametrize("anyio_backend", ["asyncio"])
|
||||
async def test_redisstorage_remove(anyio_backend):
|
||||
+ if redis is None: # pragma: no cover
|
||||
+ pytest.skip("redis not installed")
|
||||
if await is_redis_down(): # pragma: no cover
|
||||
pytest.fail("Redis server was not found")
|
||||
|
||||
@@ -408,6 +433,8 @@ async def test_redisstorage_remove(anyio_backend):
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_sqlitestorage_remove():
|
||||
+ if anysqlite is None: # pragma: no cover
|
||||
+ pytest.skip("anysqlite not installed")
|
||||
storage = AsyncSQLiteStorage(connection=await anysqlite.connect(":memory:"))
|
||||
request = Request(b"GET", "https://example.com")
|
||||
|
||||
diff --git a/tests/_sync/test_storages.py b/tests/_sync/test_storages.py
|
||||
index 43151de..16c8336 100644
|
||||
--- a/tests/_sync/test_storages.py
|
||||
+++ b/tests/_sync/test_storages.py
|
||||
@@ -2,7 +2,6 @@ import datetime
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
-import sqlite3
|
||||
import pytest
|
||||
from httpcore import Request, Response
|
||||
|
||||
@@ -10,6 +9,16 @@ from hishel import FileStorage, InMemoryStorage, RedisStorage, SQLiteStorage
|
||||
from hishel._serializers import Metadata
|
||||
from hishel._utils import sleep, generate_key
|
||||
|
||||
+try:
|
||||
+ import sqlite3
|
||||
+except ImportError:
|
||||
+ sqlite3 = None # type: ignore
|
||||
+
|
||||
+try:
|
||||
+ import redis
|
||||
+except ImportError:
|
||||
+ redis = None # type: ignore
|
||||
+
|
||||
dummy_metadata = Metadata(cache_key="test", number_of_uses=0, created_at=datetime.datetime.now(datetime.timezone.utc))
|
||||
|
||||
|
||||
@@ -48,6 +57,8 @@ def test_filestorage(use_temp_dir):
|
||||
|
||||
|
||||
def test_redisstorage(anyio_backend):
|
||||
+ if redis is None: # pragma: no cover
|
||||
+ pytest.skip("redis is not installed")
|
||||
if is_redis_down(): # pragma: no cover
|
||||
pytest.fail("Redis server was not found")
|
||||
storage = RedisStorage()
|
||||
@@ -73,6 +84,8 @@ def test_redisstorage(anyio_backend):
|
||||
|
||||
|
||||
def test_sqlitestorage():
|
||||
+ if sqlite3 is None: # pragma: no cover
|
||||
+ pytest.skip("sqlite3 not installed")
|
||||
storage = SQLiteStorage(connection=sqlite3.connect(":memory:"))
|
||||
|
||||
request = Request(b"GET", "https://example.com")
|
||||
@@ -196,6 +209,8 @@ def test_filestorage_ttl_after_hits(use_temp_dir, anyio_backend):
|
||||
|
||||
|
||||
def test_redisstorage_expired(anyio_backend):
|
||||
+ if redis is None: # pragma: no cover
|
||||
+ pytest.skip("redis is not installed")
|
||||
if is_redis_down(): # pragma: no cover
|
||||
pytest.fail("Redis server was not found")
|
||||
storage = RedisStorage(ttl=0.1)
|
||||
@@ -219,6 +234,10 @@ def test_redisstorage_expired(anyio_backend):
|
||||
|
||||
|
||||
def test_redis_ttl_after_hits(use_temp_dir, anyio_backend):
|
||||
+ if redis is None: # pragma: no cover
|
||||
+ pytest.skip("redis not installed")
|
||||
+ if is_redis_down(): # pragma: no cover
|
||||
+ pytest.fail("Redis server was not found")
|
||||
storage = RedisStorage(ttl=0.2)
|
||||
|
||||
request = Request(b"GET", "https://example.com")
|
||||
@@ -249,6 +268,8 @@ def test_redis_ttl_after_hits(use_temp_dir, anyio_backend):
|
||||
|
||||
|
||||
def test_sqlite_expired(anyio_backend):
|
||||
+ if sqlite3 is None: # pragma: no cover
|
||||
+ pytest.skip("sqlite3 not installed")
|
||||
storage = SQLiteStorage(ttl=0.1, connection=sqlite3.connect(":memory:"))
|
||||
first_request = Request(b"GET", "https://example.com")
|
||||
second_request = Request(b"GET", "https://anotherexample.com")
|
||||
@@ -271,6 +292,8 @@ def test_sqlite_expired(anyio_backend):
|
||||
@pytest.mark.xfail
|
||||
|
||||
def test_sqlite_ttl_after_hits(use_temp_dir, anyio_backend):
|
||||
+ if sqlite3 is None: # pragma: no cover
|
||||
+ pytest.skip("sqlite3 not installed")
|
||||
storage = SQLiteStorage(ttl=0.2)
|
||||
|
||||
request = Request(b"GET", "https://example.com")
|
||||
@@ -390,6 +413,8 @@ def test_filestorage_remove(use_temp_dir):
|
||||
|
||||
|
||||
def test_redisstorage_remove(anyio_backend):
|
||||
+ if redis is None: # pragma: no cover
|
||||
+ pytest.skip("redis not installed")
|
||||
if is_redis_down(): # pragma: no cover
|
||||
pytest.fail("Redis server was not found")
|
||||
|
||||
@@ -408,6 +433,8 @@ def test_redisstorage_remove(anyio_backend):
|
||||
|
||||
|
||||
def test_sqlitestorage_remove():
|
||||
+ if sqlite3 is None: # pragma: no cover
|
||||
+ pytest.skip("sqlite3 not installed")
|
||||
storage = SQLiteStorage(connection=sqlite3.connect(":memory:"))
|
||||
request = Request(b"GET", "https://example.com")
|
||||
|
||||
diff --git a/tests/test_serializers.py b/tests/test_serializers.py
|
||||
index d22ed0a..cf7df2f 100644
|
||||
--- a/tests/test_serializers.py
|
||||
+++ b/tests/test_serializers.py
|
||||
@@ -1,5 +1,6 @@
|
||||
import datetime
|
||||
|
||||
+import pytest
|
||||
from httpcore import Request, Response
|
||||
|
||||
from hishel._serializers import (
|
||||
@@ -10,6 +11,11 @@ from hishel._serializers import (
|
||||
)
|
||||
from hishel._utils import normalized_url
|
||||
|
||||
+try:
|
||||
+ import yaml
|
||||
+except ImportError:
|
||||
+ yaml = None # type: ignore
|
||||
+
|
||||
|
||||
def test_pickle_serializer_dumps_and_loads():
|
||||
request = Request(
|
||||
@@ -192,6 +198,8 @@ def test_dict_serializer_loads():
|
||||
|
||||
|
||||
def test_yaml_serializer_dumps():
|
||||
+ if yaml is None: # pragma: no cover
|
||||
+ pytest.skip("yaml not installed")
|
||||
request = Request(
|
||||
method="GET",
|
||||
url="https://example.com",
|
||||
@@ -248,6 +256,8 @@ def test_yaml_serializer_dumps():
|
||||
|
||||
|
||||
def test_yaml_serializer_loads():
|
||||
+ if yaml is None: # pragma: no cover
|
||||
+ pytest.skip("yaml not installed")
|
||||
raw_response = "\n".join(
|
||||
[
|
||||
"response:",
|
||||
--
|
||||
2.50.0
|
||||
|
20
srcpkgs/python3-hishel/template
Normal file
20
srcpkgs/python3-hishel/template
Normal file
|
@ -0,0 +1,20 @@
|
|||
# Template file for 'python3-hishel'
|
||||
pkgname=python3-hishel
|
||||
version=0.1.2
|
||||
revision=1
|
||||
build_style=python3-pep517
|
||||
hostmakedepends="python3 hatch hatch-fancy-pypi-readme"
|
||||
makedepends="python3 hatch hatch-fancy-pypi-readme"
|
||||
depends="python3-httpx"
|
||||
checkdepends="python3-pytest python3-trio"
|
||||
short_desc="Elegant HTTP Cache implementation for httpx and httpcore"
|
||||
maintainer="Komeil Parseh <komeilparseh@disroot.org>"
|
||||
license="BSD-3-Clause"
|
||||
homepage="https://github.com/karpetrosyan/hishel"
|
||||
changelog="${homepage}/raw/refs/heads/master/CHANGELOG.md"
|
||||
distfiles="${homepage}/archive/refs/tags/${version}.tar.gz"
|
||||
checksum=ee41e09d18d0b6c63d87797def3c3825dbedf871664764d7afbd0cc0305fa317
|
||||
|
||||
post_install() {
|
||||
vlicense LICENSE
|
||||
}
|
Loading…
Add table
Reference in a new issue