Beispiel #1
0
 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'
Beispiel #2
0
def test_hostname_is_taken_from_url():
    url = CacheURL("dummy://localhost")
    assert url.hostname == "localhost"
Beispiel #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://")
Beispiel #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://"
Beispiel #5
0
def test_url_obj_has_repr():
    url = CacheURL("dummy://")
    assert repr(url)
Beispiel #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
Beispiel #7
0
def test_options_are_empty_dict_if_url_has_no_querystring():
    url = CacheURL("redis://localhost/0")
    assert url.options == {}
Beispiel #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"}
Beispiel #9
0
def test_none_is_returned_for_database_if_its_not_set():
    url = CacheURL("redis://localhost/")
    assert url.database is None
Beispiel #10
0
def test_database_is_taken_from_url():
    url = CacheURL("redis://localhost/0")
    assert url.database == "0"
Beispiel #11
0
def test_none_is_returned_for_netloc_if_its_not_set():
    url = CacheURL("redis://")
    assert url.netloc is None
Beispiel #12
0
def test_backend_is_taken_from_url_protocol():
    url = CacheURL("dummy://")
    assert url.backend == "dummy"
Beispiel #13
0
def test_netloc_is_taken_from_url():
    url = CacheURL("redis://localhost:6379")
    assert url.netloc == "localhost:6379"
Beispiel #14
0
def test_none_is_returned_for_port_if_its_not_set():
    url = CacheURL("redis://localhost")
    assert url.port is None
Beispiel #15
0
def test_port_is_taken_from_url():
    url = CacheURL("redis://localhost:6379")
    assert url.port == 6379
Beispiel #16
0
def test_none_is_returned_for_hostname_if_its_not_set():
    url = CacheURL("dummy://")
    assert url.hostname is None