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