Skip to content

Commit 692b0e2

Browse files
committed
Add missing asset type, clean up tests
1 parent c7123a3 commit 692b0e2

File tree

2 files changed

+28
-12
lines changed

2 files changed

+28
-12
lines changed

planet/scripts/item_asset_types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
'ps4b_basic_analytic_nitf', 'ps4b_basic_analytic_rpc_nitf',
7979
'ps4b_basic_analytic_xml_nitf', 'ps4b_udm', 'udm', 'ortho_udm2',
8080
'video_file', 'video_frames', 'video_metadata', 'ortho_visual',
81-
'visual', 'visual_xml'
81+
'analytic', 'visual', 'visual_xml'
8282
]
8383

8484

tests/test_types.py

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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

6379
def test_geom_type():

0 commit comments

Comments
 (0)