Warning
This document is for an in-development version of Galaxy. You can alternatively view this page in the latest release if it exists or view the top of the latest release's documentation.
galaxy.tool_util.verify.asserts package
- galaxy.tool_util.verify.asserts.verify_assertions(data: bytes, assertion_description_list: list, decompress: bool = False)[source]
This function takes a list of assertions and a string to check these assertions against.
Submodules
galaxy.tool_util.verify.asserts.archive module
- galaxy.tool_util.verify.asserts.archive.assert_has_archive_member(output_bytes: ~typing.Annotated[bytes, "The target output of a tool or workflow read as raw Python 'bytes'"], path: ~typing.Annotated[str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff8e3e0>], verify_assertions_function: ~galaxy.tool_util.verify.asserts._types.VerifyAssertionsFunction, children: ~typing.Annotated[~typing.Any, 'Parsed child assertions'] | None = None, all: ~types.Annotated[bool | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff8e2f0>] = False, n: ~types.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff97c10>] | None = None, delta: ~types.Annotated[int | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff95fc0>] = 0, min: ~types.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff97e50>] | None = None, max: ~types.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff97d00>] | None = None, negate: ~types.Annotated[bool | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff951b0>] = False) None[source]
This tag allows to check if
pathis contained in a compressed file.The path is a regular expression that is matched against the full paths of the objects in the compressed file (remember that “matching” means it is checked if a prefix of the full path of an archive member is described by the regular expression). Valid archive formats include
.zip,.tar, and.tar.gz. Note that depending on the archive creation method:full paths of the members may be prefixed with
./directories may be treated as empty files
`xml <has_archive_member path="./path/to/my-file.txt"/> `With
nanddelta(orminandmax) assertions on the number of archive members matchingpathcan be expressed. The following could be used, e.g., to assert an archive containing n±1 elements out of which at least 4 need to have atxtextension.`xml <has_archive_member path=".*" n="10" delta="1"/> <has_archive_member path=".*\.txt" min="4"/> `In addition the tag can contain additional assertions as child elements about the first member in the archive matching the regular expression
path. For instance```xml <has_archive_member path=”.*/my-file.txt”>
<not_has_text text=”EDK72998.1”/>
If the
allattribute is set totruethen all archive members are subject to the assertions. Note that, archive members matching thepathare sorted alphabetically.The
negateattribute of thehas_archive_memberassertion only affects the asserts on the presence and number of matching archive members, but not any sub-assertions (which can offer thenegateattribute on their own). The check if the file is an archive at all, which is also done by the function, is not affected.
galaxy.tool_util.verify.asserts.hdf5 module
- galaxy.tool_util.verify.asserts.hdf5.assert_has_h5_attribute(output_bytes: ~typing.Annotated[bytes, "The target output of a tool or workflow read as raw Python 'bytes'"], key: ~typing.Annotated[str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f81a1756590>], value: ~typing.Annotated[str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f81a1756650>]) None[source]
Asserts HDF5 output contains the specified
valuefor an attribute (key), e.g.`xml <has_h5_attribute key="nchroms" value="15" /> `
- galaxy.tool_util.verify.asserts.hdf5.assert_has_h5_keys(output_bytes: ~typing.Annotated[bytes, "The target output of a tool or workflow read as raw Python 'bytes'"], keys: ~typing.Annotated[str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f81a1756710>]) None[source]
Asserts the specified HDF5 output has the given keys.
galaxy.tool_util.verify.asserts.size module
- galaxy.tool_util.verify.asserts.size.assert_has_size(output_bytes: ~typing.Annotated[bytes, "The target output of a tool or workflow read as raw Python 'bytes'"], value: ~types.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff8cd60>] | None = None, size: ~types.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff8cf70>] | None = None, delta: ~types.Annotated[int | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff95fc0>] = 0, min: ~types.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff97e50>] | None = None, max: ~types.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff97d00>] | None = None, negate: ~types.Annotated[bool | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff951b0>] = False) None[source]
Asserts the specified output has a size of the specified value
Attributes size and value or synonyms though value is considered deprecated. The size optionally allows for absolute (
delta) difference.
galaxy.tool_util.verify.asserts.tabular module
- galaxy.tool_util.verify.asserts.tabular.get_first_line(output: str, comment: str) str[source]
get the first non-comment and non-empty line
- galaxy.tool_util.verify.asserts.tabular.assert_has_n_columns(output: ~typing.Annotated[str, 'The target output of a tool or workflow read as a UTF-8 string'], n: ~types.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff97c10>] | None = None, delta: ~types.Annotated[int | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff95fc0>] = 0, min: ~types.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff97e50>] | None = None, max: ~types.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff97d00>] | None = None, sep: ~typing.Annotated[str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff8d0c0>] = '\t', comment: ~typing.Annotated[str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff8d270>] = '', negate: ~types.Annotated[bool | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff951b0>] = False) None[source]
Asserts tabular output contains the specified number (
n) of columns.For instance,
<has_n_columns n="3"/>. The assertion tests only the first line. Number of columns can optionally also be specified withdelta. Alternatively the range of expected occurrences can be specified byminand/ormax.Optionally a column separator (
sep, default is ``) `and comment character(s) can be specified (``comment, default is empty string). The first non-comment line is used for determining the number of columns.
galaxy.tool_util.verify.asserts.text module
- galaxy.tool_util.verify.asserts.text.assert_has_text(output: ~typing.Annotated[str, 'The target output of a tool or workflow read as a UTF-8 string'], text: ~typing.Annotated[str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f81a1be0a60>], n: ~types.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff97c10>] | None = None, delta: ~types.Annotated[int | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff95fc0>] = 0, min: ~types.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff97e50>] | None = None, max: ~types.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff97d00>] | None = None, negate: ~types.Annotated[bool | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff951b0>] = False) None[source]
Asserts specified output contains the substring specified by the argument text. The exact number of occurrences can be optionally specified by the argument n
- galaxy.tool_util.verify.asserts.text.assert_not_has_text(output: ~typing.Annotated[str, 'The target output of a tool or workflow read as a UTF-8 string'], text: ~typing.Annotated[str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f81a1be0a60>]) None[source]
Asserts specified output does not contain the substring specified by the argument text
- galaxy.tool_util.verify.asserts.text.assert_has_line(output: ~typing.Annotated[str, 'The target output of a tool or workflow read as a UTF-8 string'], line: ~typing.Annotated[str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff8f1c0>], n: ~types.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff97c10>] | None = None, delta: ~types.Annotated[int | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff95fc0>] = 0, min: ~types.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff97e50>] | None = None, max: ~types.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff97d00>] | None = None, negate: ~types.Annotated[bool | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff951b0>] = False) None[source]
Asserts the specified output contains the line specified by the argument line. The exact number of occurrences can be optionally specified by the argument n
- galaxy.tool_util.verify.asserts.text.assert_has_n_lines(output: ~typing.Annotated[str, 'The target output of a tool or workflow read as a UTF-8 string'], n: ~types.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff97c10>] | None = None, delta: ~types.Annotated[int | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff95fc0>] = 0, min: ~types.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff97e50>] | None = None, max: ~types.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff97d00>] | None = None, negate: ~types.Annotated[bool | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff951b0>] = False) None[source]
Asserts the specified output contains
nlines allowing for a difference in the number of lines (delta) or relative differebce in the number of lines
- galaxy.tool_util.verify.asserts.text.assert_has_text_matching(output: ~typing.Annotated[str, 'The target output of a tool or workflow read as a UTF-8 string'], expression: ~typing.Annotated[str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff8f100>], n: ~types.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff97c10>] | None = None, delta: ~types.Annotated[int | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff95fc0>] = 0, min: ~types.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff97e50>] | None = None, max: ~types.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff97d00>] | None = None, negate: ~types.Annotated[bool | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff951b0>] = False) None[source]
Asserts the specified output contains text matching the regular expression specified by the argument expression. If n is given the assertion checks for exactly n (nonoverlapping) occurrences.
- galaxy.tool_util.verify.asserts.text.assert_has_line_matching(output: ~typing.Annotated[str, 'The target output of a tool or workflow read as a UTF-8 string'], expression: ~typing.Annotated[str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff8f100>], n: ~types.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff97c10>] | None = None, delta: ~types.Annotated[int | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff95fc0>] = 0, min: ~types.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff97e50>] | None = None, max: ~types.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff97d00>] | None = None, negate: ~types.Annotated[bool | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff951b0>] = False) None[source]
Asserts the specified output contains a line matching the regular expression specified by the argument expression. If n is given the assertion checks for exactly n occurrences.
galaxy.tool_util.verify.asserts.xml module
- galaxy.tool_util.verify.asserts.xml.assert_is_valid_xml(output: Annotated[str, 'The target output of a tool or workflow read as a UTF-8 string']) None[source]
Asserts the output is a valid XML file (e.g.
<is_valid_xml />).
- galaxy.tool_util.verify.asserts.xml.assert_has_element_with_path(output: ~typing.Annotated[str, 'The target output of a tool or workflow read as a UTF-8 string'], path: ~typing.Annotated[str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f81a1f63e80>], negate: ~types.Annotated[bool | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff951b0>] = False) None[source]
Asserts the XML output contains at least one element (or tag) with the specified XPath-like
path, e.g.`xml <has_element_with_path path="BlastOutput_param/Parameters/Parameters_matrix" /> `With
negatethe result of the assertion can be inverted.
- galaxy.tool_util.verify.asserts.xml.assert_has_n_elements_with_path(output: ~typing.Annotated[str, 'The target output of a tool or workflow read as a UTF-8 string'], path: ~typing.Annotated[str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f81a1f63e80>], n: ~types.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff97c10>] | None = None, delta: ~types.Annotated[int | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff95fc0>] = 0, min: ~types.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff97e50>] | None = None, max: ~types.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff97d00>] | None = None, negate: ~types.Annotated[bool | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff951b0>] = False) None[source]
Asserts the XML output contains the specified number (
n, optionally withdelta) of elements (or tags) with the specified XPath-likepath.For example:
`xml <has_n_elements_with_path n="9" path="BlastOutput_iterations/Iteration/Iteration_hits/Hit/Hit_num" /> `Alternatively to
nanddeltaalso theminandmaxattributes can be used to specify the range of the expected number of occurrences. Withnegatethe result of the assertion can be inverted.
- galaxy.tool_util.verify.asserts.xml.assert_element_text_matches(output: ~typing.Annotated[str, 'The target output of a tool or workflow read as a UTF-8 string'], path: ~typing.Annotated[str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f81a1f63e80>], expression: ~typing.Annotated[str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f81a1f628c0>], negate: ~types.Annotated[bool | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff951b0>] = False) None[source]
Asserts the text of the XML element with the specified XPath-like
pathmatches the regular expression defined byexpression.For example:
`xml <element_text_matches path="BlastOutput_version" expression="BLASTP\s+2\.2.*"/> `The assertion implicitly also asserts that an element matching
pathexists. Withnegatethe result of the assertion (on the matching) can be inverted (the implicit assertion on the existence of the path is not affected).
- galaxy.tool_util.verify.asserts.xml.assert_element_text_is(output: ~typing.Annotated[str, 'The target output of a tool or workflow read as a UTF-8 string'], path: ~typing.Annotated[str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f81a1f63e80>], text: ~typing.Annotated[str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f81a17557e0>], negate: ~types.Annotated[bool | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff951b0>] = False) None[source]
Asserts the text of the XML element with the specified XPath-like
pathis the specifiedtext.For example:
`xml <element_text_is path="BlastOutput_program" text="blastp" /> `The assertion implicitly also asserts that an element matching
pathexists. Withnegatethe result of the assertion (on the equality) can be inverted (the implicit assertion on the existence of the path is not affected).
- galaxy.tool_util.verify.asserts.xml.assert_attribute_matches(output: ~typing.Annotated[str, 'The target output of a tool or workflow read as a UTF-8 string'], path: ~typing.Annotated[str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f81a1f63e80>], attribute: ~typing.Annotated[str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f81a1f63ac0>], expression: ~typing.Annotated[str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f81a1f63580>], negate: ~types.Annotated[bool | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff951b0>] = False) None[source]
Asserts the XML
attributefor the element (or tag) with the specified XPath-likepathmatches the regular expression specified byexpression.For example:
`xml <attribute_matches path="outerElement/innerElement2" attribute="foo2" expression="bar\d+" /> `The assertion implicitly also asserts that an element matching
pathexists. Withnegatethe result of the assertion (on the matching) can be inverted (the implicit assertion on the existence of the path is not affected).
- galaxy.tool_util.verify.asserts.xml.assert_attribute_is(output: ~typing.Annotated[str, 'The target output of a tool or workflow read as a UTF-8 string'], path: ~typing.Annotated[str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f81a1f63e80>], attribute: ~typing.Annotated[str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f81a1f63ac0>], text: ~typing.Annotated[str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f81a1755570>], negate: ~types.Annotated[bool | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff951b0>] = False) None[source]
Asserts the XML
attributefor the element (or tag) with the specified XPath-likepathis the specifiedtext.For example:
`xml <attribute_is path="outerElement/innerElement1" attribute="foo" text="bar" /> `The assertion implicitly also asserts that an element matching
pathexists. Withnegatethe result of the assertion (on the equality) can be inverted (the implicit assertion on the existence of the path is not affected).
- galaxy.tool_util.verify.asserts.xml.assert_element_text(output: ~typing.Annotated[str, 'The target output of a tool or workflow read as a UTF-8 string'], path: ~typing.Annotated[str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f81a1f63e80>], verify_assertions_function: ~galaxy.tool_util.verify.asserts._types.VerifyAssertionsFunction, children: ~typing.Annotated[~typing.Any, 'Parsed child assertions'], negate: ~types.Annotated[bool | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff951b0>] = False) None[source]
This tag allows the developer to recurisively specify additional assertions as child elements about just the text contained in the element specified by the XPath-like
path, e.g.```xml <element_text path=”BlastOutput_iterations/Iteration/Iteration_hits/Hit/Hit_def”>
<not_has_text text=”EDK72998.1” />
The assertion implicitly also asserts that an element matching
pathexists. Withnegatethe result of the implicit assertions can be inverted. The sub-assertions, which have their ownnegateattribute, are not affected bynegate.
- galaxy.tool_util.verify.asserts.xml.assert_xml_element(output: ~typing.Annotated[str, 'The target output of a tool or workflow read as a UTF-8 string'], path: ~typing.Annotated[str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f81a1f63e80>], verify_assertions_function: ~galaxy.tool_util.verify.asserts._types.VerifyAssertionsFunction | None = None, children: ~typing.Annotated[~typing.Any, 'Parsed child assertions'] | None = None, attribute: ~types.Annotated[str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f81a1757b50>] | None = None, all: ~types.Annotated[bool | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f81a1755990>] = False, n: ~types.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff97c10>] | None = None, delta: ~types.Annotated[int | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff95fc0>] = 0, min: ~types.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff97e50>] | None = None, max: ~types.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff97d00>] | None = None, negate: ~types.Annotated[bool | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7f819ff951b0>] = False) None[source]
Assert if the XML file contains element(s) or tag(s) with the specified [XPath-like
path](https://lxml.de/xpathxslt.html). Ifnanddeltaorminandmaxare given also the number of occurrences is checked.<xml_element path=”./elem”/> <xml_element path=”./elem/more[2]”/> <xml_element path=”.//more” n=”3” delta=”1”/>
With
negate="true"the outcome of the assertions wrt the presence and number ofpathcan be negated. If there are any sub assertions then check them againstthe content of the attribute
attributethe element’s text if no attribute is given
- <xml_element path=”./elem/more[2]” attribute=”name”>
<has_text_matching expression=”foo$”/>
</xml_element>
Sub-assertions are not subject to the
negateattribute ofxml_element. Ifallistruethen the sub assertions are checked for all occurrences.Note that all other XML assertions can be expressed by this assertion (Galaxy also implements the other assertions by calling this one).