From 1a247260ff11377f77185f23b2e270cd4ed11f3e Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Mon, 9 Sep 2024 13:50:02 -0700 Subject: [PATCH] fix tests and flake8 --- notifications_utils/logging.py | 1 - tests/end_to_end/conftest.py | 14 ++++++-------- tests/end_to_end/test_accounts_page.py | 2 -- tests/end_to_end/test_create_new_template.py | 7 ------- .../test_invite_team_member_to_service.py | 2 -- .../test_send_message_from_existing_template.py | 8 +++----- 6 files changed, 9 insertions(+), 25 deletions(-) diff --git a/notifications_utils/logging.py b/notifications_utils/logging.py index 445f42529..d0c594c7e 100644 --- a/notifications_utils/logging.py +++ b/notifications_utils/logging.py @@ -6,7 +6,6 @@ from itertools import product from flask import g, request from flask.ctx import has_app_context, has_request_context -from flask.logging import default_handler from pythonjsonlogger.jsonlogger import JsonFormatter as BaseJSONFormatter LOG_FORMAT = ( diff --git a/tests/end_to_end/conftest.py b/tests/end_to_end/conftest.py index b3a73b103..750e9ae72 100644 --- a/tests/end_to_end/conftest.py +++ b/tests/end_to_end/conftest.py @@ -1,5 +1,4 @@ import os -import re import pytest @@ -19,7 +18,6 @@ def login_for_end_to_end_testing(browser): # Wait for the next page to fully load. page.wait_for_load_state("domcontentloaded") - print(f"PAGE ON CONFTEST AFTER SIGNIN IS {page}") # Save storage state into the file. auth_state_path = os.path.join( os.getenv("NOTIFY_E2E_AUTH_STATE_PATH"), "state.json" @@ -50,12 +48,12 @@ def end_to_end_context(browser): def pytest_generate_tests(metafunc): pass - #os.environ["DANGEROUS_SALT"] = os.getenv("E2E_DANGEROUS_SALT") - #os.environ["SECRET_KEY"] = os.getenv("E2E_SECRET_KEY") - #os.environ["ADMIN_CLIENT_SECRET"] = os.getenv("E2E_ADMIN_CLIENT_SECRET") - #os.environ["ADMIN_CLIENT_USERNAME"] = os.getenv("E2E_ADMIN_CLIENT_USERNAME") - #os.environ["NOTIFY_ENVIRONMENT"] = os.getenv("E2E_NOTIFY_ENVIRONMENT") - #os.environ["API_HOST_NAME"] = os.getenv("E2E_API_HOST_NAME") + # os.environ["DANGEROUS_SALT"] = os.getenv("E2E_DANGEROUS_SALT") + # os.environ["SECRET_KEY"] = os.getenv("E2E_SECRET_KEY") + # os.environ["ADMIN_CLIENT_SECRET"] = os.getenv("E2E_ADMIN_CLIENT_SECRET") + # os.environ["ADMIN_CLIENT_USERNAME"] = os.getenv("E2E_ADMIN_CLIENT_USERNAME") + # os.environ["NOTIFY_ENVIRONMENT"] = os.getenv("E2E_NOTIFY_ENVIRONMENT") + # os.environ["API_HOST_NAME"] = os.getenv("E2E_API_HOST_NAME") @pytest.fixture diff --git a/tests/end_to_end/test_accounts_page.py b/tests/end_to_end/test_accounts_page.py index 6efd2247a..b07b8851f 100644 --- a/tests/end_to_end/test_accounts_page.py +++ b/tests/end_to_end/test_accounts_page.py @@ -70,8 +70,6 @@ def test_add_new_service_workflow(authenticated_page, end_to_end_context): # Check to make sure that we've arrived at the next page. page.wait_for_load_state("domcontentloaded") - - # TODO this fails on staging due to duplicate results on 'get_by_text' # Check for the service name title and heading. # service_heading = page.get_by_text(new_service_name, exact=True) diff --git a/tests/end_to_end/test_create_new_template.py b/tests/end_to_end/test_create_new_template.py index c1b569b8c..76086acf0 100644 --- a/tests/end_to_end/test_create_new_template.py +++ b/tests/end_to_end/test_create_new_template.py @@ -3,7 +3,6 @@ import os import re import uuid -from flask import current_app from playwright.sync_api import expect E2E_TEST_URI = os.getenv("NOTIFY_E2E_TEST_URI") @@ -89,26 +88,20 @@ def create_new_template(page): def test_create_new_template(end_to_end_context): - print(f"WHAT IS THE TEST EMAIL {os.getenv('NOTIFY_E2E_TEST_EMAIL')}") page = end_to_end_context.new_page() - print(f"INITIAL PAGE IS {page}") page.goto(f"{E2E_TEST_URI}/sign-in") # Wait for the next page to fully load. page.wait_for_load_state("domcontentloaded") - print(f"PAGE ON ENTER TEST_CREATE_NEW_TEMPLATE AFTER SIGNING IN IS {page}") current_date_time = datetime.datetime.now() new_service_name = "E2E Federal Test Service {now} - {browser_type}".format( now=current_date_time.strftime("%m/%d/%Y %H:%M:%S"), browser_type=page.context.browser.browser_type.name, ) - print(f"NEW SERVICE NAME {new_service_name}") - print(f"GOING TO {E2E_TEST_URI}/accounts") page.goto(f"{E2E_TEST_URI}/accounts") # Check to make sure that we've arrived at the next page. page.wait_for_load_state("domcontentloaded") - print(page) # Check to make sure that we've arrived at the next page. # Check the page title exists and matches what we expect. diff --git a/tests/end_to_end/test_invite_team_member_to_service.py b/tests/end_to_end/test_invite_team_member_to_service.py index 287abd11a..79f1bf55b 100644 --- a/tests/end_to_end/test_invite_team_member_to_service.py +++ b/tests/end_to_end/test_invite_team_member_to_service.py @@ -68,8 +68,6 @@ def _setup(page): # Check to make sure that we've arrived at the next page. page.wait_for_load_state("domcontentloaded") - - # TODO this fails on staging due to duplicate results on 'get_by_text' # Check for the service name title and heading. # service_heading = page.get_by_text(new_service_name, exact=True) diff --git a/tests/end_to_end/test_send_message_from_existing_template.py b/tests/end_to_end/test_send_message_from_existing_template.py index 79601904b..4d19820ba 100644 --- a/tests/end_to_end/test_send_message_from_existing_template.py +++ b/tests/end_to_end/test_send_message_from_existing_template.py @@ -69,8 +69,6 @@ def _setup(page): # Check to make sure that we've arrived at the next page. page.wait_for_load_state("domcontentloaded") - - # TODO this fails on staging due to duplicate results on 'get_by_text' # Check for the service name title and heading. # service_heading = page.get_by_text(new_service_name, exact=True) @@ -176,7 +174,7 @@ def handle_no_existing_template_case(page): # Start waiting for the download # with page.expect_download() as download_info: - # download_link.click() + # download_link.click() # download = download_info.value # download.save_as("download_test_file") # f = open("download_test_file", "r") @@ -189,8 +187,8 @@ def handle_no_existing_template_case(page): # message and it won't be sent, but the report will still be generated, which is all # we care about here. # assert ( - # "Phone Number,Template,Sent by,Batch File,Carrier Response,Status,Time" - # in content + # "Phone Number,Template,Sent by,Batch File,Carrier Response,Status,Time" + # in content # ) # assert "12025555555" in content # assert "one-off-" in content