@@ -417,32 +417,71 @@ def compare_filter_options_with_database(
417417 # Log detailed comparison for each property
418418 for prop_name in sorted (set (expected_properties .keys ()) | set (api_filters .keys ())):
419419 if prop_name in expected_properties and prop_name in api_filters :
420- db_values = set (expected_properties [prop_name ])
421- api_values = set (api_filters [prop_name ]["values" ])
422-
423- missing_values = db_values - api_values
424- extra_values = api_values - db_values
425-
426- if missing_values :
427- error_msg = (
428- f"Property '{ prop_name } ': DB has { len (missing_values )} values missing from API: { missing_values } "
429- )
430- LOGGER .error (error_msg )
431- comparison_errors .append (error_msg )
432- if extra_values :
433- error_msg = (
434- f"Property '{ prop_name } ': API has { len (extra_values )} values missing from DB: { extra_values } "
435- )
436- LOGGER .error (error_msg )
437- comparison_errors .append (error_msg )
438- if not missing_values and not extra_values :
439- LOGGER .info (f"Property '{ prop_name } ': Perfect match ({ len (api_values )} values)" )
420+ db_data = expected_properties [prop_name ]
421+ api_filter = api_filters [prop_name ]
422+
423+ # Check if this is a numeric property (has "range" in API response)
424+ if "range" in api_filter :
425+ # Numeric property: DB has [min, max] as 2-element array
426+ if len (db_data ) == 2 :
427+ try :
428+ db_min , db_max = float (db_data [0 ]), float (db_data [1 ])
429+ api_min = api_filter ["range" ]["min" ]
430+ api_max = api_filter ["range" ]["max" ]
431+
432+ if db_min != api_min or db_max != api_max :
433+ error_msg = (
434+ f"Property '{ prop_name } ': Range mismatch - DB: [{ db_min } , { db_max } ], "
435+ f"API: [{ api_min } , { api_max } ]"
436+ )
437+ LOGGER .error (error_msg )
438+ comparison_errors .append (error_msg )
439+ else :
440+ LOGGER .info (f"Property '{ prop_name } ': Perfect range match (min={ api_min } , max={ api_max } )" )
441+ except (ValueError , TypeError ) as e :
442+ error_msg = f"Property '{ prop_name } ': Failed to parse numeric values - { e } "
443+ LOGGER .error (error_msg )
444+ comparison_errors .append (error_msg )
445+ else :
446+ error_msg = f"Property '{ prop_name } ': Expected 2 values for range, got { len (db_data )} "
447+ LOGGER .error (error_msg )
448+ comparison_errors .append (error_msg )
449+ else :
450+ # String/array property: compare values as sets
451+ db_values = set (db_data )
452+ api_values = set (api_filter ["values" ])
453+
454+ missing_values = db_values - api_values
455+ extra_values = api_values - db_values
456+
457+ if missing_values :
458+ error_msg = (
459+ f"Property '{ prop_name } ': DB has { len (missing_values )} "
460+ f"values missing from API: { missing_values } "
461+ )
462+ LOGGER .error (error_msg )
463+ comparison_errors .append (error_msg )
464+ if extra_values :
465+ error_msg = (
466+ f"Property '{ prop_name } ': API has { len (extra_values )} values missing from DB: { extra_values } "
467+ )
468+ LOGGER .error (error_msg )
469+ comparison_errors .append (error_msg )
470+ if not missing_values and not extra_values :
471+ LOGGER .info (f"Property '{ prop_name } ': Perfect match ({ len (api_values )} values)" )
440472 elif prop_name in expected_properties :
441473 error_msg = f"Property '{ prop_name } ': In DB ({ len (expected_properties [prop_name ])} values) but NOT in API"
442474 LOGGER .error (error_msg )
443475 comparison_errors .append (error_msg )
444476 elif prop_name in api_filters :
445- error_msg = f"Property '{ prop_name } ': In API ({ len (api_filters [prop_name ]['values' ])} values) but NOT in DB"
477+ LOGGER .info (f"Property name: '{ prop_name } ' in API filters: { api_filters [prop_name ]} " )
478+ # For properties only in API, we can't reliably get DB values, so skip logging them
479+ if "range" in api_filters [prop_name ]:
480+ error_msg = f"Property '{ prop_name } ': In API (range property) but NOT in DB"
481+ else :
482+ error_msg = (
483+ f"Property '{ prop_name } ': In API ({ len (api_filters [prop_name ]['values' ])} values) but NOT in DB"
484+ )
446485 LOGGER .error (error_msg )
447486 comparison_errors .append (error_msg )
448487
0 commit comments