def send_wrong_password(the_config, page_signin) -> None:
    """I send the credential with a wrong password."""
    p_user = UserAdminFactory().initialize(the_config["data"]["users"])
    p_user.password = p_user.password + ' wrong password'
    page_signin.set_user(p_user)
    p_action = SigninAction(_page=page_signin)
    p_action.fill_credential().click()
def send_without_name(the_config, page_signin) -> None:
    """I send the credential without the name."""
    p_user = UserAdminFactory().initialize(the_config["data"]["users"])
    p_user.login = ''
    page_signin.set_user(p_user)
    p_action = SigninAction(_page=page_signin)
    p_action.fill_password().click()
def access_page(the_config, the_browser, type_user) -> None:
    """I sign in to the app."""
    p_page = SigninPage(_driver=the_browser,
                        _config=the_config['urls'],
                        _user=type_user)
    assert p_page.sign_out().visit() is True
    p_action = SigninAction(_page=p_page)
    p_action.fill_credential().click()
def permission(the_config, the_browser, type_user, permission) -> None:
    """I <permission> access to the main page."""
    assert isinstance(permission, str)
    p_page = SigninPage(_driver=the_browser,
                        _config=the_config['urls'],
                        _user=type_user)
    p_action = SigninAction(_page=p_page)
    if permission.lower() == 'can':
        assert p_action.connected() is True
    else:
        assert p_action.connected() is False
        assert p_action.has_failed() is True
Example #5
0
def sign_in(driver: DriverAPI,
            config: dict,
            user: str,
            password: str = '') -> bool:
    """Sign in.
        user= '******'"""
    switcher = {
        "admin": UserAdminFactory().initialize(config["data"]["users"]),
        "simple": UserSimpleFactory().initialize(config["data"]["users"]),
        "deactivated": UserClosedFactory().initialize(config["data"]["users"]),
    }
    d_user = {"login": user, "password": password}
    p_page = SigninPage(_driver=driver,
                        _config=config['urls'],
                        _user=switcher.get(
                            user,
                            UserDictFactory().initialize(d_user)))
    assert p_page.sign_out().visit() is True
    p_action = SigninAction(_page=p_page)
    p_action.fill_credential().click()
    return p_action.connected()
def error_message(page_signin) -> None:
    """I should see the error message."""
    p_action = SigninAction(_page=page_signin)
    assert p_action.has_failed() is True
def connect(page_signin) -> None:
    """I press the connect button."""
    p_action = SigninAction(_page=page_signin)
    p_action.click()