mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-02 20:59:39 -04:00
Speeding up unit tests
This commit is contained in:
@@ -158,9 +158,10 @@ def download_notifications_csv(service_id):
|
||||
service_data_retention_days = current_service.get_days_of_retention(
|
||||
filter_args.get("message_type")[0], number_of_days
|
||||
)
|
||||
user_tz = ZoneInfo(get_user_preferred_timezone())
|
||||
user_tz_name = get_user_preferred_timezone()
|
||||
user_tz = ZoneInfo(user_tz_name)
|
||||
file_time = datetime.now(user_tz).strftime("%Y-%m-%d %I:%M:%S %p")
|
||||
file_time = f"{file_time} {get_user_preferred_timezone()}"
|
||||
file_time = f"{file_time} {user_tz_name}"
|
||||
|
||||
job_id = request.args.get("job_id")
|
||||
if not job_id and number_of_days in PERIOD_TO_S3_FILENAME:
|
||||
|
||||
@@ -199,6 +199,13 @@ def convert_report_date_to_preferred_timezone(db_date_str_in_utc):
|
||||
def get_user_preferred_timezone():
|
||||
if current_user and hasattr(current_user, "preferred_timezone"):
|
||||
tz = current_user.preferred_timezone
|
||||
if tz in pytz.all_timezones:
|
||||
# Use a set of common US timezones for quick validation instead of checking all timezones
|
||||
valid_timezones = {
|
||||
"US/Eastern", "US/Central", "US/Mountain", "US/Pacific",
|
||||
"US/Alaska", "US/Hawaii", "America/New_York", "America/Chicago",
|
||||
"America/Denver", "America/Los_Angeles", "America/Anchorage",
|
||||
"America/Honolulu", "America/Phoenix", "America/Puerto_Rico"
|
||||
}
|
||||
if tz in valid_timezones:
|
||||
return tz
|
||||
return "US/Eastern"
|
||||
|
||||
Reference in New Issue
Block a user