@@ -46,18 +46,34 @@ def test_item_type():
4646 assert 'invalid choice: x' in str (e .value )
4747
4848
49- @mock .patch ('planet.scripts.types.get_asset_types' ,
50- new = mock .Mock (return_value = DEFAULT_ASSET_TYPES ))
51- def test_asset_type ():
52- check = convert_asserter (AssetType ())
53- check ('visual*' , ['visual' , 'visual_xml' ])
54- check ('*data_*' , ['metadata_aux' , 'metadata_txt' ])
55- check ('analytic' , ['analytic' ])
56- check ('analytic,visual' , ['analytic' , 'visual' ])
49+ @mock .patch (
50+ "planet.scripts.types.get_asset_types" ,
51+ new = mock .Mock (return_value = DEFAULT_ASSET_TYPES ),
52+ )
53+ @pytest .mark .parametrize (
54+ "pattern,type_list" ,
55+ [
56+ ("visual*" , ["visual" , "visual_xml" ]),
57+ ("*data_*" , ["metadata_aux" , "metadata_txt" ]),
58+ ("analytic" , ["analytic" ]),
59+ ("analytic,visual" , ["analytic" , "visual" ]),
60+ ],
61+ )
62+ def test_asset_type_convert (pattern , type_list ):
63+ """Patterns are correctly converted to a list of assert types."""
64+ assert sorted (AssetType ()(pattern )) == sorted (type_list )
5765
58- with pytest .raises (Exception ) as e :
59- AssetType ().convert ('x' , None , None )
60- assert 'invalid choice: x' in str (e .value )
66+
67+ @mock .patch (
68+ "planet.scripts.types.get_asset_types" ,
69+ new = mock .Mock (return_value = DEFAULT_ASSET_TYPES ),
70+ )
71+ @pytest .mark .parametrize ("pattern" , ["x" , "foo?" , "?visual" , "visual?" ])
72+ def test_asset_type_convert_invalid (pattern ):
73+ """Invalid patterns result in an exception."""
74+ with pytest .raises (Exception ) as exc :
75+ AssetType ()(pattern )
76+ assert "invalid choice:" in str (exc .value )
6177
6278
6379def test_geom_type ():
0 commit comments