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: bytes[bytes], path: str[str], verify_assertions_function: VerifyAssertionsFunction, children: Any[Any] | None = None, all: bool | str[bool | str] = False, n: int | str | None[int | str | None] | None = None, delta: int | str[int | str] = 0, min: int | str | None[int | str | None] | None = None, max: int | str | None[int | str | None] | None = None, negate: bool | str[bool | str] = 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: bytes[bytes], key: str[str], value: str[str]) 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: bytes[bytes], keys: str[str]) 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: bytes[bytes], value: int | str | None[int | str | None] | None = None, size: int | str | None[int | str | None] | None = None, delta: int | str[int | str] = 0, min: int | str | None[int | str | None] | None = None, max: int | str | None[int | str | None] | None = None, negate: bool | str[bool | str] = 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: str[str], n: int | str | None[int | str | None] | None = None, delta: int | str[int | str] = 0, min: int | str | None[int | str | None] | None = None, max: int | str | None[int | str | None] | None = None, sep: str[str] = '\t', comment: str[str] = '', negate: bool | str[bool | str] = 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 occurences 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: str[str], text: str[str], n: int | str | None[int | str | None] | None = None, delta: int | str[int | str] = 0, min: int | str | None[int | str | None] | None = None, max: int | str | None[int | str | None] | None = None, negate: bool | str[bool | str] = 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: str[str], text: str[str]) 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: str[str], line: str[str], n: int | str | None[int | str | None] | None = None, delta: int | str[int | str] = 0, min: int | str | None[int | str | None] | None = None, max: int | str | None[int | str | None] | None = None, negate: bool | str[bool | str] = 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: str[str], n: int | str | None[int | str | None] | None = None, delta: int | str[int | str] = 0, min: int | str | None[int | str | None] | None = None, max: int | str | None[int | str | None] | None = None, negate: bool | str[bool | str] = 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: str[str], expression: str[str], n: int | str | None[int | str | None] | None = None, delta: int | str[int | str] = 0, min: int | str | None[int | str | None] | None = None, max: int | str | None[int | str | None] | None = None, negate: bool | str[bool | str] = 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: str[str], expression: str[str], n: int | str | None[int | str | None] | None = None, delta: int | str[int | str] = 0, min: int | str | None[int | str | None] | None = None, max: int | str | None[int | str | None] | None = None, negate: bool | str[bool | str] = 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: str[str]) 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: str[str], path: str[str], negate: bool | str[bool | str] = 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: str[str], path: str[str], n: int | str | None[int | str | None] | None = None, delta: int | str[int | str] = 0, min: int | str | None[int | str | None] | None = None, max: int | str | None[int | str | None] | None = None, negate: bool | str[bool | str] = 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 occurences. With negate the result of the assertion can be inverted.

galaxy.tool_util.verify.asserts.xml.assert_element_text_matches(output: str[str], path: str[str], expression: str[str], negate: bool | str[bool | str] = 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: str[str], path: str[str], text: str[str], negate: bool | str[bool | str] = 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: str[str], path: str[str], attribute: str[str], expression: str[str], negate: bool | str[bool | str] = 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: str[str], path: str[str], attribute: str[str], text: str[str], negate: bool | str[bool | str] = 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: str[str], path: str[str], verify_assertions_function: VerifyAssertionsFunction, children: Any[Any], negate: bool | str[bool | str] = 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: str[str], path: str[str], verify_assertions_function: VerifyAssertionsFunction | None = None, children: Any[Any] | None = None, attribute: str | None[str | None] | None = None, all: bool | str[bool | str] = False, n: int | str | None[int | str | None] | None = None, delta: int | str[int | str] = 0, min: int | str | None[int | str | None] | None = None, max: int | str | None[int | str | None] | None = None, negate: bool | str[bool | str] = 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 occurences 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 precence 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 occurences.

Note that all other XML assertions can be expressed by this assertion (Galaxy also implements the other assertions by calling this one).