def __init__(self, cache_url: Union[CacheURL, str],
              **options: Any) -> None:
     self._cache_url = CacheURL(cache_url)
     self._options = options
     self._pool = None
     self.namespace = 'default'
     self.set_name = 'default'
Exemple #2
0
def test_hostname_is_taken_from_url():
    url = CacheURL("dummy://localhost")
    assert url.hostname == "localhost"
Exemple #3
0
def test_url_obj_can_be_compared_to_other_url_obj():
    url_str = "redis://localhost:6379"
    assert CacheURL(url_str) == CacheURL(url_str)
    assert CacheURL(url_str) != CacheURL("dummy://")
Exemple #4
0
def test_url_obj_can_be_compared_to_str():
    url_str = "redis://localhost:6379"
    url = CacheURL(url_str)
    assert url == url_str
    assert url != "dummy://"
Exemple #5
0
def test_url_obj_has_repr():
    url = CacheURL("dummy://")
    assert repr(url)
Exemple #6
0
def test_url_obj_can_be_converted_back_to_str():
    url_str = "redis://localhost:6379"
    url = CacheURL(url_str)
    assert str(url) == url_str
Exemple #7
0
def test_options_are_empty_dict_if_url_has_no_querystring():
    url = CacheURL("redis://localhost/0")
    assert url.options == {}
Exemple #8
0
def test_options_are_taken_from_url_querystring():
    url = CacheURL("redis://localhost/0?minsize=5&key_prefix=test")
    assert url.options == {"minsize": "5", "key_prefix": "test"}
Exemple #9
0
def test_none_is_returned_for_database_if_its_not_set():
    url = CacheURL("redis://localhost/")
    assert url.database is None
Exemple #10
0
def test_database_is_taken_from_url():
    url = CacheURL("redis://localhost/0")
    assert url.database == "0"
Exemple #11
0
def test_none_is_returned_for_netloc_if_its_not_set():
    url = CacheURL("redis://")
    assert url.netloc is None
Exemple #12
0
def test_backend_is_taken_from_url_protocol():
    url = CacheURL("dummy://")
    assert url.backend == "dummy"
Exemple #13
0
def test_netloc_is_taken_from_url():
    url = CacheURL("redis://localhost:6379")
    assert url.netloc == "localhost:6379"
Exemple #14
0
def test_none_is_returned_for_port_if_its_not_set():
    url = CacheURL("redis://localhost")
    assert url.port is None
Exemple #15
0
def test_port_is_taken_from_url():
    url = CacheURL("redis://localhost:6379")
    assert url.port == 6379
Exemple #16
0
def test_none_is_returned_for_hostname_if_its_not_set():
    url = CacheURL("dummy://")
    assert url.hostname is None