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