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: 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
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.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 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: 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 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: 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 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: 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 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: 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-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: 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-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: 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” />
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: 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). 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).