This instance will be upgraded to Heptapod 0.26.0rc1 on 2021-10-25 at 14:00 UTC+2 (a few minutes of down time)

Commit c573dd3b authored by Georges Racinet's avatar Georges Racinet 🦑
Browse files

session, User: avoid ambiguity in login flow

The `session` module should be about lower level, not
object-oriented, primitives that don't care about
caching of web drivers and generally maintaining state.

The `login_as_user()` method did not fit there, because
it called to the Heptapod object, which does exactly that.
This was an ambiguity, that could easily lead to infinite
loops when developping new features.

It is a better fit on the `User` class. Actually the next
natural move would be to make `webdriver` a property, renaming
the current attribute to `_webdriver` as already done with

The only caller, in `test_projects`, is updated by this.
parent c864f293f2a1
......@@ -9,7 +9,6 @@ import tarfile
from .utils import (
from .utils.project import (
......@@ -333,7 +332,7 @@ def test_housekeeping(test_project):
def test_external_user_can_create_project(test_group, external_user):
heptapod = test_group.heptapod
webdriver = session.login_as_user(external_user)
webdriver = external_user.signed_in_webdriver()
# if the external user has no group, there's no link to create a project.
# note that the "+" menu title itself is such a link
......@@ -109,11 +109,3 @@ def make_webdriver(heptapod, user_name, password):"Made signed-in webdriver for user %s in %.2f seconds",
user_name, time.time() - start)
return driver
def login_as_user(user):
"""Return a Selenium webdriver, authentified as user
:param user: a `User` instance
return user.heptapod.get_user_webdriver(
......@@ -79,6 +79,13 @@ class User(object):
def store_in_heptapod(self):
self.heptapod.users[] = self
def signed_in_webdriver(self):
"""Return a Selenium webdriver, authentified as self.
Actual sign in sequence is performed only if not already done.
return self.heptapod.get_user_webdriver(
def api_request(self, method, subpath=None, **data):
"""Perform a request on user API as root"""
hepta = self.heptapod
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