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+ {
xmldb:get-child-collections($config-params:projects-dir)
};
(:~
: STATUS: UNCLEAR! COMES FROM OLDE SADE! -- Returns the scripts and links
: required by the modules as configured in the project-config either put code
: directly into `<container key="html-head">` or if a module is mentioned in
: the config, its config is checked for <container key="html-head" >
:)
declare function config:html-head($node as node(), $model as map(*)) {
let $head := $model("config")//container[./@key='html-head']
return $head/*
declare function local:mkcol-recursive($collection, $components) {
if (exists($components)) then
let $newColl := concat($collection, "/", $components[1])
return
if(xmldb:collection-available($newColl))
then local:mkcol-recursive($newColl, subsequence($components, 2))
else (
xmldb:create-collection($collection, $components[1]),
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") )
then true()
else
(: read test config :)
let $testconfig := doc("tests.xml")
let $testconfig := doc("tests.xml")//testdata[@module="f-indexviewer"]
(: prepare the collections :)
let $prepare-collections :=
for $create in $testconfig//create/collection
......
......@@ -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
%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")
%test:setUp
function f-misc:setup(){
let $testconfig := doc("tests.xml")//testdata[@module="f-misc"]
(: prepare the collections :)
let $prepare-collections :=
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?)
......
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