From 16aa5af2fef8f0d127fc2264d1843a8f2a79380d Mon Sep 17 00:00:00 2001 From: Taka Date: Thu, 23 Aug 2018 07:10:31 +0000 Subject: [PATCH] Fixed some timing issues in the tests. --- vasl_templates/webapp/tests/test_ob.py | 10 ++++++---- vasl_templates/webapp/tests/test_snippets.py | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/vasl_templates/webapp/tests/test_ob.py b/vasl_templates/webapp/tests/test_ob.py index 3042e7c..8e90cfa 100644 --- a/vasl_templates/webapp/tests/test_ob.py +++ b/vasl_templates/webapp/tests/test_ob.py @@ -8,7 +8,7 @@ from selenium.webdriver.support.ui import Select from vasl_templates.webapp.tests.utils import \ get_nationalities, get_clipboard, get_stored_msg, set_stored_msg_marker, select_tab, find_child, find_children, \ add_simple_note, edit_simple_note, get_sortable_entry_count, drag_sortable_entry_to_trash, \ - select_droplist_val, init_webapp + select_droplist_val, init_webapp, wait_for # --------------------------------------------------------------------- @@ -113,13 +113,15 @@ def test_nationality_specific( webapp, webdriver ): #pylint: disable=too-many-lo assert get_clipboard() == expected # check if a warning was issued last_warning = get_stored_msg( "_last-warning_" ) - image_url = find_child( "img", btn ).get_attribute( "src" ) if warning: assert "are only available" in last_warning - assert "snippet-disabled.png" in image_url + expected_image_url = "snippet-disabled.png" else: assert last_warning == marker - assert "snippet.png" in image_url + expected_image_url = "snippet.png" + wait_for( 2, + lambda: expected_image_url in find_child( "img", btn ).get_attribute( "src" ) + ) # initialize def check_pf_snippets(): diff --git a/vasl_templates/webapp/tests/test_snippets.py b/vasl_templates/webapp/tests/test_snippets.py index 594a9ea..6f12961 100644 --- a/vasl_templates/webapp/tests/test_snippets.py +++ b/vasl_templates/webapp/tests/test_snippets.py @@ -4,7 +4,7 @@ from selenium.webdriver.common.keys import Keys from vasl_templates.webapp.tests.utils import \ init_webapp, select_tab, set_template_params, get_clipboard, \ - get_stored_msg, set_stored_msg_marker, find_child, \ + get_stored_msg, set_stored_msg_marker, find_child, wait_for, \ for_each_template, add_simple_note, edit_simple_note, \ get_sortable_entry_count, generate_sortable_entry_snippet, drag_sortable_entry_to_trash @@ -184,7 +184,7 @@ def test_edit_templates( webapp, webdriver ): # check that the new template is being used elem = find_child( "button.generate[data-id='{}']".format( orig_template_id ) ) elem.click() - assert get_clipboard() == "EDITED TEMPLATE: {}".format( orig_template_id ) + wait_for( 2, lambda: get_clipboard() == "EDITED TEMPLATE: {}".format( orig_template_id ) ) for_each_template( test_template ) # customize the SCENARIO NOTE template