summaryrefslogtreecommitdiff
path: root/tests/integration/test_db.py
blob: 89ec31f385ddf19b830508afb6b4708047d75928 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from sqlalchemy import create_engine

from requests_cache import ALL_METHODS, CachedSession
from requests_cache.backends import DbCache, DbDict
from tests.integration.base_cache_test import BaseCacheTest
from tests.integration.base_storage_test import BaseStorageTest

# class TestDbDict(BaseStorageTest):
#     storage_class = DbDict


class TestDbCache(BaseCacheTest):
    backend_class = DbCache

    def init_session(self, clear=True, **kwargs) -> CachedSession:
        kwargs.setdefault('allowable_methods', ALL_METHODS)
        engine = create_engine('postgresql://postgres:hunter2@localhost:5432/postgres')
        backend = DbCache(engine, **kwargs)
        if clear:
            backend.clear()

        return CachedSession(backend=backend, **kwargs)