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