3535)
3636from qiime2 .plugin .testing import TestPluginBase
3737from qiime2 .plugin import ValidationError
38+ from qiime2 .core .exceptions import RachisWarning
39+ from qiime2 .sdk .result import Artifact
3840
3941
4042class TestTaxonomyFormats (TestPluginBase ):
@@ -48,7 +50,6 @@ def test_taxonomy_format_validate_positive(self):
4850
4951 for filepath in filepaths :
5052 format = TaxonomyFormat (filepath , mode = 'r' )
51-
5253 format .validate ()
5354
5455 def test_taxonomy_format_validate_negative (self ):
@@ -116,6 +117,31 @@ def test_headerless_tsv_taxonomy_directory_format(self):
116117
117118 format .validate ()
118119
120+ def test_tsv_taxonomy_format_warnings (self ):
121+ '''
122+ Tests that the taxonomic depth of one and trailing semicolon warnings
123+ are raised under the proper conditions.
124+ '''
125+ filepath = self .get_data_path (
126+ os .path .join ('taxonomy' , 'one-depth.tsv' )
127+ )
128+ format = TSVTaxonomyFormat (filepath , mode = 'r' )
129+
130+ with self .assertWarnsRegex (
131+ RachisWarning , 'Importing taxonomy with taxonomic depth of one.'
132+ ):
133+ Artifact .import_data ('FeatureData[Taxonomy]' , format )
134+
135+ filepath = self .get_data_path (
136+ os .path .join ('taxonomy' , 'trailing-semicolon.tsv' )
137+ )
138+ format = TSVTaxonomyFormat (filepath , mode = 'r' )
139+
140+ with self .assertWarnsRegex (
141+ RachisWarning , 'Importing taxonomy with a trailing semicolon.'
142+ ):
143+ Artifact .import_data ('FeatureData[Taxonomy]' , format )
144+
119145 def test_tsv_taxonomy_format_validate_positive (self ):
120146 filenames = ['2-column.tsv' , '3-column.tsv' , 'valid-but-messy.tsv' ,
121147 'many-rows.tsv' ]
0 commit comments