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.

galaxy.tool_util.verify.asserts.verify_assertion(data: bytes, assertion_description)[source]

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 0x7fd3acf80370>], 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 0x7fd3acf837f0>] = False, n: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3af3077f0>] | None = None, delta: ~typing.Annotated[int | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3af3079a0>] = 0, min: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3af3041c0>] | None = None, max: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3af304130>] | None = None, negate: ~typing.Annotated[bool | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3af306410>] = 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 and delta (or min and max) assertions on the number of archive members matching path can be expressed. The following could be used, e.g., to assert an archive containing n&plusmn;1 elements out of which at least 4 need to have a txt 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”/>

</has_archive_member> ```

If the all attribute is set to true then all archive members are subject to the assertions. Note that, archive members matching the path are sorted alphabetically.

The negate attribute of the has_archive_member assertion only affects the asserts on the presence and number of matching archive members, but not any sub-assertions (which can offer the negate 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 0x7fd3ae38bb20>], value: ~typing.Annotated[str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3ae38a4a0>]) 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 0x7fd3ae3881f0>]) 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 0x7fd3adb13340>] | None = None, size: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3adb11de0>] | None = None, delta: ~typing.Annotated[int | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3af3079a0>] = 0, min: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3af3041c0>] | None = None, max: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3af304130>] | None = None, negate: ~typing.Annotated[bool | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3af306410>] = 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 0x7fd3af3077f0>] | None = None, delta: ~typing.Annotated[int | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3af3079a0>] = 0, min: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3af3041c0>] | None = None, max: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3af304130>] | None = None, sep: ~typing.Annotated[str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3adb10c10>] = '\t', comment: ~typing.Annotated[str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3adb10370>] = '', negate: ~typing.Annotated[bool | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3af306410>] = 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 with delta. Alternatively the range of expected occurrences can be specified by min and/or max.

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 0x7fd3adb125c0>], n: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3af3077f0>] | None = None, delta: ~typing.Annotated[int | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3af3079a0>] = 0, min: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3af3041c0>] | None = None, max: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3af304130>] | None = None, negate: ~typing.Annotated[bool | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3af306410>] = 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 0x7fd3adb125c0>]) 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 0x7fd3adb13880>], n: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3af3077f0>] | None = None, delta: ~typing.Annotated[int | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3af3079a0>] = 0, min: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3af3041c0>] | None = None, max: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3af304130>] | None = None, negate: ~typing.Annotated[bool | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3af306410>] = 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 0x7fd3af3077f0>] | None = None, delta: ~typing.Annotated[int | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3af3079a0>] = 0, min: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3af3041c0>] | None = None, max: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3af304130>] | None = None, negate: ~typing.Annotated[bool | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3af306410>] = 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 0x7fd3adb139d0>], n: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3af3077f0>] | None = None, delta: ~typing.Annotated[int | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3af3079a0>] = 0, min: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3af3041c0>] | None = None, max: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3af304130>] | None = None, negate: ~typing.Annotated[bool | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3af306410>] = 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 0x7fd3adb139d0>], n: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3af3077f0>] | None = None, delta: ~typing.Annotated[int | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3af3079a0>] = 0, min: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3af3041c0>] | None = None, max: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3af304130>] | None = None, negate: ~typing.Annotated[bool | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3af306410>] = 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 0x7fd3ae3884f0>], negate: ~typing.Annotated[bool | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3af306410>] = 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 0x7fd3ae3884f0>], n: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3af3077f0>] | None = None, delta: ~typing.Annotated[int | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3af3079a0>] = 0, min: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3af3041c0>] | None = None, max: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3af304130>] | None = None, negate: ~typing.Annotated[bool | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3af306410>] = False) None[source]

Asserts the XML output contains the specified number (n, optionally with delta) of elements (or tags) with the specified XPath-like path.

For example:

`xml <has_n_elements_with_path n="9" path="BlastOutput_iterations/Iteration/Iteration_hits/Hit/Hit_num" /> `

Alternatively to n and delta also the min and max attributes can be used to specify the range of the expected number of occurrences. With negate 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 0x7fd3ae3884f0>], expression: ~typing.Annotated[str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3ae388430>], negate: ~typing.Annotated[bool | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3af306410>] = False) None[source]

Asserts the text of the XML element with the specified XPath-like path matches the regular expression defined by expression.

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. With negate 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 0x7fd3ae3884f0>], text: ~typing.Annotated[str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3ae38afe0>], negate: ~typing.Annotated[bool | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3af306410>] = False) None[source]

Asserts the text of the XML element with the specified XPath-like path is the specified text.

For example:

`xml <element_text_is path="BlastOutput_program" text="blastp" /> `

The assertion implicitly also asserts that an element matching path exists. With negate 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 0x7fd3ae3884f0>], attribute: ~typing.Annotated[str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3ae388100>], expression: ~typing.Annotated[str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3ae388400>], negate: ~typing.Annotated[bool | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3af306410>] = False) None[source]

Asserts the XML attribute for the element (or tag) with the specified XPath-like path matches the regular expression specified by expression.

For example:

`xml <attribute_matches path="outerElement/innerElement2" attribute="foo2" expression="bar\d+" /> `

The assertion implicitly also asserts that an element matching path exists. With negate 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 0x7fd3ae3884f0>], attribute: ~typing.Annotated[str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3ae388100>], text: ~typing.Annotated[str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3ae38ac50>], negate: ~typing.Annotated[bool | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3af306410>] = False) None[source]

Asserts the XML attribute for the element (or tag) with the specified XPath-like path is the specified text.

For example:

`xml <attribute_is path="outerElement/innerElement1" attribute="foo" text="bar" /> `

The assertion implicitly also asserts that an element matching path exists. With negate 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 0x7fd3ae3884f0>], 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 0x7fd3af306410>] = 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” />

</element_text> ```

The assertion implicitly also asserts that an element matching path exists. With negate the result of the implicit assertions can be inverted. The sub-assertions, which have their own negate attribute, are not affected by negate.

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 0x7fd3ae3884f0>], 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 0x7fd3ae38b3a0>] | None = None, all: ~typing.Annotated[bool | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3ae38b640>] = False, n: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3af3077f0>] | None = None, delta: ~typing.Annotated[int | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3af3079a0>] = 0, min: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3af3041c0>] | None = None, max: ~typing.Annotated[int | str | None, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3af304130>] | None = None, negate: ~typing.Annotated[bool | str, <galaxy.tool_util.verify.asserts._types.AssertionParameter object at 0x7fd3af306410>] = 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). If n and delta or min and max are given also the number of occurrences is checked.

```xml <assert_contents>

<xml_element path=”./elem”/> <xml_element path=”./elem/more[2]”/> <xml_element path=”.//more” n=”3” delta=”1”/>

</assert_contents> ```

With negate="true" the outcome of the assertions wrt the presence and number of path can be negated. If there are any sub assertions then check them against

  • the content of the attribute attribute

  • the element’s text if no attribute is given

```xml <assert_contents>

<xml_element path=”./elem/more[2]” attribute=”name”>

<has_text_matching expression=”foo$”/>

</xml_element>

</assert_contents> ```

Sub-assertions are not subject to the negate attribute of xml_element. If all is true then 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).