From 5da4ff4ff166200c14b2b0ab3f17056f01edd262 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Tue, 29 Sep 2020 00:27:58 +0200 Subject: [PATCH] e2e: further cleanup tests, directly navigate to user-settings instead of click --- e2e/test_flows_otp.py | 3 +-- e2e/test_provider_oauth2_github.py | 8 +------- e2e/test_source_oauth.py | 17 ++++++----------- e2e/test_source_saml.py | 6 +++--- passbook/flows/management/commands/benchmark.py | 4 ++-- passbook/lib/tasks.py | 2 +- 6 files changed, 14 insertions(+), 26 deletions(-) diff --git a/e2e/test_flows_otp.py b/e2e/test_flows_otp.py index fd9cfc8cc..75a4146c1 100644 --- a/e2e/test_flows_otp.py +++ b/e2e/test_flows_otp.py @@ -66,8 +66,7 @@ class TestFlowsOTP(SeleniumTestCase): ) self.driver.find_element(By.CSS_SELECTOR, ".pf-c-page__header").click() - self.driver.find_element(By.ID, "user-settings").click() - self.wait_for_url(self.url("passbook_core:user-settings")) + self.driver.get(self.url("passbook_core:user-settings")) self.driver.find_element(By.LINK_TEXT, "Time-based OTP").click() diff --git a/e2e/test_provider_oauth2_github.py b/e2e/test_provider_oauth2_github.py index b38dfd978..8eff0d0c5 100644 --- a/e2e/test_provider_oauth2_github.py +++ b/e2e/test_provider_oauth2_github.py @@ -149,13 +149,7 @@ class TestProviderOAuth2Github(SeleniumTestCase): "GitHub Compatibility: Access you Email addresses", self.driver.find_element(By.ID, "scope-user:email").text, ) - self.driver.find_element( - By.CSS_SELECTOR, - ( - "form[action='/flows/b/default-provider-authorization-explicit-consent/'] " - "[type=submit]" - ), - ).click() + self.driver.find_element(By.CSS_SELECTOR, ("[type=submit]"),).click() self.wait_for_url("http://localhost:3000/?orgId=1") self.driver.get("http://localhost:3000/profile") diff --git a/e2e/test_source_oauth.py b/e2e/test_source_oauth.py index 5ad145380..0b278e954 100644 --- a/e2e/test_source_oauth.py +++ b/e2e/test_source_oauth.py @@ -140,10 +140,9 @@ class TestSourceOAuth2(SeleniumTestCase): self.driver.find_element(By.NAME, "username").send_keys(Keys.ENTER) # Wait until we've loaded the user info page - self.wait.until(ec.presence_of_element_located((By.LINK_TEXT, "foo"))) - self.driver.find_element(By.LINK_TEXT, "foo").click() + self.wait.until(ec.presence_of_element_located((By.ID, "user-settings"))) + self.driver.get(self.url("passbook_core:user-settings")) - self.wait_for_url(self.url("passbook_core:user-settings")) self.assertEqual( self.driver.find_element(By.ID, "user-settings").text, "foo", ) @@ -222,11 +221,9 @@ class TestSourceOAuth2(SeleniumTestCase): ) self.driver.find_element(By.CSS_SELECTOR, "button[type=submit]").click() - # Wait until we've loaded the user info page - self.wait.until(ec.presence_of_element_located((By.LINK_TEXT, "foo"))) - self.driver.find_element(By.LINK_TEXT, "foo").click() + self.wait.until(ec.presence_of_element_located((By.ID, "user-settings"))) + self.driver.get(self.url("passbook_core:user-settings")) - self.wait_for_url(self.url("passbook_core:user-settings")) self.assertEqual( self.driver.find_element(By.ID, "user-settings").text, "foo", ) @@ -316,11 +313,9 @@ class TestSourceOAuth1(SeleniumTestCase): self.driver.find_element(By.CSS_SELECTOR, "[name='confirm']").click() # Wait until we've loaded the user info page - sleep(1) - self.wait.until(ec.presence_of_element_located((By.LINK_TEXT, "example-user"))) - self.driver.find_element(By.LINK_TEXT, "example-user").click() + self.wait.until(ec.presence_of_element_located((By.ID, "user-settings"))) + self.driver.get(self.url("passbook_core:user-settings")) - self.wait_for_url(self.url("passbook_core:user-settings")) self.assertEqual( self.driver.find_element(By.ID, "user-settings").text, "example-user", ) diff --git a/e2e/test_source_saml.py b/e2e/test_source_saml.py index b154c4b27..e5c0e96bc 100644 --- a/e2e/test_source_saml.py +++ b/e2e/test_source_saml.py @@ -131,7 +131,7 @@ class TestSourceSAML(SeleniumTestCase): # Wait until we're logged in self.wait.until(ec.presence_of_element_located((By.ID, "user-settings"))) - self.driver.find_element(By.ID, "user-settings").click() + self.driver.get(self.url("passbook_core:user-settings")) # Wait until we've loaded the user info page self.wait.until(ec.presence_of_element_located((By.ID, "id_username"))) @@ -180,7 +180,7 @@ class TestSourceSAML(SeleniumTestCase): # Wait until we're logged in self.wait.until(ec.presence_of_element_located((By.ID, "user-settings"))) - self.driver.find_element(By.ID, "user-settings").click() + self.driver.get(self.url("passbook_core:user-settings")) # Wait until we've loaded the user info page self.wait.until(ec.presence_of_element_located((By.ID, "id_username"))) @@ -227,7 +227,7 @@ class TestSourceSAML(SeleniumTestCase): # Wait until we're logged in self.wait.until(ec.presence_of_element_located((By.ID, "user-settings"))) - self.driver.find_element(By.ID, "user-settings").click() + self.driver.get(self.url("passbook_core:user-settings")) # Wait until we've loaded the user info page self.wait.until(ec.presence_of_element_located((By.ID, "id_username"))) diff --git a/passbook/flows/management/commands/benchmark.py b/passbook/flows/management/commands/benchmark.py index c949690c5..3d41e75af 100644 --- a/passbook/flows/management/commands/benchmark.py +++ b/passbook/flows/management/commands/benchmark.py @@ -18,7 +18,7 @@ from passbook.flows.planner import PLAN_CONTEXT_PENDING_USER, FlowPlanner LOGGER = get_logger() -class FlowPlanProcess(Process): +class FlowPlanProcess(Process): # pragma: no cover """Test process which executes flow planner""" def __init__(self, index, return_dict, flow, user) -> None: @@ -46,7 +46,7 @@ class FlowPlanProcess(Process): self.return_dict[self.index] = diffs -class Command(BaseCommand): +class Command(BaseCommand): # pragma: no cover """Benchmark passbook""" def add_arguments(self, parser): diff --git a/passbook/lib/tasks.py b/passbook/lib/tasks.py index d240d8337..8c451fc65 100644 --- a/passbook/lib/tasks.py +++ b/passbook/lib/tasks.py @@ -8,7 +8,7 @@ LOGGER = get_logger() @CELERY_APP.task() -def backup_database(): +def backup_database(): # pragma: no cover """Backup database""" management.call_command("dbbackup") LOGGER.info("Successfully backed up database.")