finish metadata equal validator

This commit is contained in:
Matthias Bernt
2023-06-06 10:02:30 +02:00
parent 1f56fa37d7
commit 12a4464b48
5 changed files with 92 additions and 25 deletions
+40 -10
View File
@@ -1,29 +1,59 @@
<tool id="metadata_check_eq" name="metadata_check_eq" version="1.0.0">
<!-- functional tool test for the dataset_metadata_equal validator -->
<tool id="metadata_check_eq" name="metadata_check_eq" version="1.0.0" profile="23.1">
<description>Tests whether asserting metadata equals something works.</description>
<command><![CDATA[
cp '$input' '$output'
#if $input or $input_negate
echo "sucess" >> '$output' &&
#end if
#if $input
echo "columns $input.metadata.columns" >> '$output' &&
echo "column_names $input.metadata.column_names" >> '$output'
#else
echo "columns $input_negate.metadata.columns" >> '$output' &&
echo "column_names $input_negate.metadata.column_names" >> '$output'
#end if
]]></command>
<inputs>
<param name="input" type="data" multiple="false" format="tabular,csv">
<validator type="metdata_eq" metadata_name="delimiter" value="&#x9;" />
<param name="input" type="data" optional="true" multiple="false" format="tabular,csv">
<validator type="dataset_metadata_equal" metadata_name="columns" value="12" />
<validator type="dataset_metadata_equal" metadata_name="column_names" value="Transaction_date,Product,Price,Payment_Type,Name,City,State,Country,Account_Created,Last_Login,Latitude,Longitude" />
</param>
<param name="input_negate" type="data" optional="true" multiple="false" format="tabular,csv">
<validator type="dataset_metadata_equal" metadata_name="columns" negate="true" value="12"/>
<validator type="dataset_metadata_equal" metadata_name="column_names" negate="true" value="Transaction_date,Product,Price,Payment_Type,Name,City,State,Country,Account_Created,Last_Login,Latitude,Longitude" />
</param>
</inputs>
<outputs>
<data format="tabular" name="output" format_source="input">
</data>
<data name="output" format="txt"/>
</outputs>
<tests>
<test expect_failure="true">
<param name="input" value="1.tabular" ftype="tabular" />
</test>
<test>
<param name="input" value="1.tabular" format="tabular" />
<param name="input" value="1.csv" ftype="csv" />
<output name="output">
<metadata name="delimiter" value="&#x9;"/>
<assert_contents>
<has_text text="sucess"/>
<has_text text="columns 12"/>
<!-- unfortunately it seems impossible to access metadata and ,-join in cheetah -->
<has_text text="column_names __ob____sq__Transaction_date__sq__, __sq__Product__sq__, __sq__Price__sq__, __sq__Payment_Type__sq__, __sq__Name__sq__, __sq__City__sq__, __sq__State__sq__, __sq__Country__sq__, __sq__Account_Created__sq__, __sq__Last_Login__sq__, __sq__Latitude__sq__, __sq__Longitude__sq____cb__"/>
</assert_contents>
</output>
</test>
<test>
<param name="input" value="1.csv" format="csv" />
<param name="input_negate" value="1.tabular" ftype="tabular" />
<output name="output">
<metadata name="delimiter" value="&#x9;"/>
<assert_contents>
<has_text text="sucess"/>
<has_text text="columns 3"/>
<!-- tabular has no column names -->
<has_text text="column_names __ob____cb__"/>
</assert_contents>
</output>
</test>
<test expect_failure="true">
<param name="input_negate" value="1.csv" ftype="csv" />
</test>
</tests>
</tool>