Added tool test for recursive subset of h5 keys

This commit is contained in:
msauria
2019-05-16 15:52:30 -04:00
parent 2d0f67ac6b
commit dfaaf5a5bf
5 changed files with 39 additions and 1 deletions
+18
View File
@@ -31,3 +31,21 @@ def assert_has_h5_keys(output_bytes, keys):
output_temp = io.BytesIO(output_bytes)
local_keys = sorted(list(h5py.File(output_temp, 'r').keys()))
assert local_keys == h5_keys, "Not a HDF5 file or H5 keys do not match:\n\t%s\n\t%s" % (local_keys, h5_keys)
def assert_contains_h5_keys(output_bytes, keys):
""" Asserts the specified HDF5 output contains the given keys, including recursive group paths."""
_assert_h5py()
keys = [k.strip() for k in keys.strip().split(',')]
h5_keys = sorted(keys)
output_temp = io.BytesIO(output_bytes)
local_keys = []
def append_keys(key):
local_keys.append(key)
return None
h5py.File(output_temp, 'r').visit(append_keys)
missing = 0
for key in h5_keys:
if key not in local_keys:
missing += 1
assert missing == 0, "Not a HDF5 file or H5 keys missing:\n\t%s\n\t%s" % (local_keys, h5_keys)
+12
View File
@@ -1652,6 +1652,8 @@ module.
</xs:element>
<xs:element name="has_h5_keys" type="AssertHasH5Keys">
</xs:element>
<xs:element name="contains_h5_keys" type="AssertContainsH5Keys">
</xs:element>
<xs:element name="has_h5_attribute" type="AssertHasH5Attribute">
</xs:element>
<xs:element name="has_archive_member" type="AssertHasArchiveMember">
@@ -1668,6 +1670,16 @@ module.
</xs:annotation>
</xs:attribute>
</xs:complexType>
<xs:complexType name="AssertContainsH5Keys">
<xs:annotation>
<xs:documentation xml:lang="en"><![CDATA[Asserts HDF5 output includes a set of attributes (``keys``) including nested attributes, specified as a comma-separated list (e.g. ``<contains_h5_keys keys="bins,resolution/chroms,indexes,pixels" />``).]]></xs:documentation>
</xs:annotation>
<xs:attribute name="keys" type="xs:string">
<xs:annotation>
<xs:documentation xml:lang="en">Comma-separated list of HDF5 attributes to check for.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
<xs:complexType name="AssertHasH5Attribute">
<xs:annotation>
<xs:documentation xml:lang="en"><![CDATA[Asserts HDF5 output contains the specified ``value`` for an attribute (``key``) (e.g. ``<has_attr key="nchroms" value="15" />``).]]></xs:documentation>
+7
View File
@@ -60,6 +60,7 @@ DynamicProxy.prototype.rewriteRequest = function(request) {
DynamicProxy.prototype.targetForRequest = function(request) {
// return proxy target for a given url
var session = this.findSession(request);
console.log('Session: ', session);
for (var mappedSession in this.sessionMap) {
if(session == mappedSession) {
return this.sessionMap[session].target;
@@ -70,8 +71,10 @@ DynamicProxy.prototype.targetForRequest = function(request) {
};
DynamicProxy.prototype.findSession = function(request) {
console.log("SessionCookie: ", this.sessionCookie);
var sessionCookie = this.sessionCookie,
rc = request.headers.cookie;
console.log('RequestCookie: ', rc);
if(!rc) {
return null;
}
@@ -91,6 +94,10 @@ DynamicProxy.prototype.findSession = function(request) {
DynamicProxy.prototype.handleProxyRequest = function(req, res) {
var othis = this;
var target = this.targetForRequest(req);
console.log(req.method);
console.log(req.url);
console.log(target.host);
console.log(target.port);
if(this.debug) {
console.log("PROXY " + req.method + " " + req.url + " to " + target.host + ':' + target.port);
}
Binary file not shown.
+2 -1
View File
@@ -13,7 +13,8 @@
<param name="input" value="matrix.cool" />
<output name="output">
<assert_contents>
<has_h5_keys keys="bins, chroms,indexes,pixels" />
<has_h5_keys keys="bins,chroms,indexes,pixels" />
<contains_h5_keys keys="bins,chroms/length,chroms,name" />
<has_h5_attribute key="nbins" value="33754" />
<has_h5_attribute key="nchroms" value="15" />
</assert_contents>