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