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
......
......@@ -10,10 +10,28 @@ 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: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? {
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")
......
<?xml version="1.0" encoding="UTF-8"?>
<testdata>
<!-- test configuration and sample data -->
<!-- by setting up some test data we omit circular dependencies between
<setup>
<testdata module="f-misc">
<create>
<collection path="/db/sade-projects/textgrid/data/xml/meta"/>
<document collection="/db/sade-projects/textgrid/data/xml/meta" name="16b00.xml">
<MetadataContainerType xmlns="http://textgrid.info/namespaces/metadata/core/2010" xmlns:ns2="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<object>
<generic>
<provided>
<title>Notizbuch C07</title>
<format>text/xml</format>
<notes/>
</provided>
<generated>
<created>2012-10-09T09:21:00.413+02:00</created>
<lastModified>2012-12-19T12:11:01.557+01:00</lastModified>
<textgridUri extRef="">textgrid:16b00.0</textgridUri>
<revision>0</revision>
<extent>12694</extent>
<dataContributor>Mathias.G%C3%B6bel@textgrid.de</dataContributor>
<project id="TGPR-9b18459d-3a6b-004f-b6aa-4fba2b9e1d3e">Fontane Notizbücher</project>
<permissions>read</permissions>
</generated>
</generic>
<item/>
<tgmd:relations xmlns:tgmd="http://textgrid.info/namespaces/metadata/core/2010"/>
</object>
</MetadataContainerType>
</document>
</create>
</testdata>
<testdata module="f-indexviewer">
<!-- test configuration and sample data -->
<!-- by setting up some test data we omit circular dependencies between
modules for data import and buisness logic. -->
<create>
<collection target="/db" new="sade-projects"/>
......@@ -517,4 +548,5 @@
</data>
</document-template>
</create>
</testdata>
</testdata>
</setup>
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