Add product-specific session and token setup
This commit is contained in:
@@ -6,16 +6,10 @@ import pytest
|
||||
|
||||
from tests.step_actions import StepActions
|
||||
from tests.helpers import login, select_ui_dropdown
|
||||
from tests.config_reader import is_combined_setup_enabled, is_setup_session_enabled, load_config
|
||||
from tests.config_reader import get_setup_configs
|
||||
from tests.locators import Locator
|
||||
|
||||
|
||||
pytestmark = pytest.mark.skipif(
|
||||
is_combined_setup_enabled() or not is_setup_session_enabled(),
|
||||
reason="Standalone session setup is disabled or runs inside combined setup",
|
||||
)
|
||||
|
||||
|
||||
def get_session_window(config):
|
||||
|
||||
session_config = config.get("setup", {}).get("session", {})
|
||||
@@ -50,9 +44,8 @@ def create_session(driver, step, config):
|
||||
|
||||
|
||||
@pytest.mark.session
|
||||
def test_session(driver, test_context):
|
||||
|
||||
config = load_config()
|
||||
@pytest.mark.parametrize("config", get_setup_configs("session"), ids=lambda c: c["product_name"])
|
||||
def test_session(driver, test_context, config):
|
||||
|
||||
wait = WebDriverWait(driver, 20)
|
||||
|
||||
|
||||
@@ -1,26 +1,19 @@
|
||||
import pytest
|
||||
from selenium.webdriver.support.ui import WebDriverWait
|
||||
|
||||
from tests.config_reader import is_combined_setup_enabled, load_config
|
||||
from tests.config_reader import get_setup_configs
|
||||
from tests.helpers import login, logout, save_session_backup
|
||||
from tests.setup.sessions.test_session import create_session
|
||||
from tests.setup.tokens.test_trading_token import create_and_activate_token, get_product_codes
|
||||
from tests.step_actions import StepActions
|
||||
|
||||
|
||||
pytestmark = pytest.mark.skipif(
|
||||
not is_combined_setup_enabled(),
|
||||
reason="Combined setup requires setup.run_session and setup.run_token to both be true",
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.session
|
||||
@pytest.mark.trading_token
|
||||
def test_session_and_token_setup(driver, test_context):
|
||||
@pytest.mark.parametrize("config", get_setup_configs("combined"), ids=lambda c: c["product_name"])
|
||||
def test_session_and_token_setup(driver, test_context, config):
|
||||
|
||||
config = load_config()
|
||||
token = config.get("trading_token_idas")
|
||||
assert token, "Add trading_token_idas in config.json before running token setup."
|
||||
token = config["token"]
|
||||
|
||||
wait = WebDriverWait(driver, 20)
|
||||
step = StepActions(driver, wait, test_context)
|
||||
|
||||
@@ -4,7 +4,7 @@ import pytest
|
||||
from selenium.webdriver.common.by import By
|
||||
from selenium.webdriver.support.ui import WebDriverWait
|
||||
|
||||
from tests.config_reader import is_combined_setup_enabled, is_setup_token_enabled, load_config, parse_product_codes
|
||||
from tests.config_reader import get_setup_configs, parse_product_codes
|
||||
from tests.helpers import (
|
||||
click_visible_menu_item,
|
||||
click_first_grid_button,
|
||||
@@ -23,20 +23,10 @@ from tests.locators import Locator
|
||||
from tests.step_actions import StepActions
|
||||
|
||||
|
||||
pytestmark = pytest.mark.skipif(
|
||||
is_combined_setup_enabled() or not is_setup_token_enabled(),
|
||||
reason="Standalone token setup is disabled or runs inside combined setup",
|
||||
)
|
||||
|
||||
|
||||
def get_token_context(driver, test_context):
|
||||
|
||||
config = load_config()
|
||||
def get_token_context(driver, test_context, config):
|
||||
wait = WebDriverWait(driver, 20)
|
||||
step = StepActions(driver, wait, test_context)
|
||||
token = config.get("trading_token_idas")
|
||||
|
||||
assert token, "Add trading_token_idas in config.json before running this test."
|
||||
token = config["token"]
|
||||
|
||||
return config, step, token
|
||||
|
||||
@@ -88,7 +78,7 @@ def get_product_codes(token):
|
||||
return product_codes
|
||||
|
||||
product_code = token.get("product_code")
|
||||
assert product_code, "Add product_code or product_codes in config.json trading_token_idas."
|
||||
assert product_code, "Add product_code or product_codes in config.json products.<product>.token."
|
||||
return parse_product_codes(product_code)
|
||||
|
||||
|
||||
@@ -224,9 +214,10 @@ def create_and_activate_token(driver, step, token):
|
||||
|
||||
|
||||
@pytest.mark.trading_token
|
||||
def test_trading_token_creation_idas(driver, test_context):
|
||||
@pytest.mark.parametrize("config", get_setup_configs("token"), ids=lambda c: c["product_name"])
|
||||
def test_trading_token_creation(driver, test_context, config):
|
||||
|
||||
config, step, token = get_token_context(driver, test_context)
|
||||
config, step, token = get_token_context(driver, test_context, config)
|
||||
open_app_and_login(driver, step, config)
|
||||
save_session_backup(driver, test_context, "login_session_backup")
|
||||
|
||||
@@ -241,7 +232,7 @@ def test_trading_token_creation_idas(driver, test_context):
|
||||
# @pytest.mark.trading_token
|
||||
# def test_trading_token_time_session_edit_idas(driver, test_context):
|
||||
#
|
||||
# config, step, token = get_token_context(driver, test_context)
|
||||
# config, step, token = get_token_context(driver, test_context, config)
|
||||
# open_app_and_login(driver, step, config)
|
||||
#
|
||||
# next_day, _ = get_delivery_date_and_expiry(token)
|
||||
|
||||
Reference in New Issue
Block a user