Exemplo n.º 1
0
 def _setup_connector(self, response, cache=None, remaining_keys=None):
     cache = cache or {}
     remaining_keys = remaining_keys or set()
     counter = create_mock_full({"inc()": self.REQ_ID})
     connector = SCIONDConnector("addr", counter)
     connector._create_socket = create_mock()
     connector._get_response = create_mock_full(return_value=response)
     connector._try_cache = create_mock_full(return_value=(remaining_keys,
                                                           cache))
     return connector
Exemplo n.º 2
0
 def _setup_connector(self, svc_info_desc=None):
     counter = create_mock_full({"inc()": 1})
     connector = SCIONDConnector("addr", counter)
     if svc_info_desc:
         svc_info = create_mock_full({"host_info()": svc_info_desc[1]})
         connector.get_service_info = create_mock_full(
             return_value={svc_info_desc[0]: svc_info})
     else:
         connector.get_service_info = create_mock()
     return connector
Exemplo n.º 3
0
 def test_partial_hit(self):
     cache = {1: "a", 3: "c"}
     key_list = [1, 2]
     # Call
     ntools.eq_(SCIONDConnector._try_cache(cache, key_list), ({2}, {
         1: "a"
     }))
Exemplo n.º 4
0
 def test_duplicate_keys(self):
     cache = {1: "a", 2: "b", 3: "c"}
     key_list = [1, 2, 1, 2]
     # Call
     ntools.eq_(SCIONDConnector._try_cache(cache, key_list), (set(), {
         1: "a",
         2: "b"
     }))
Exemplo n.º 5
0
 def test_empty_key_list(self):
     cache = {1: "a", 2: "b", 3: "c"}
     key_list = []
     # Call
     ntools.eq_(SCIONDConnector._try_cache(cache, key_list), (set(), {}))
Exemplo n.º 6
0
 def test_empty_cache(self):
     cache = {}
     key_list = [1, 2]
     # Call
     ntools.eq_(SCIONDConnector._try_cache(cache, key_list), ({1, 2}, {}))