• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

yazmolod / pynspd / #12

28 Jul 2025 06:51PM UTC coverage: 95.698% (-1.9%) from 97.585%
#12

push

coveralls-python

yazmolod
bump version

5 of 5 new or added lines in 2 files covered. (100.0%)

71 existing lines in 5 files now uncovered.

2825 of 2952 relevant lines covered (95.7%)

0.96 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

71.74
/tests/_sync/test_cache.py
1
import os
1✔
2
import shutil
1✔
3
from pathlib import Path
1✔
4

5
import pytest
1✔
6
from hishel import InMemoryStorage, RedisStorage
1✔
7

8
from pynspd import Nspd
1✔
9

10

11
@pytest.fixture(scope="session")
1✔
12
def file_cache_api():
1✔
13
    with Nspd(cache_folder_path=".test.cache") as client:
1✔
14
        yield client
1✔
15
        shutil.rmtree(".test.cache")
1✔
16

17

18
@pytest.fixture(scope="session")
1✔
19
def sqlite_cache_api():
1✔
20
    cache_path = (Path.cwd() / ".test.cache.sqlite").resolve()
1✔
21
    with Nspd(cache_sqlite_url=cache_path) as client:
1✔
22
        yield client
1✔
23
    cache_path.unlink()
1✔
24

25

26
@pytest.fixture(scope="session")
1✔
UNCOV
27
def redis_cache_api():
×
UNCOV
28
    with Nspd(cache_redis_url=os.environ["REDIS_URL"], trust_env=False) as client:
×
29
        yield client
1✔
30
        cache: RedisStorage = client._cache_storage
1✔
31
        cache._client.flushdb()
1✔
32

33

34
@pytest.fixture(scope="session")
1✔
UNCOV
35
def custom_cache_api():
×
UNCOV
36
    with Nspd(cache_storage=InMemoryStorage()) as client:
×
37
        yield client
1✔
38

39

40
def request(api: Nspd):
1✔
41
    return api.request(
1✔
42
        "get",
43
        "/api/geoportal/v2/search/geoportal",
44
        params={
45
            "query": "77:02:0021001:5304",
46
            "thematicSearchId": 1,
47
        },
48
    )
49

50

UNCOV
51
def req_assertion(api: Nspd):
×
UNCOV
52
    r = request(api)
×
UNCOV
53
    assert not r.extensions["from_cache"]
×
54
    r = request(api)
1✔
55
    assert r.extensions["from_cache"]
1✔
56

57

58
def test_file_cache_client(file_cache_api: Nspd):
1✔
UNCOV
59
    req_assertion(file_cache_api)
×
60

61

62
def test_sqlite_cache_client(sqlite_cache_api: Nspd):
1✔
UNCOV
63
    req_assertion(sqlite_cache_api)
×
64

65

66
def test_redis_cache_client(redis_cache_api: Nspd):
1✔
UNCOV
67
    req_assertion(redis_cache_api)
×
68

69

70
def test_custom_cache_client(custom_cache_api: Nspd):
1✔
UNCOV
71
    req_assertion(custom_cache_api)
×
72

73

74
def test_multiple_cache_client():
1✔
UNCOV
75
    with pytest.raises(ValueError):
×
UNCOV
76
        with Nspd(cache_redis_url="foo", cache_sqlite_url="bar") as api:
×
77
            req_assertion(api)
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc