Skip to content

Commit

Permalink
Fix error messages for program validity
Browse files Browse the repository at this point in the history
  • Loading branch information
robertdstein committed Jan 31, 2024
1 parent 4cab377 commit b37ee99
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion tests/test_schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
prog_key="763244309190298696786072636901190268976229595667748695826878",
maxpriority=100,
startdate=date(2021, 1, 1),
enddate=date(2023, 12, 31),
enddate=date(3023, 12, 31),
)


Expand Down
13 changes: 10 additions & 3 deletions wintertoo/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,15 +209,21 @@ def validate_target_dates(
err = None

if start_time > stop_time:
err = f"Start time '{start_time}' is after stop time '{stop_time}'."
err = (
f"Start time '{start_time.isot}' is after stop time '{stop_time.isot}'."
)

elif start_time < program_start_date:
err = (
f"Start time '{start_time}' is before program start date '{stop_time}'"
f"Start time '{start_time.isot}' is before "
f"program start date '{program_start_date.isot}'"
)

elif stop_time > program_end_date:
err = f"Stop time '{start_time}' is after program end date '{stop_time}'"
err = (
f"Stop time '{start_time.isot}' is after "
f"program end date '{program_end_date.isot}'"
)

if err is not None:
logger.error(err)
Expand All @@ -236,6 +242,7 @@ def validate_schedule_request( # pylint: disable=too-many-arguments
"""
Central to validate that a schedule request is allowed.
Raises an error if not.
:param schedule_request: Schedule to validate
:param program_name: name of program e.g 2020A000
:param program_api_key: unique API key for program
Expand Down

0 comments on commit b37ee99

Please sign in to comment.