Writing proper tests for a dynamic collection created through the discover_datasets tag

I am currently trying to write tests for a tool that I am publishing, that creates a list of zip files that are contained within a collection. As the number of zip files is not known in advance, I am using the “discover_datasets“ tag:

<collection type='list' label='Influx_si input files' name='list_output'>
            <discover_datasets pattern='(?P&lt;name&gt;.+\.[^.]+)$' format='zip'/>
        </collection>

I have no problem getting this to work when I serve the tool on a local instance. The problem comes when I write the test and I try it out using “planemo test“. Here is the test of the collection:

<output_collection name='list_output' type='list'>
                <element name='Sample_1' file='Sample_1.zip' ftype='zip'>
                    <assert_contents>
                        <has_archive_member path='Sample_1.miso'>
                            <has_text_matching expression='sample\tId\tComment\tSpecie\tFragment\tDataset\tIsospecies\tSD\tTime'/>
                            <has_n_lines n='30'/>
                        </has_archive_member>
                        <has_archive_member path='Sample_1.mflux'>
                            <has_text_matching expression='Id\tComment\tFlux\tValue\tSD'/>
                            <has_text_matching expression='Glc_q'/>
                            <has_n_lines n='4'/>
                        </has_archive_member>
                        <has_archive_member path='Sample_1.netw'>
                            <has_n_lines n='86'/>
                        </has_archive_member>
                        <has_archive_member path='Sample_1.tvar'/>
                        <has_archive_member path='Sample_1.linp'/>
                        <has_archive_member path='Sample_1.cnstr'/>
                        <has_archive_member path='Sample_1.opt'/>
                    </assert_contents>
                </element>

This does not work as I get this simple error message showing that the collection is not being detected I think by planemo:

Output collection 'list_output': failed to find identifier 'Sample_1' in the tool generated elements ['conda_activate.log']

Any ideas on how I can fix this?

Thanks!!

Hi @llegregam

For this part

when inputing regular data, there will be an unknown number of zip files, and the content of those files may not be known, but for your small test data, is the result reproducible across tool runs and deployments?

If so, then create the test assertions to double check that what you expected to happen did happen, or the reverse for negative tests (expected failures, where you might be checking the logs for certain messages instead).

There are other ways to do this, like just counting up the number of items, and there will be examples of that in the Tool Shed, but if you have a tool, some test data, and expected outputs from that specific test data, this should be testable at the file level.

Let us know what you think or if you need more help! :slight_smile: