@@ -328,11 +328,29 @@ def test_date_time_value(
328328 * Invalid date time string formats
329329 * Invalid date-times
330330 """
331+ expected_error_message = (
332+ f"{ field_location } must be a valid datetime in one of the following formats:"
333+ "- 'YYYY-MM-DD' — Full date only"
334+ "- 'YYYY-MM-DDThh:mm:ss' — Full date and time without milliseconds"
335+ "- 'YYYY-MM-DDThh:mm:ss.f' — Full date and time with milliseconds (any level of precision)"
336+ "- 'YYYY-MM-DDThh:mm:ss%z' — Full date and time with timezone (e.g. +00:00 or +01:00)"
337+ "- 'YYYY-MM-DDThh:mm:ss.f%z' — Full date and time with milliseconds and timezone"
338+ )
339+
340+ if is_occurrence_date_time :
341+ expected_error_message += "Only '+00:00' and '+01:00' are accepted as valid timezone offsets.\n "
342+ expected_error_message += f"Note that partial dates are not allowed for { field_location } in this service."
343+ valid_datetime_formats = ValidValues .for_date_times_strict_timezones
344+ invalid_datetime_formats = InvalidValues .for_date_time_string_formats_for_strict_timezone
345+ else :
346+ # For recorded, skip values that are valid ISO with non-restricted timezone
347+ valid_datetime_formats = ValidValues .for_date_times_relaxed_timezones
348+ invalid_datetime_formats = InvalidValues .for_date_time_string_formats_for_relaxed_timezone
331349
332350 valid_json_data = deepcopy (test_instance .json_data )
333351
334352 # Test that valid data is accepted
335- test_valid_values_accepted (test_instance , valid_json_data , field_location , ValidValues . for_date_times )
353+ test_valid_values_accepted (test_instance , valid_json_data , field_location , valid_datetime_formats )
336354
337355 # Set list of invalid data types to test
338356 invalid_data_types_for_strings = InvalidDataTypes .for_strings
@@ -349,25 +367,6 @@ def test_date_time_value(
349367 expected_error_message = f"{ field_location } must be a string" ,
350368 )
351369
352- expected_error_message = (
353- f"{ field_location } must be a valid datetime in one of the following formats:"
354- "- 'YYYY-MM-DD' — Full date only"
355- "- 'YYYY-MM-DDThh:mm:ss' — Full date and time without milliseconds"
356- "- 'YYYY-MM-DDThh:mm:ss.f' — Full date and time with milliseconds (any level of precision)"
357- "- 'YYYY-MM-DDThh:mm:ss%z' — Full date and time with timezone (e.g. +00:00 or +01:00)"
358- "- 'YYYY-MM-DDThh:mm:ss.f%z' — Full date and time with milliseconds and timezone"
359- )
360-
361- if is_occurrence_date_time :
362- expected_error_message += "Only '+00:00' and '+01:00' are accepted as valid timezone offsets.\n "
363- expected_error_message += f"Note that partial dates are not allowed for { field_location } in this service."
364-
365- if is_occurrence_date_time :
366- invalid_datetime_formats = InvalidValues .for_date_time_string_formats_for_strict_timezone
367- else :
368- # For recorded, skip values that are valid ISO with non-restricted timezone
369- invalid_datetime_formats = InvalidValues .for_date_time_string_formats_for_relaxed_timezone
370-
371370 # Test invalid date time string formats
372371 for invalid_occurrence_date_time in invalid_datetime_formats :
373372 test_invalid_values_rejected (
0 commit comments