@@ -451,6 +451,38 @@ def test_get_product_list():
451451 __check_results_column (results , 'observation_id' , None , None , np .dtype ('<U255' ))
452452 __check_results_column (results , 'observation_stk_oid' , None , None , np .int64 )
453453
454+ for product_type in conf .OBSERVATION_STACK_PRODUCTS :
455+ results = tap .get_product_list (observation_id = '13' , product_type = product_type )
456+ assert results is not None , "Expected a valid table"
457+
458+ for product_type in conf .BASIC_DOWNLOAD_DATA_PRODUCTS :
459+ results = tap .get_product_list (observation_id = '13' , product_type = product_type )
460+ assert results is not None , "Expected a valid table"
461+
462+ for product_type in conf .MER_SEGMENTATION_MAP_PRODUCTS :
463+ results = tap .get_product_list (observation_id = '13' , product_type = product_type )
464+ assert results is not None , "Expected a valid table"
465+
466+ for product_type in conf .RAW_FRAME_PRODUCTS :
467+ results = tap .get_product_list (observation_id = '13' , product_type = product_type )
468+ assert results is not None , "Expected a valid table"
469+
470+ for product_type in conf .CALIBRATED_FRAME_PRODUCTS :
471+ results = tap .get_product_list (observation_id = '13' , product_type = product_type )
472+ assert results is not None , "Expected a valid table"
473+
474+ for product_type in conf .FRAME_CATALOG_PRODUCTS :
475+ results = tap .get_product_list (observation_id = '13' , product_type = product_type )
476+ assert results is not None , "Expected a valid table"
477+
478+ for product_type in conf .COMBINED_SPECTRA_PRODUCTS :
479+ results = tap .get_product_list (observation_id = '13' , product_type = product_type )
480+ assert results is not None , "Expected a valid table"
481+
482+ for product_type in conf .SIR_SCIENCE_FRAME_PRODUCTS :
483+ results = tap .get_product_list (observation_id = '13' , product_type = product_type )
484+ assert results is not None , "Expected a valid table"
485+
454486
455487def test_get_product_list_by_tile_index ():
456488 conn_handler = DummyConnHandler ()
@@ -471,6 +503,22 @@ def test_get_product_list_by_tile_index():
471503 __check_results_column (results , 'observation_id' , None , None , np .dtype ('<U255' ))
472504 __check_results_column (results , 'observation_stk_oid' , None , None , np .int64 )
473505
506+ for product_type in conf .MOSAIC_PRODUCTS :
507+ results = tap .get_product_list (tile_index = '13' , product_type = product_type )
508+ assert results is not None , "Expected a valid table"
509+
510+ for product_type in conf .BASIC_DOWNLOAD_DATA_PRODUCTS :
511+ results = tap .get_product_list (tile_index = '13' , product_type = product_type )
512+ assert results is not None , "Expected a valid table"
513+
514+ for product_type in conf .COMBINED_SPECTRA_PRODUCTS :
515+ results = tap .get_product_list (tile_index = '13' , product_type = product_type )
516+ assert results is not None , "Expected a valid table"
517+
518+ for product_type in conf .MER_SEGMENTATION_MAP_PRODUCTS :
519+ results = tap .get_product_list (tile_index = '13' , product_type = product_type )
520+ assert results is not None , "Expected a valid table"
521+
474522
475523def test_get_product_list_errors ():
476524 tap = EuclidClass ()
@@ -507,6 +555,25 @@ def test_get_product_list_errors():
507555 assert str (exc_info .value ).startswith ("Invalid product type DpdMerBksMosaic." )
508556
509557
558+ def test_get_product_by_product_id ():
559+ conn_handler = DummyConnHandler ()
560+ tap_plus = TapPlus (url = "http://test:1111/tap" , data_context = 'data' , client_id = 'ASTROQUERY' ,
561+ connhandler = conn_handler )
562+ # Launch response: we use default response because the query contains decimals
563+ responseLaunchJob = DummyResponse (200 )
564+ responseLaunchJob .set_data (method = 'POST' , context = None , body = '' , headers = None )
565+
566+ conn_handler .set_default_response (responseLaunchJob )
567+
568+ tap = EuclidClass (tap_plus_conn_handler = conn_handler , datalink_handler = tap_plus , show_server_messages = False )
569+
570+ result = tap .get_product (product_id = 123456789 , output_file = None )
571+
572+ assert result is not None
573+
574+ remove_temp_dir ()
575+
576+
510577def test_get_product ():
511578 conn_handler = DummyConnHandler ()
512579 tap_plus = TapPlus (url = "http://test:1111/tap" , data_context = 'data' , client_id = 'ASTROQUERY' ,
@@ -524,6 +591,27 @@ def test_get_product():
524591
525592 assert result is not None
526593
594+ remove_temp_dir ()
595+
596+
597+ def test_get_product_exceptions ():
598+ conn_handler = DummyConnHandler ()
599+ tap_plus = TapPlus (url = "http://test:1111/tap" , data_context = 'data' , client_id = 'ASTROQUERY' ,
600+ connhandler = conn_handler )
601+ # Launch response: we use default response because the query contains decimals
602+ responseLaunchJob = DummyResponse (200 )
603+ responseLaunchJob .set_data (method = 'POST' , context = None , body = '' , headers = None )
604+
605+ conn_handler .set_default_response (responseLaunchJob )
606+
607+ tap = EuclidClass (tap_plus_conn_handler = conn_handler , datalink_handler = tap_plus , show_server_messages = False )
608+
609+ file_name = 'EUC_SIM_NISRGS180-8-1_20220722T094150.427Z_PV023_NISP-S_8_18_0.fits'
610+ with pytest .raises (ValueError ) as exc_info :
611+ tap .get_product (file_name = None , product_id = None , output_file = None )
612+
613+ assert str (exc_info .value ).startswith ("'file_name' and 'product_id' are both None" )
614+
527615
528616def test_get_obs_products ():
529617 conn_handler = DummyConnHandler ()
@@ -590,6 +678,12 @@ def test_get_cutout_exception():
590678 tap = EuclidClass (tap_plus_conn_handler = conn_handler , datalink_handler = tap_plus , cutout_handler = cutout_handler ,
591679 show_server_messages = False )
592680
681+ with pytest .raises (Exception ) as exc_info :
682+ tap .get_cutout (file_path = file_path , instrument = 'NISP' , id = '19704' , coordinate = c , radius = 100 * u .arcmin ,
683+ output_file = None )
684+
685+ assert str (exc_info .value ).startswith ('Radius cannot be greater than 30 arcminutes' )
686+
593687 with pytest .raises (Exception ) as exc_info :
594688 tap .get_cutout (file_path = None , instrument = 'NISP' , id = '19704' , coordinate = c , radius = r , output_file = None )
595689
@@ -632,8 +726,11 @@ def test_get_spectrum():
632726
633727 assert result is not None
634728
635- dirs = glob .glob ('./temp_*' )
729+ remove_temp_dir ()
730+
636731
732+ def remove_temp_dir ():
733+ dirs = glob .glob ('./temp_*' )
637734 for dir_path in dirs :
638735 try :
639736 shutil .rmtree (dir_path )
0 commit comments