Commit 587dbf8a authored by Georges Racinet's avatar Georges Racinet 🦑
Browse files

Heptapod: preparing to store User instances

Having real `User` instances on the `Heptapod` object has been
on the radar since the `User` class was created.

Many places in the test utils and at most a few in the tests
themselves access the `Heptapod.users` dictionary.

It's therefore a bit too much for now to convert all these to
fetch a User instance directly, but the new `Heptapod.get_user()`
method will help us transitioning progressively.
parent 6cffadeb99cd
......@@ -106,6 +106,25 @@ class Heptapod:
def basic_user_token_headers(self):
return {'Private-Token': self.users['test_basic']['token']}
def get_user(self, name):
"""Return a :class:`User` instance, or `None`."""
info = self.users.get(name)
if info is None:
return None
user_id = info.get('id')
password = info.get('password')
if user_id is None:
logger.info(
"Searching for known user %r because its id is unknown.",
name)
user = User.search(self, name)
user.password = password
user.store_in_heptapod()
return user
return User(heptapod=self, id=user_id, name=name, password=password)
def new_webdriver(self):
options = selenium.webdriver.ChromeOptions()
options.add_argument('--headless')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment