mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-09 11:59:48 -04:00
More conftest goodness.
Signed-off-by: Cliff Hill <clifford.hill@gsa.gov>
This commit is contained in:
@@ -10,6 +10,8 @@ from app import create_app
|
|||||||
from app.notify_client.service_api_client import service_api_client
|
from app.notify_client.service_api_client import service_api_client
|
||||||
from app.notify_client.user_api_client import user_api_client
|
from app.notify_client.user_api_client import user_api_client
|
||||||
|
|
||||||
|
from .. import TestClient
|
||||||
|
|
||||||
E2E_TEST_URI = os.getenv("NOTIFY_E2E_TEST_URI")
|
E2E_TEST_URI = os.getenv("NOTIFY_E2E_TEST_URI")
|
||||||
|
|
||||||
|
|
||||||
@@ -52,35 +54,57 @@ def notify_admin_e2e():
|
|||||||
application = Flask("app")
|
application = Flask("app")
|
||||||
create_app(application)
|
create_app(application)
|
||||||
|
|
||||||
return application
|
application.test_client_class = TestClient
|
||||||
|
|
||||||
|
with application.app_context():
|
||||||
|
yield application
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def default_user(notify_admin_e2e):
|
||||||
|
default_user = user_api_client.get_user_by_email(os.getenv("NOTIFY_E2E_TEST_EMAIL"))
|
||||||
|
return default_user
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def client(notify_admin_e2e, default_user):
|
||||||
|
"""
|
||||||
|
Do not use this fixture directly – use `client_request` instead
|
||||||
|
"""
|
||||||
|
with notify_admin_e2e.test_request_context(), notify_admin_e2e.test_client() as client:
|
||||||
|
client.allow_subdomain_redirects = True
|
||||||
|
try:
|
||||||
|
client.login(default_user)
|
||||||
|
yield client
|
||||||
|
finally:
|
||||||
|
client.logout(default_user)
|
||||||
|
|
||||||
|
|
||||||
# Need e2e service defined here?
|
# Need e2e service defined here?
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def default_service(browser, notify_admin_e2e):
|
def default_service(browser, client, default_user):
|
||||||
with notify_admin_e2e.app_context():
|
current_date_time = datetime.datetime.now()
|
||||||
current_date_time = datetime.datetime.now()
|
now = current_date_time.strftime("%m/%d/%Y %H:%M:%S")
|
||||||
now = current_date_time.strftime("%m/%d/%Y %H:%M:%S")
|
browser_type = browser.browser_type.name
|
||||||
browser_type = browser.browser_type.name
|
service_name = f"E2E Federal Test Service {now} - {browser_type}"
|
||||||
service_name = f"E2E Federal Test Service {now} - {browser_type}"
|
|
||||||
|
|
||||||
default_user = user_api_client.get_user_by_email(
|
from pprint import pprint
|
||||||
os.getenv("NOTIFY_E2E_TEST_EMAIL")
|
|
||||||
)
|
|
||||||
service = service_api_client.create_service(
|
|
||||||
service_name,
|
|
||||||
"federal",
|
|
||||||
current_app.config["DEFAULT_SERVICE_LIMIT"],
|
|
||||||
True,
|
|
||||||
default_user["id"],
|
|
||||||
default_user["email_address"],
|
|
||||||
)
|
|
||||||
|
|
||||||
print("OK I GOT HERE LETS GO!!!")
|
pprint(default_user)
|
||||||
|
service = service_api_client.create_service(
|
||||||
|
service_name,
|
||||||
|
"federal",
|
||||||
|
current_app.config["DEFAULT_SERVICE_LIMIT"],
|
||||||
|
True,
|
||||||
|
default_user["id"],
|
||||||
|
default_user["email_address"],
|
||||||
|
)
|
||||||
|
|
||||||
yield service
|
print("OK I GOT HERE LETS GO!!!")
|
||||||
|
|
||||||
service_api_client.archive_service(service.id, None)
|
yield service
|
||||||
|
|
||||||
|
service_api_client.archive_service(service.id, None)
|
||||||
|
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
|
|||||||
Reference in New Issue
Block a user