@@ -645,37 +645,25 @@ def test_get_product_list_by_tile_index():
645
645
def test_get_product_list_errors ():
646
646
tap = EuclidClass ()
647
647
648
- with pytest .raises (ValueError ) as exc_info :
648
+ with pytest .raises (ValueError , match = "Missing required argument: 'product_type'" ) :
649
649
tap .get_product_list (observation_id = '13' , product_type = None )
650
650
651
- assert str (exc_info .value ).startswith ("Missing required argument: 'product_type'" )
652
-
653
- with pytest .raises (ValueError ) as exc_info :
651
+ with pytest .raises (ValueError ,
652
+ match = "Missing required argument: 'observation_id'; Missing required argument: 'tile_id'" ):
654
653
tap .get_product_list (observation_id = None , tile_index = None , product_type = 'DpdNirStackedFrame' )
655
654
656
- assert str (exc_info .value ).startswith (
657
- "Missing required argument: 'observation_id'; Missing required argument: 'tile_id'" )
658
-
659
- with pytest .raises (ValueError ) as exc_info :
655
+ with pytest .raises (ValueError , match = "Incompatible: 'observation_id' and 'tile_id'. Use only one." ):
660
656
tap .get_product_list (observation_id = '13' , tile_index = '13' , product_type = 'DpdNirStackedFrame' )
661
657
662
- assert str (exc_info .value ).startswith ("Incompatible: 'observation_id' and 'tile_id'. Use only one." )
663
-
664
- with pytest .raises (ValueError ) as exc_info :
658
+ with pytest .raises (ValueError , match = "Invalid product type DpdNirStackedFrame." ):
665
659
tap .get_product_list (tile_index = '13' , product_type = 'DpdNirStackedFrame' )
666
660
667
- assert str (exc_info .value ).startswith ("Invalid product type DpdNirStackedFrame." )
668
-
669
- with pytest .raises (ValueError ) as exc_info :
661
+ with pytest .raises (ValueError , match = "Missing required argument: 'product_type'" ):
670
662
tap .get_product_list (tile_index = '13' , product_type = None )
671
663
672
- assert str (exc_info .value ).startswith ("Missing required argument: 'product_type'" )
673
-
674
- with pytest .raises (ValueError ) as exc_info :
664
+ with pytest .raises (ValueError , match = "Invalid product type DpdMerBksMosaic." ):
675
665
tap .get_product_list (observation_id = '13' , product_type = 'DpdMerBksMosaic' )
676
666
677
- assert str (exc_info .value ).startswith ("Invalid product type DpdMerBksMosaic." )
678
-
679
667
680
668
def test_get_product_by_product_id (tmp_path_factory ):
681
669
conn_handler = DummyConnHandler ()
@@ -833,21 +821,15 @@ def test_get_observation_products_exceptions():
833
821
834
822
tap = EuclidClass (tap_plus_conn_handler = conn_handler , datalink_handler = tap_plus , show_server_messages = False )
835
823
836
- with pytest .raises (ValueError ) as exc_info :
824
+ with pytest .raises (ValueError , match = "Missing required argument: 'observation_id'" ) :
837
825
tap .get_observation_products (id = None , product_type = 'observation' , filter = 'VIS' , output_file = None )
838
826
839
- assert str (exc_info .value ).startswith ("Missing required argument: 'observation_id'" )
840
-
841
- with pytest .raises (ValueError ) as exc_info :
827
+ with pytest .raises (ValueError , match = "Missing required argument: 'product_type'" ):
842
828
tap .get_observation_products (id = '12' , product_type = None , filter = 'VIS' , output_file = None )
843
829
844
- assert str (exc_info .value ).startswith ("Missing required argument: 'product_type'" )
845
-
846
- with pytest .raises (ValueError ) as exc_info :
830
+ with pytest .raises (ValueError , match = "Invalid product type XXXXXXXX. Valid values: \\ ['observation', 'mosaic'\\ ]" ):
847
831
tap .get_observation_products (id = '12' , product_type = 'XXXXXXXX' , filter = 'VIS' , output_file = None )
848
832
849
- assert str (exc_info .value ).startswith ("Invalid product type XXXXXXXX. Valid values: ['observation', 'mosaic']" )
850
-
851
833
852
834
@patch .object (TapPlus , 'load_data' )
853
835
def test_get_observation_products_exceptions_2 (mock_load_data , caplog ):
@@ -929,37 +911,25 @@ def test_get_cutout_exception():
929
911
tap = EuclidClass (tap_plus_conn_handler = conn_handler , datalink_handler = tap_plus , cutout_handler = cutout_handler ,
930
912
show_server_messages = False )
931
913
932
- with pytest .raises (Exception ) as exc_info :
914
+ with pytest .raises (ValueError , match = "Radius cannot be greater than 30 arcminutes" ) :
933
915
tap .get_cutout (file_path = file_path , instrument = 'NISP' , id = '19704' , coordinate = c , radius = 100 * u .arcmin ,
934
916
output_file = None )
935
917
936
- assert str (exc_info .value ).startswith ('Radius cannot be greater than 30 arcminutes' )
937
-
938
- with pytest .raises (Exception ) as exc_info :
918
+ with pytest .raises (ValueError , match = "Missing required argument" ):
939
919
tap .get_cutout (file_path = None , instrument = 'NISP' , id = '19704' , coordinate = c , radius = r , output_file = None )
940
920
941
- assert str (exc_info .value ).startswith ('Missing required argument' )
942
-
943
- with pytest .raises (Exception ) as exc_info :
921
+ with pytest .raises (ValueError , match = "Missing required argument" ):
944
922
tap .get_cutout (file_path = file_path , instrument = None , id = '19704' , coordinate = c , radius = r , output_file = None )
945
923
946
- assert str (exc_info .value ).startswith ('Missing required argument' )
947
-
948
- with pytest .raises (Exception ) as exc_info :
924
+ with pytest .raises (ValueError , match = "Missing required argument" ):
949
925
tap .get_cutout (file_path = file_path , instrument = 'NISP' , id = None , coordinate = c , radius = r , output_file = None )
950
926
951
- assert str (exc_info .value ).startswith ('Missing required argument' )
952
-
953
- with pytest .raises (Exception ) as exc_info :
927
+ with pytest .raises (ValueError , match = "Missing required argument" ):
954
928
tap .get_cutout (file_path = file_path , instrument = 'NISP' , id = '19704' , coordinate = None , radius = r , output_file = None )
955
929
956
- assert str (exc_info .value ).startswith ('Missing required argument' )
957
-
958
- with pytest .raises (Exception ) as exc_info :
930
+ with pytest .raises (ValueError , match = "Missing required argument" ):
959
931
tap .get_cutout (file_path = file_path , instrument = 'NISP' , id = '19704' , coordinate = c , radius = None , output_file = None )
960
932
961
- assert str (exc_info .value ).startswith ('Missing required argument' )
962
-
963
933
964
934
@patch .object (TapPlus , 'load_data' )
965
935
def test_get_cutout_exceptions_2 (mock_load_data , caplog ):
@@ -1072,15 +1042,12 @@ def test_get_spectrum_exceptions():
1072
1042
1073
1043
# if source_id is None or schema is None:
1074
1044
1075
- with pytest .raises (Exception ) as exc_info :
1045
+ with pytest .raises (ValueError , match = "Missing required argument" ) :
1076
1046
tap .get_spectrum (source_id = None , schema = 'sedm_sc8' , output_file = None )
1077
1047
1078
- assert str (exc_info .value ).startswith ('Missing required argument' )
1079
-
1080
- with pytest .raises (Exception ) as exc_info :
1048
+ with pytest .raises (ValueError , match = "Missing required argument" ):
1081
1049
tap .get_spectrum (source_id = '2417660845403252054' , schema = None , output_file = None )
1082
1050
1083
- assert str (exc_info .value ).startswith ('Missing required argument' )
1084
1051
with pytest .raises (ValueError , match = (
1085
1052
"Invalid argument value for 'retrieval_type'. Found hola, expected: 'ALL' or any of \\ ['SPECTRA_BGS', "
1086
1053
"'SPECTRA_RGS'\\ ]" )):
0 commit comments