@@ -367,15 +367,51 @@ def test_missions_get_unique_product_list(patch_post, caplog):
367367def test_missions_filter_products (patch_post ):
368368 # Filter products list by column
369369 products = mast .MastMissions .get_product_list ('Z14Z0104T' )
370- filtered = mast .MastMissions .filter_products (products ,
371- category = 'CALIBRATED' )
370+ filtered = mast .MastMissions .filter_products (products , category = 'CALIBRATED' )
372371 assert isinstance (filtered , Table )
373372 assert all (filtered ['category' ] == 'CALIBRATED' )
374373
375- # Filter by non-existing column
376- with pytest .warns (InputWarning ):
377- mast .MastMissions .filter_products (products ,
378- invalid = True )
374+ # Filter by extension
375+ filtered = mast .MastMissions .filter_products (products , extension = 'fits' )
376+ assert len (filtered ) > 0
377+
378+ # Numeric filtering
379+ # Single integer value
380+ filtered = mast .MastMissions .filter_products (products , size = 11520 )
381+ assert all (filtered ['size' ] == 11520 )
382+
383+ # Single string value
384+ filtered = mast .MastMissions .filter_products (products , size = '11520' )
385+ assert all (filtered ['size' ] == 11520 )
386+
387+ # Comparison operators
388+ filtered = mast .MastMissions .filter_products (products , size = '<15000' )
389+ assert all (filtered ['size' ] < 15000 )
390+
391+ filtered = mast .MastMissions .filter_products (products , size = '>15000' )
392+ assert all (filtered ['size' ] > 15000 )
393+
394+ filtered = mast .MastMissions .filter_products (products , size = '>=14400' )
395+ assert all (filtered ['size' ] >= 14400 )
396+
397+ filtered = mast .MastMissions .filter_products (products , size = '<=14400' )
398+ assert all (filtered ['size' ] <= 14400 )
399+
400+ # Range operator
401+ filtered = mast .MastMissions .filter_products (products , size = '14400..17280' )
402+ assert all ((filtered ['size' ] >= 14400 ) & (filtered ['size' ] <= 17280 ))
403+
404+ # List of expressions
405+ filtered = mast .MastMissions .filter_products (products , size = [14400 , '>20000' ])
406+ assert all ((filtered ['size' ] == 14400 ) | (filtered ['size' ] > 20000 ))
407+
408+ with pytest .raises (InvalidQueryError , match = "Could not parse numeric filter 'invalid' for column 'size'" ):
409+ # Invalid filter value
410+ mast .MastMissions .filter_products (products , size = 'invalid' )
411+
412+ # Error when filtering by non-existing column
413+ with pytest .raises (InvalidQueryError , match = "Column 'non_existing' not found in product table." ):
414+ mast .MastMissions .filter_products (products , non_existing = 'value' )
379415
380416
381417def test_missions_download_products (patch_post , tmp_path ):
@@ -671,11 +707,31 @@ def test_observations_get_product_list(patch_post):
671707
672708def test_observations_filter_products (patch_post ):
673709 products = mast .Observations .get_product_list ('2003738726' )
674- result = mast .Observations .filter_products (products ,
675- productType = ["SCIENCE" ],
676- mrp_only = False )
677- assert isinstance (result , Table )
678- assert len (result ) == 7
710+ filtered = mast .Observations .filter_products (products ,
711+ productType = ["SCIENCE" ],
712+ mrp_only = False )
713+ assert isinstance (filtered , Table )
714+ assert len (filtered ) == 7
715+
716+ # Filter for minimum recommended products
717+ filtered = mast .Observations .filter_products (products , mrp_only = True )
718+ assert all (filtered ['productGroupDescription' ] == 'Minimum Recommended Products' )
719+
720+ # Filter by extension
721+ filtered = mast .Observations .filter_products (products , extension = 'fits' )
722+ assert len (filtered ) > 0
723+
724+ # Numeric filtering
725+ filtered = mast .Observations .filter_products (products , size = '<50000' )
726+ assert all (filtered ['size' ] < 50000 )
727+
728+ # Numeric filter that cannot be parsed
729+ with pytest .raises (InvalidQueryError , match = "Could not parse numeric filter 'invalid' for column 'size'" ):
730+ filtered = mast .Observations .filter_products (products , size = 'invalid' )
731+
732+ # Filter by non-existing column
733+ with pytest .raises (InvalidQueryError , match = "Column 'invalid' not found in product table." ):
734+ mast .Observations .filter_products (products , invalid = True )
679735
680736
681737def test_observations_download_products (patch_post , tmpdir ):
@@ -703,8 +759,7 @@ def test_observations_download_products(patch_post, tmpdir):
703759
704760 # passing row product
705761 products = mast .Observations .get_product_list ('2003738726' )
706- result1 = mast .Observations .download_products (products [0 ],
707- download_dir = str (tmpdir ))
762+ result1 = mast .Observations .download_products (products [0 ], download_dir = str (tmpdir ))
708763 assert isinstance (result1 , Table )
709764
710765
0 commit comments