Beispiel #1
0
    def test_has_expired(self, tmpdir):
        c = cache.SqliteCache(path=tmpdir.join("sqlite.cache.db").strpath)
        c.add("http://tests.python-zeep.org/example.wsdl", b"content")

        freeze_dt = datetime.datetime.utcnow() + datetime.timedelta(seconds=7200)
        with freezegun.freeze_time(freeze_dt):
            result = c.get("http://tests.python-zeep.org/example.wsdl")
            assert result is None
Beispiel #2
0
def test_sqlite_cache_timeout(tmpdir):
    c = cache.SqliteCache(path=tmpdir.join('sqlite.cache.db').strpath)
    c.add('http://tests.python-zeep.org/example.wsdl', b'content')
    result = c.get('http://tests.python-zeep.org/example.wsdl')
    assert result == b'content'

    freeze_dt = datetime.datetime.utcnow() + datetime.timedelta(seconds=7200)
    with freezegun.freeze_time(freeze_dt):
        result = c.get('http://tests.python-zeep.org/example.wsdl')
        assert result is None
Beispiel #3
0
def test_cache_timeout():
    c = cache.SqliteCache(path=':memory:')
    c.add('http://tests.python-zeep.org/example.wsdl', b'content')
    result = c.get('http://tests.python-zeep.org/example.wsdl')
    assert result == b'content'

    freeze_dt = datetime.datetime.utcnow() + datetime.timedelta(seconds=7200)
    with freezegun.freeze_time(freeze_dt):
        result = c.get('http://tests.python-zeep.org/example.wsdl')
        assert result is None
Beispiel #4
0
def test_sqlite_cache(tmpdir):
    c = cache.SqliteCache(path=tmpdir.join('sqlite.cache.db').strpath)
    c.add('http://tests.python-zeep.org/example.wsdl', b'content')

    result = c.get('http://tests.python-zeep.org/example.wsdl')
    assert result == b'content'
def test_sqlite_cache(tmpdir):
    c = cache.SqliteCache(path=tmpdir.join("sqlite.cache.db").strpath)
    c.add("http://tests.python-zeep.org/example.wsdl", b"content")

    result = c.get("http://tests.python-zeep.org/example.wsdl")
    assert result == b"content"
Beispiel #6
0
def test_custom_cache():
    transport = transports.Transport(cache=cache.SqliteCache())
    assert isinstance(transport.cache, cache.SqliteCache)
Beispiel #7
0
 def test_no_records(self, tmpdir):
     c = cache.SqliteCache(path=tmpdir.join("sqlite.cache.db").strpath)
     result = c.get("http://tests.python-zeep.org/example.wsdl")
     assert result is None
Beispiel #8
0
 def test_in_memory(self):
     with pytest.raises(ValueError):
         cache.SqliteCache(path=":memory:")
Beispiel #9
0
def test_cache():
    c = cache.SqliteCache(path=':memory:')
    c.add('http://tests.python-zeep.org/example.wsdl', b'content')

    result = c.get('http://tests.python-zeep.org/example.wsdl')
    assert result == b'content'