"""Test using online images in VASL scenarios.""" import re import pytest from selenium.webdriver.common.action_chains import ActionChains from vasl_templates.webapp.tests.utils import init_webapp, select_tab, \ find_child, find_children, click_dialog_button, wait_for_clipboard, wait_for_elem from vasl_templates.webapp.tests.test_user_settings import set_user_settings, \ SCENARIO_IMAGES_SOURCE_THIS_PROGRAM, SCENARIO_IMAGES_SOURCE_INTERNET from vasl_templates.webapp.tests.test_scenario_persistence import load_scenario # --------------------------------------------------------------------- @pytest.mark.skipif( not pytest.config.option.vasl_mods, #pylint: disable=no-member reason = "--vasl-mods not specified" ) def test_online_images( webapp, webdriver ): """Test using online images in VASL scenarios.""" # initialize init_webapp( webapp, webdriver, scenario_persistence=1, reset = lambda ct: ct.set_data_dir( dtype="real" ) \ .set_vasl_mod( vmod="random" ) \ .set_default_template_pack( dname="real" ) ) # load the test scenario load_scenario( { "PLAYER_1": "german", "OB_VEHICLES_1": [ { "name": "PzKpfw IVH" } ], } ) # configure the user settings set_user_settings( { "include-flags-in-snippets": True, "custom-list-bullets": True, "include-vasl-images-in-snippets": True, } ) def do_test( snippet_id, expected1, expected2 ): #pylint: disable=missing-docstring # generate the snippet with online images enabled set_user_settings( { "scenario-images-source": SCENARIO_IMAGES_SOURCE_INTERNET } ) btn = find_child( "button[data-id='{}']".format( snippet_id ) ) btn.click() wait_for_clipboard( 2, expected1 ) # generate the snippet with online images disabled set_user_settings( { "scenario-images-source": SCENARIO_IMAGES_SOURCE_THIS_PROGRAM } ) btn.click() wait_for_clipboard( 2, expected2 ) # test player flags do_test( "players", re.compile( r'