def utest(h,cpt): n,ok=0,0 o = 'test_%s:'%cpt for i in h.keys(): item = ui.cg(i) n+=1 if item.get(cpt) != h[i]: ok += 1 o += 'Item %d on |%s| Computed:%s|Expected:%s|\n'%(n, i, item.get(cpt),h[i]) o += ('Test OK (%d cases)'%n if ok==0 else 'Test KO on %d tests'%ok) o += '\n' return n,o
def index(req): """ main test page """ req.content_type = 'application/xhtml+xml' o = '<?xml version="1.0" encoding="UTF-8"?>\n' o += '<?xml-stylesheet href="%s" type="text/css"?>\n'%ui.__CSS__ o += '<svg %s editable="yes" test="yes">\n'%ui._SVGNS o += '<title id=".title">Test</title>' o += '<link %s rel="shortcut icon" href="logo16.png"/>\n'%ui._XHTMLNS o += ui.include_ace('.') o += '<script %s type="text/ecmascript" xlink:href="xregexp-min.js"></script>\n'%ui._XLINKNS o += '<script %s type="text/ecmascript" xlink:href="%s"></script>\n'%(ui._XLINKNS,ui.__JS__) o += '<script %s type="text/ecmascript" xlink:href="test_client.js"></script>\n'%ui._XLINKNS o += '<foreignObject display="none" width="100%%" height="100%%"><div %s id=".editor" class="editor"></div></foreignObject>'%ui._XHTMLNS mygraph = ui.cg('') o += mygraph.draw() + ui.menu() + ui.gui_elements() + ui.menubar(req,'reload') o += '<g onclick="run_tests();"><rect x="160" width="70" height="18" fill="red" class="button"/><text y="12" x="166" class="button" fill="white">Run tests</text></g><g transform="translate(5,20)"><text id=".results" stroke-width="0"/></g>' o += '<g onclick="update_tool();"><rect x="245" width="80" height="18" fill="red" class="button"/><text y="12" x="251" class="button" fill="white">Update tool</text></g>' return o + '</svg>'