mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-10 03:23:04 +00:00

behaves more like one would expect (same as try get-key, except: return default) without relying on cache presence or underlying key type (integer only)
23 lines
541 B
Python
23 lines
541 B
Python
import pytest
|
|
|
|
from ..user import UserDict
|
|
from .utils import add_user
|
|
|
|
|
|
@pytest.mark.parametrize("attr", ["self", "id", "name"])
|
|
async def test_userdict_get(db, attr):
|
|
u = add_user(db, name="rey", app=False)
|
|
userdict = UserDict(db_factory=lambda: db, settings={})
|
|
|
|
if attr == "self":
|
|
key = u
|
|
else:
|
|
key = getattr(u, attr)
|
|
|
|
# `in` checks cache only
|
|
assert key not in userdict
|
|
assert userdict.get(key)
|
|
assert userdict.get(key).id == u.id
|
|
# `in` should find it now
|
|
assert key in userdict
|