mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-06 12:18:26 -04:00
fix tests maybe
This commit is contained in:
@@ -169,7 +169,7 @@
|
|||||||
"filename": "app/config.py",
|
"filename": "app/config.py",
|
||||||
"hashed_secret": "577a4c667e4af8682ca431857214b3a920883efc",
|
"hashed_secret": "577a4c667e4af8682ca431857214b3a920883efc",
|
||||||
"is_verified": false,
|
"is_verified": false,
|
||||||
"line_number": 117,
|
"line_number": 118,
|
||||||
"is_secret": false
|
"is_secret": false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -692,5 +692,5 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"generated_at": "2024-08-20T14:14:36Z"
|
"generated_at": "2024-09-03T17:36:57Z"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ from notifications_utils import DAILY_MESSAGE_LIMIT
|
|||||||
|
|
||||||
|
|
||||||
class Config(object):
|
class Config(object):
|
||||||
|
SIMULATED_SMS_NUMBERS = ("+14254147755", "+14254147167")
|
||||||
NOTIFY_APP_NAME = "admin"
|
NOTIFY_APP_NAME = "admin"
|
||||||
NOTIFY_ENVIRONMENT = getenv("NOTIFY_ENVIRONMENT", "development")
|
NOTIFY_ENVIRONMENT = getenv("NOTIFY_ENVIRONMENT", "development")
|
||||||
API_HOST_NAME = getenv("API_HOST_NAME", "localhost")
|
API_HOST_NAME = getenv("API_HOST_NAME", "localhost")
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ from flask import (
|
|||||||
abort,
|
abort,
|
||||||
current_app,
|
current_app,
|
||||||
flash,
|
flash,
|
||||||
|
redirect,
|
||||||
render_template,
|
render_template,
|
||||||
request,
|
request,
|
||||||
session,
|
session,
|
||||||
@@ -34,6 +35,7 @@ from app.main.forms import (
|
|||||||
DateFilterForm,
|
DateFilterForm,
|
||||||
RequiredDateFilterForm,
|
RequiredDateFilterForm,
|
||||||
)
|
)
|
||||||
|
from app.main.views.dashboard import get_dashboard_partials
|
||||||
from app.main.views.send import _send_notification
|
from app.main.views.send import _send_notification
|
||||||
from app.statistics_utils import (
|
from app.statistics_utils import (
|
||||||
get_formatted_percentage,
|
get_formatted_percentage,
|
||||||
@@ -794,29 +796,31 @@ def load_test():
|
|||||||
the platform admin a member of this service if the platform is not already. All
|
the platform admin a member of this service if the platform is not already. All
|
||||||
messagese will be sent in this service.
|
messagese will be sent in this service.
|
||||||
"""
|
"""
|
||||||
# SIMULATED_SMS_NUMBERS = ("+14254147755", "+14254147167")
|
|
||||||
service = _find_load_test_service()
|
service = _find_load_test_service()
|
||||||
_prepare_load_test_service(service)
|
_prepare_load_test_service(service)
|
||||||
example_template = _find_example_template(service)
|
example_template = _find_example_template(service)
|
||||||
|
|
||||||
for _ in range(0, 3):
|
# Simulated success
|
||||||
session["recipient"] = "+14254147755"
|
for _ in range(0, 250):
|
||||||
|
session["recipient"] = current_app.config["SIMULATED_SMS_NUMBERS"][0]
|
||||||
session["placeholders"] = {
|
session["placeholders"] = {
|
||||||
"day of week": "Monday",
|
"day of week": "Monday",
|
||||||
"color": "blue",
|
"color": "blue",
|
||||||
"phone number": "+14254147755",
|
"phone number": current_app.config["SIMULATED_SMS_NUMBERS"][0],
|
||||||
}
|
}
|
||||||
_send_notification(service["id"], example_template["id"])
|
_send_notification(service["id"], example_template["id"])
|
||||||
for _ in range(0, 3):
|
# Simulated failure
|
||||||
session["recipient"] = "+14254147167"
|
for _ in range(0, 250):
|
||||||
|
session["recipient"] = current_app.config["SIMULATED_SMS_NUMBERS"][1]
|
||||||
session["placeholders"] = {
|
session["placeholders"] = {
|
||||||
"day of week": "Monday",
|
"day of week": "Wednesday",
|
||||||
"color": "blue",
|
"color": "orange",
|
||||||
"phone number": "+14254147167",
|
"phone number": current_app.config["SIMULATED_SMS_NUMBERS"][1],
|
||||||
}
|
}
|
||||||
_send_notification(service["id"], example_template["id"])
|
_send_notification(service["id"], example_template["id"])
|
||||||
|
|
||||||
return render_template("views/dashboard/dashboard.html")
|
# For now, just hang out on the platform admin page
|
||||||
|
return redirect(request.referrer)
|
||||||
|
|
||||||
|
|
||||||
def _find_example_template(service):
|
def _find_example_template(service):
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import os
|
||||||
import time
|
import time
|
||||||
import uuid
|
import uuid
|
||||||
from string import ascii_uppercase
|
from string import ascii_uppercase
|
||||||
@@ -1032,12 +1033,16 @@ def _send_notification(service_id, template_id):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
form = CsvUploadForm()
|
# For load testing we want to skip these checks. They are doing some fine-grained
|
||||||
form.file.data = my_data
|
# comparison about what is in the preview, but the load test just blast messages
|
||||||
form.file.name = filename
|
# and doesn't care about the preview.
|
||||||
check_message_output = check_messages(service_id, template_id, upload_id, 2)
|
if os.getenv("NOTIFY_ENVIRONMENT") not in ("development", "staging", "demo"):
|
||||||
if "You cannot send to" in check_message_output:
|
form = CsvUploadForm()
|
||||||
return check_messages(service_id, template_id, upload_id, 2)
|
form.file.data = my_data
|
||||||
|
form.file.name = filename
|
||||||
|
check_message_output = check_messages(service_id, template_id, upload_id, 2)
|
||||||
|
if "You cannot send to" in check_message_output:
|
||||||
|
return check_messages(service_id, template_id, upload_id, 2)
|
||||||
|
|
||||||
job_api_client.create_job(
|
job_api_client.create_job(
|
||||||
upload_id,
|
upload_id,
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import os
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from flask import abort, current_app, request, session
|
from flask import abort, current_app, request, session
|
||||||
@@ -219,7 +220,12 @@ class User(JSONModel, UserMixin):
|
|||||||
def has_permissions(
|
def has_permissions(
|
||||||
self, *permissions, restrict_admin_usage=False, allow_org_user=False
|
self, *permissions, restrict_admin_usage=False, allow_org_user=False
|
||||||
):
|
):
|
||||||
if self.platform_admin and restrict_admin_usage is False:
|
# TODO need this for load test, but breaks unit tests
|
||||||
|
if self.platform_admin and os.getenv("NOTIFY_ENVIRONMENT") in (
|
||||||
|
"development",
|
||||||
|
"staging",
|
||||||
|
"demo",
|
||||||
|
):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
unknown_permissions = set(permissions) - all_ui_permissions
|
unknown_permissions = set(permissions) - all_ui_permissions
|
||||||
|
|||||||
Reference in New Issue
Block a user