Commit a8a4d116 authored by Mathias Goebel's avatar Mathias Goebel 🎠
Browse files

new test setup

parent 76cc540a
...@@ -143,13 +143,29 @@ declare function config:list-projects() as xs:string+ { ...@@ -143,13 +143,29 @@ declare function config:list-projects() as xs:string+ {
xmldb:get-child-collections($config-params:projects-dir) xmldb:get-child-collections($config-params:projects-dir)
}; };
(:~ declare function local:mkcol-recursive($collection, $components) {
: STATUS: UNCLEAR! COMES FROM OLDE SADE! -- Returns the scripts and links if (exists($components)) then
: required by the modules as configured in the project-config either put code let $newColl := concat($collection, "/", $components[1])
: directly into `<container key="html-head">` or if a module is mentioned in return
: the config, its config is checked for <container key="html-head" > if(xmldb:collection-available($newColl))
:) then local:mkcol-recursive($newColl, subsequence($components, 2))
declare function config:html-head($node as node(), $model as map(*)) { else (
let $head := $model("config")//container[./@key='html-head'] xmldb:create-collection($collection, $components[1]),
return $head/* local:mkcol-recursive($newColl, subsequence($components, 2))
)
else
()
};
(: Helper function to recursively create a collection hierarchy. :)
declare function app:mkcol($path) {
if(not(starts-with($path, "/")))
then error(QName("error", "path"), "Invalid path. Absolute path required.")
else
if($path => matches("[^a-zA-Z0-9\-\.\+]"))
then error(QName("error", "charset"), "Invalid path. use characters that match [a-zA-Z0-9\-\.\+] only.")
else
let $components := tokenize($path, "/")
return
local:mkcol-recursive($components[1], subsequence($components, 2))
}; };
...@@ -23,7 +23,7 @@ if( xmldb:collection-available("/db/sade-projects/textgrid") ) ...@@ -23,7 +23,7 @@ if( xmldb:collection-available("/db/sade-projects/textgrid") )
then true() then true()
else else
(: read test config :) (: read test config :)
let $testconfig := doc("tests.xml") let $testconfig := doc("tests.xml")//testdata[@module="f-indexviewer"]
(: prepare the collections :) (: prepare the collections :)
let $prepare-collections := let $prepare-collections :=
for $create in $testconfig//create/collection for $create in $testconfig//create/collection
......
...@@ -11,12 +11,30 @@ declare namespace xhtml="http://www.w3.org/1999/xhtml"; ...@@ -11,12 +11,30 @@ declare namespace xhtml="http://www.w3.org/1999/xhtml";
declare variable $f-misc:metadata-collection := collection("/db/sade-projects/textgrid/data/xml/meta"); declare variable $f-misc:metadata-collection := collection("/db/sade-projects/textgrid/data/xml/meta");
declare declare
%test:arg("baseUri","textgrid:16b00") %test:assertEquals("Notizbuch C7") %test:setUp
%test:arg("baseUri","") %test:assertEquals("") function f-misc:setup(){
function f-misc:get-title-by-baseUri($baseUri as xs:string) as xs:string? { let $testconfig := doc("tests.xml")//testdata[@module="f-misc"]
if($baseUri = "") then () else (: prepare the collections :)
$f-misc:metadata-collection//tgmd:textgridUri[starts-with(string(.), $baseUri)]/ancestor::tgmd:object//tgmd:title/string() let $prepare-collections :=
=> replace("([A-E])0(\d)", "$1$2") for $create in $testconfig//create/collection
return
config:mkcol($create/@path)
(: prepare documents :)
let $prepare-documents :=
for $create in $testconfig//create/document
return
xmldb:store($create/@collection, $create/@name, $create/*)
return true()
};
declare
%test:arg("baseUri","textgrid:16b00") %test:assertEquals("Notizbuch C7")
%test:arg("baseUri","") %test:assertEquals("")
function f-misc:get-title-by-baseUri($baseUri as xs:string)
as xs:string? {
if($baseUri = "") then () else
$f-misc:metadata-collection//tgmd:textgridUri[starts-with(string(.), $baseUri)]/ancestor::tgmd:object//tgmd:title/string()
=> replace("([A-E])0(\d)", "$1$2")
}; };
declare function f-misc:nb-param-to-title($node as node(), $model as map(*), $nb as xs:string?) declare function f-misc:nb-param-to-title($node as node(), $model as map(*), $nb as xs:string?)
......
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment