コード例 #1
0
 def set_superuser_as_current_user(self):
     """Class fixtures are evaluated before function fixtures.
 This fixture is used by class `test_data` fixture so this one should be
 class as well.
 Code is copied from conftest.py.
 """
     # pylint: disable=protected-access
     users._current_user = users.FakeSuperUser()
     users.set_current_user(entities_factory.PeopleFactory.superuser)
コード例 #2
0
ファイル: run_selenium.py プロジェクト: zdqf/ggrc-core
def add_user(url_origin):
    """If two processes log in as a new user at the same time,
  the second login may fail because of a race condition in dev code
  (user_generator.py).
  We workaround this issue by creating a user not in parallel as this issue
  is considered not worth to fix by developers.
  """
    environment.app_url = url_origin
    environment.app_url = urlparse.urljoin(environment.app_url, "/")
    session = requests.Session()
    session.get(url_module.Urls().gae_login(users.FakeSuperUser()))
    session.get(url_module.Urls().login)
コード例 #3
0
def set_superuser_as_current_user():
    """Set super user as a current user"""
    # pylint: disable=protected-access
    users._current_user = users.FakeSuperUser()
    users.set_current_user(entities_factory.PeopleFactory.superuser)
コード例 #4
0
def chrome_options(chrome_options, pytestconfig):
    """Set configuration to run Chrome with specific options."""
    if selenium_utils.is_headless_chrome(pytestconfig):
        chrome_options.set_headless(True)
        chrome_options.add_argument("window-size={},{}".format(
            os.environ["SCREEN_WIDTH"], os.environ["SCREEN_HEIGHT"]))
    return chrome_options


# `PeopleFactory.superuser` uses `environment.app_url` and `current user`.
# It is used in @pytest.mark.parametrize parameters.
# Parametrize parameters are evaluated before fixtures so
# `environment.app_url` and `current user` should be already set.
environment.app_url = os.environ["DEV_URL"]
environment.app_url = urlparse.urljoin(environment.app_url, "/")
users.set_current_user(users.FakeSuperUser())


@pytest.fixture(autouse=True)
def set_superuser_as_current_user():
    """Set super user as a current user"""
    # pylint: disable=protected-access
    users._current_user = users.FakeSuperUser()
    users.set_current_user(entities_factory.PeopleFactory.superuser)


@pytest.fixture(autouse=True)
def reset_logged_in_users():
    """Reset cache of logged in users.
  This cache is used to check if user has already logged in.
  """