Skip to content

Commit

Permalink
chore: clean up control flow
Browse files Browse the repository at this point in the history
  • Loading branch information
DerekMaggio committed Dec 21, 2023
1 parent a28ee27 commit 0c339a6
Showing 1 changed file with 12 additions and 18 deletions.
30 changes: 12 additions & 18 deletions app-testing/tests/protocol_analyze_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from automation.pages.protocol_landing import ProtocolLanding
from rich.console import Console
from selenium.webdriver.chrome.webdriver import WebDriver
from selenium.webdriver.remote.webelement import WebElement


def _what_protocols() -> list[Protocol]:
Expand Down Expand Up @@ -39,6 +40,13 @@ def _what_protocols() -> list[Protocol]:
return tests


def get_error_text(protocol_landing: ProtocolLanding, error_link: WebElement) -> str:
protocol_landing.base.click_webelement(error_link)
error_details = protocol_landing.get_popout_error().text
protocol_landing.click_popout_close()
return error_details


@pytest.mark.parametrize(
"protocol",
_what_protocols(),
Expand Down Expand Up @@ -91,26 +99,12 @@ def test_analyses(
), f"Analysis took more than {analysis_timeout} seconds."

# look for analysis error if the protocol should have one
error_link = protocol_landing.get_error_details_safe()
if protocol.app_error:
error_link = protocol_landing.get_error_details_safe()

assert error_link is not None, "No analysis error but was expecting one."
protocol_landing.base.click_webelement(error_link)
error_details = protocol_landing.get_popout_error().text
try:
assert error_details == protocol.app_analysis_error
except AssertionError:
raise
finally:
protocol_landing.click_popout_close()
else:
error_link = protocol_landing.get_error_details_safe()

if error_link is not None:
protocol_landing.base.click_webelement(error_link)
error_details = protocol_landing.get_popout_error().text
protocol_landing.click_popout_close()
raise AssertionError(f"Unexpected analysis error: {error_details}")
assert get_error_text(protocol_landing, error_link) == protocol.app_analysis_error
elif error_link is not None:
raise AssertionError(f"Unexpected analysis error: {get_error_text(protocol_landing, error_link)}")

# Verifying elements on Protocol Landing Page
# todo fix next line needs to be safe and print name not found
Expand Down

0 comments on commit 0c339a6

Please sign in to comment.