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 0x7ff34e74e220>], verify_assertions_function: ~galaxy.tool_util.verify.asserts._types.VerifyAssertionsFunction, children: ~typing.Annotated[~typing.Any, 'Parsed child assertions'] | None = None, all: ~typing.Annotated[bool | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e67ab50>] = False, n: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6b9a90>] | None = None, delta: ~typing.Annotated[int | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6b9c10>] = 0, min: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6b9ca0>] | None = None, max: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6b9e50>] | None = None, negate: ~typing.Annotated[bool | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6b9160>] = False) None [source]
This tag allows to check if
path
is 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
n
anddelta
(ormin
andmax
) assertions on the number of archive members matchingpath
can 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 atxt
extension.`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
all
attribute is set totrue
then all archive members are subject to the assertions. Note that, archive members matching thepath
are sorted alphabetically.The
negate
attribute of thehas_archive_member
assertion only affects the asserts on the presence and number of matching archive members, but not any sub-assertions (which can offer thenegate
attribute 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 0x7ff34e74e3a0>], value: ~typing.Annotated[str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e74e1c0>]) None [source]
Asserts HDF5 output contains the specified
value
for 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 0x7ff34e74e2b0>]) 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: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6682e0>] | None = None, size: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e668340>] | None = None, delta: ~typing.Annotated[int | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6b9c10>] = 0, min: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6b9ca0>] | None = None, max: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6b9e50>] | None = None, negate: ~typing.Annotated[bool | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6b9160>] = 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: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6b9a90>] | None = None, delta: ~typing.Annotated[int | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6b9c10>] = 0, min: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6b9ca0>] | None = None, max: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6b9e50>] | None = None, sep: ~typing.Annotated[str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e722040>] = '\t', comment: ~typing.Annotated[str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e7226a0>] = '', negate: ~typing.Annotated[bool | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6b9160>] = 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 occurences can be specified bymin
and/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 0x7ff34eceadc0>], n: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6b9a90>] | None = None, delta: ~typing.Annotated[int | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6b9c10>] = 0, min: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6b9ca0>] | None = None, max: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6b9e50>] | None = None, negate: ~typing.Annotated[bool | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6b9160>] = 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 0x7ff34eceadc0>]) 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 0x7ff34eceab50>], n: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6b9a90>] | None = None, delta: ~typing.Annotated[int | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6b9c10>] = 0, min: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6b9ca0>] | None = None, max: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6b9e50>] | None = None, negate: ~typing.Annotated[bool | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6b9160>] = 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: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6b9a90>] | None = None, delta: ~typing.Annotated[int | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6b9c10>] = 0, min: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6b9ca0>] | None = None, max: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6b9e50>] | None = None, negate: ~typing.Annotated[bool | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6b9160>] = False) None [source]
Asserts the specified output contains
n
lines 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 0x7ff34e7756d0>], n: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6b9a90>] | None = None, delta: ~typing.Annotated[int | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6b9c10>] = 0, min: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6b9ca0>] | None = None, max: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6b9e50>] | None = None, negate: ~typing.Annotated[bool | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6b9160>] = 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 exacly n (nonoverlapping) occurences.
- 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 0x7ff34e7756d0>], n: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6b9a90>] | None = None, delta: ~typing.Annotated[int | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6b9c10>] = 0, min: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6b9ca0>] | None = None, max: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6b9e50>] | None = None, negate: ~typing.Annotated[bool | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6b9160>] = 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 occurences.
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 0x7ff34ec6b580>], negate: ~typing.Annotated[bool | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6b9160>] = 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
negate
the 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 0x7ff34ec6b580>], n: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6b9a90>] | None = None, delta: ~typing.Annotated[int | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6b9c10>] = 0, min: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6b9ca0>] | None = None, max: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6b9e50>] | None = None, negate: ~typing.Annotated[bool | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6b9160>] = 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
n
anddelta
also themin
andmax
attributes can be used to specify the range of the expected number of occurences. Withnegate
the 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 0x7ff34ec6b580>], expression: ~typing.Annotated[str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34ec6b460>], negate: ~typing.Annotated[bool | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6b9160>] = False) None [source]
Asserts the text of the XML element with the specified XPath-like
path
matches 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
path
exists. Withnegate
the 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 0x7ff34ec6b580>], text: ~typing.Annotated[str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff3540995e0>], negate: ~typing.Annotated[bool | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6b9160>] = False) None [source]
Asserts the text of the XML element with the specified XPath-like
path
is the specifiedtext
.For example:
`xml <element_text_is path="BlastOutput_program" text="blastp" /> `
The assertion implicitly also asserts that an element matching
path
exists. Withnegate
the 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 0x7ff34ec6b580>], attribute: ~typing.Annotated[str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34ec6b880>], expression: ~typing.Annotated[str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34ec6b6d0>], negate: ~typing.Annotated[bool | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6b9160>] = False) None [source]
Asserts the XML
attribute
for the element (or tag) with the specified XPath-likepath
matches 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
path
exists. Withnegate
the 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 0x7ff34ec6b580>], attribute: ~typing.Annotated[str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34ec6b880>], text: ~typing.Annotated[str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34ecc27c0>], negate: ~typing.Annotated[bool | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6b9160>] = False) None [source]
Asserts the XML
attribute
for the element (or tag) with the specified XPath-likepath
is the specifiedtext
.For example:
`xml <attribute_is path="outerElement/innerElement1" attribute="foo" text="bar" /> `
The assertion implicitly also asserts that an element matching
path
exists. Withnegate
the 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 0x7ff34ec6b580>], verify_assertions_function: ~galaxy.tool_util.verify.asserts._types.VerifyAssertionsFunction, children: ~typing.Annotated[~typing.Any, 'Parsed child assertions'], negate: ~typing.Annotated[bool | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6b9160>] = 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
path
exists. Withnegate
the result of the implicit assertions can be inverted. The sub-assertions, which have their ownnegate
attribute, 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 0x7ff34ec6b580>], verify_assertions_function: ~galaxy.tool_util.verify.asserts._types.VerifyAssertionsFunction | None = None, children: ~typing.Annotated[~typing.Any, 'Parsed child assertions'] | None = None, attribute: ~typing.Annotated[str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff354099670>] | None = None, all: ~typing.Annotated[bool | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34ecc2b20>] = False, n: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6b9a90>] | None = None, delta: ~typing.Annotated[int | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6b9c10>] = 0, min: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6b9ca0>] | None = None, max: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6b9e50>] | None = None, negate: ~typing.Annotated[bool | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7ff34e6b9160>] = 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). Ifn
anddelta
ormin
andmax
are given also the number of occurences 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 precence and number ofpath
can be negated. If there are any sub assertions then check them againstthe content of the attribute
attribute
the 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
negate
attribute ofxml_element
. Ifall
istrue
then the sub assertions are checked for all occurences.Note that all other XML assertions can be expressed by this assertion (Galaxy also implements the other assertions by calling this one).