Robot Framework
create_jsdata.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 from os.path import abspath, dirname, normpath, join
4 import os
5 import sys
6 
7 BASEDIR = dirname(abspath(__file__))
8 LOG = normpath(join(BASEDIR, '..', 'log.html'))
9 TESTDATA = join(BASEDIR, 'dir.suite')
10 OUTPUT = join(BASEDIR, 'output.xml')
11 TARGET = join(BASEDIR, 'data.js')
12 SRC = normpath(join(BASEDIR, '..', '..', '..'))
13 
14 sys.path.insert(0, SRC)
15 
16 from robot import run
17 from robot.conf.settings import RebotSettings
18 from robot.reporting.resultwriter import Results
19 from robot.reporting.jswriter import JsResultWriter
20 from robot.utils import file_writer
21 
22 
23 def run_robot(testdata, outxml):
24  run(testdata, loglevel='DEBUG', output=outxml, log=None, report=None)
25 
26 
27 def create_jsdata(outxml, target):
28  settings = RebotSettings({
29  'name': '<Suite.Name>',
30  'critical': ['i?'],
31  'noncritical': ['*kek*kone*'],
32  'tagstatlink': ['force:http://google.com:<kuukkeli&gt;',
33  'i*:http://%1/?foo=bar&zap=%1:Title of i%1',
34  '?1:http://%1/<&>:Title',
35  '</script>:<url>:<title>'],
36  'tagdoc': ['test:this_is_*my_bold*_test',
37  'IX:*Combined* and escaped <&lt; tag doc',
38  'i*:Me, myself, and I.',
39  '</script>:<doc>'],
40  'tagstatcombine': ['fooANDi*:No Match',
41  'long1ORcollections',
42  'i?:IX',
43  '<*>:<any>']
44  })
45  result = Results(settings, outxml).js_result
46  config = {'logURL': 'log.html',
47  'title': 'This is a long long title. A very long title indeed. '
48  'And it even contains some stuff to <esc&ape>. '
49  'Yet it should still look good.',
50  'minLevel': 'DEBUG',
51  'defaultLevel': 'DEBUG',
52  'reportURL': 'report.html',
53  'background': {'fail': 'DeepPink'}}
54  with file_writer(target) as output:
55  writer = JsResultWriter(output, start_block='', end_block='')
56  writer.write(result, config)
57  print('Log: ', normpath(join(BASEDIR, '..', 'rebot', 'log.html')))
58  print('Report: ', normpath(join(BASEDIR, '..', 'rebot', 'report.html')))
59 
60 
61 if __name__ == '__main__':
62  run_robot(TESTDATA, OUTPUT)
63  create_jsdata(OUTPUT, TARGET)
64  os.remove(OUTPUT)
def create_jsdata(outxml, target)
def run_robot(testdata, outxml)
def run(*tests, **options)
Programmatic entry point for running tests.
Definition: run.py:557
def file_writer(path=None, encoding='UTF-8', newline=None, usage=None)
Definition: robotio.py:25
def abspath(path, case_normalize=False)
Replacement for os.path.abspath with some enhancements and bug fixes.
Definition: robotpath.py:65
def normpath(path, case_normalize=False)
Replacement for os.path.normpath with some enhancements.
Definition: robotpath.py:46