# Path: anom/model.py
# def get_multi(keys):
#     """Get a set of entities from Datastore by their respective keys.
# 
#     Note:
#       This uses the adapter that is tied to the first model in the
#       list.  If the keys have disparate adapters this function may
#       behave in unexpected ways.
# 
#     Warning:
#       You must pass a **list** and not a generator or some other kind
#       of iterable to this function as it has to iterate over the list
#       of keys multiple times.
# 
#     Parameters:
#       keys(list[anom.Key]): The list of keys whose entities to get.
# 
#     Raises:
#       RuntimeError: If the given set of keys have models that use
#         a disparate set of adapters or if any of the keys are
#         partial.
# 
#     Returns:
#       list[Model]: Entities that do not exist are going to be None
#       in the result list.  The order of results matches the order
#       of the input keys.
#     """
#     if not keys:
#         return []
# 
#     adapter = None
#     for key in keys:
#         if key.is_partial:
#             raise RuntimeError(f"Key {key!r} is partial.")
# 
#         model = lookup_model_by_kind(key.kind)
#         if adapter is None:
#             adapter = model._adapter
# 
#         model.pre_get_hook(key)
# 
#     entities_data, entities = adapter.get_multi(keys), []
#     for key, entity_data in zip(keys, entities_data):
#         if entity_data is None:
#             entities.append(None)
#             continue
# 
#         # Micro-optimization to avoid calling get_model.  This is OK
#         # to do here because we've already proved that a model for
#         # that kind exists in the previous block.
#         model = _known_models[key.kind]
#         entity = model._load(key, entity_data)
#         entities.append(entity)
#         entity.post_get_hook()
# 
#     return entities


import pytest
from anom import get_multi
from concurrent.futures import ThreadPoolExecutor
from . import models




def test_get_multi_retrieves_cached_and_non_cached_entities(memcache_adapter):
    person_1 = models.Person(email="someone@example.com", first_name="Person 1").put()
    person_2 = models.Person(email="someone.else@example.com", first_name="Person 2").put()

    for _ in range(2):
        assert get_multi([person_1.key]) == [person_1]

# Path: anom/model.py
# def get_multi(keys):
#     """Get a set of entities from Datastore by their respective keys.
# 
#     Note:
#       This uses the adapter that is tied to the first model in the
#       list.  If the keys have disparate adapters this function may
#       behave in unexpected ways.
# 
#     Warning:
#       You must pass a **list** and not a generator or some other kind
#       of iterable to this function as it has to iterate over the list
#       of keys multiple times.
# 
#     Parameters:
#       keys(list[anom.Key]): The list of keys whose entities to get.
# 
#     Raises:
#       RuntimeError: If the given set of keys have models that use
#         a disparate set of adapters or if any of the keys are
#         partial.
# 
#     Returns:
#       list[Model]: Entities that do not exist are going to be None
#       in the result list.  The order of results matches the order
#       of the input keys.
#     """
#     if not keys:
#         return []
# 
#     adapter = None
#     for key in keys:
#         if key.is_partial:
#             raise RuntimeError(f"Key {key!r} is partial.")
# 
#         model = lookup_model_by_kind(key.kind)
#         if adapter is None:
#             adapter = model._adapter
# 
#         model.pre_get_hook(key)
# 
#     entities_data, entities = adapter.get_multi(keys), []
#     for key, entity_data in zip(keys, entities_data):
#         if entity_data is None:
#             entities.append(None)
#             continue
# 
#         # Micro-optimization to avoid calling get_model.  This is OK
#         # to do here because we've already proved that a model for
#         # that kind exists in the previous block.
#         model = _known_models[key.kind]
#         entity = model._load(key, entity_data)
#         entities.append(entity)
#         entity.post_get_hook()
# 
#     return entities


# Path: tests/test_memcache.py
import pytest
from anom import get_multi
from concurrent.futures import ThreadPoolExecutor
from . import models





def test_get_multi_retrieves_cached_and_non_cached_entities(memcache_adapter):
    person_1 = models.Person(email="someone@example.com", first_name="Person 1").put()
    person_2 = models.Person(email="someone.else@example.com", first_name="Person 2").put()

    for _ in range(2):
        assert get_multi([person_1.key]) == [person_1]

        assert get_multi([person_1.key, person_2.key]) == [person_1, person_2]