예제 #1
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"
     }))
예제 #2
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"
     }))
예제 #3
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
예제 #4
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(), {}))
예제 #5
0
 def test_empty_cache(self):
     cache = {}
     key_list = [1, 2]
     # Call
     ntools.eq_(SCIONDConnector._try_cache(cache, key_list), ({1, 2}, {}))