3 new revisions:
Revision: 29a715b1199a
Author: Janne Härkönen <[email protected]>
Date: Wed Feb 22 22:29:23 2012
Log: testdoc: handle title
http://code.google.com/p/robotframework/source/detail?r=29a715b1199a
Revision: 474021e73b15
Author: Janne Härkönen <[email protected]>
Date: Wed Feb 22 22:44:29 2012
Log: testdoc: fix for loop type
http://code.google.com/p/robotframework/source/detail?r=474021e73b15
Revision: 7a7dc3b4daf1
Author: Janne Härkönen <[email protected]>
Date: Wed Feb 22 23:11:37 2012
Log: testdoc: handle test timeout
http://code.google.com/p/robotframework/source/detail?r=7a7dc3b4daf1
==============================================================================
Revision: 29a715b1199a
Author: Janne Härkönen <[email protected]>
Date: Wed Feb 22 22:29:23 2012
Log: testdoc: handle title
http://code.google.com/p/robotframework/source/detail?r=29a715b1199a
Modified:
/src/robot/testdoc.py
/src/robot/webcontent/testdoc.html
=======================================
--- /src/robot/testdoc.py Wed Feb 22 15:01:14 2012
+++ /src/robot/testdoc.py Wed Feb 22 22:29:23 2012
@@ -70,16 +70,17 @@
def _write_test_doc(self, suite, outfile, title):
output = codecs.open(outfile, 'w', 'UTF-8')
- model_writer = TestdocModelWriter(output, suite)
+ model_writer = TestdocModelWriter(output, suite, title)
HtmlFileWriter(output, model_writer).write('testdoc.html')
output.close()
class TestdocModelWriter(ModelWriter):
- def __init__(self, output, suite):
+ def __init__(self, output, suite, title):
self._output = output
self._suite = suite
+ self._title = title.replace('_', ' ') if title else ''
def write(self, line):
self._output.write('<script type="text/javascript">' + os.linesep)
@@ -88,7 +89,8 @@
def _write_data(self):
json = JsonConverter().convert(self._suite)
- JsonWriter(self._output).write_json('suite = ', json)
+ json['title'] = self._title
+ JsonWriter(self._output).write_json('testdoc = ', json)
class JsonConverter(object):
=======================================
--- /src/robot/webcontent/testdoc.html Wed Feb 22 22:05:32 2012
+++ /src/robot/webcontent/testdoc.html Wed Feb 22 22:29:23 2012
@@ -35,9 +35,9 @@
<script type="text/javascript">
$(document).ready(function(){
parseTemplates();
- setTitle(window.suite);
- addSuite(window.suite, 'body');
- expandElement(suite);
+ setTitle(window.testdoc);
+ addSuite(window.testdoc, 'body');
+ expandElement(window.testdoc);
});
function parseTemplates() {
@@ -91,7 +91,6 @@
childElement.show();
$('#'+element.id+'_foldingbutton').text('-');
}
-
</script>
<script type="text/x-jquery-tmpl" id="suiteTemplate">
==============================================================================
Revision: 474021e73b15
Author: Janne Härkönen <[email protected]>
Date: Wed Feb 22 22:44:29 2012
Log: testdoc: fix for loop type
http://code.google.com/p/robotframework/source/detail?r=474021e73b15
Modified:
/src/robot/testdoc.py
=======================================
--- /src/robot/testdoc.py Wed Feb 22 22:29:23 2012
+++ /src/robot/testdoc.py Wed Feb 22 22:44:29 2012
@@ -138,11 +138,12 @@
'keywords': self._convert_keywords(test, test_id)}
def _convert_keywords(self, test, test_id):
- return [self._convert_keyword(k, test_id, index, 'KEYWORD')
- for index, k in enumerate(test.keywords)]
+ types = {'kw': 'KEYWORD', 'for': 'FOR'}
+ return [self._convert_keyword(k, test_id, index, types[k.type])
+ for index, k in enumerate(test.keywords)]
def _convert_keyword(self, kw, test_id, index, type):
- return {'name': kw.name,
+ return {'name': kw._get_name(kw.name) if isinstance(kw, Keyword)
else kw.name,
'id': test_id + '-k-%d' % index,
'arguments': ', '.join(kw.args),
'type': type
==============================================================================
Revision: 7a7dc3b4daf1
Author: Janne Härkönen <[email protected]>
Date: Wed Feb 22 23:11:37 2012
Log: testdoc: handle test timeout
http://code.google.com/p/robotframework/source/detail?r=7a7dc3b4daf1
Modified:
/src/robot/testdoc.py
=======================================
--- /src/robot/testdoc.py Wed Feb 22 22:44:29 2012
+++ /src/robot/testdoc.py Wed Feb 22 23:11:37 2012
@@ -99,18 +99,19 @@
return self._convert_suite(suite, 's-0')
def _convert_suite(self, suite, suite_id, index=None):
- suite_id = suite_id + '-s-%d' % index if index is not None else
suite_id
- return {'name': suite.name,
- 'fullName': suite.longname,
- 'source': suite.source,
- 'doc': suite.doc,
- 'id': suite_id,
- 'metadata': dict(suite.metadata),
- 'numberOfTests': suite.get_test_count(),
- 'suites': self._convert_suites(suite, suite_id),
- 'tests': self._convert_tests(suite, suite_id),
- 'keywords': self._get_suite_keywords(suite, suite_id)
- }
+ suite_id = self._get_id(suite_id, 's', index) if index is not None
else suite_id
+ return {
+ 'name': suite.name,
+ 'fullName': suite.longname,
+ 'source': suite.source,
+ 'doc': suite.doc,
+ 'id': suite_id,
+ 'metadata': dict(suite.metadata),
+ 'numberOfTests': suite.get_test_count(),
+ 'suites': self._convert_suites(suite, suite_id),
+ 'tests': self._convert_tests(suite, suite_id),
+ 'keywords': self._get_suite_keywords(suite, suite_id)
+ }
def _get_suite_keywords(self, suite, suite_id):
kws = []
@@ -129,13 +130,16 @@
for index, test in enumerate(suite.tests)]
def _convert_test(self, test, suite_id, index):
- test_id = suite_id + '-t-%d' % index
- return {'name': test.name,
- 'fullName': test.longname,
- 'id': test_id,
- 'doc': test.doc,
- 'tags': test.tags,
- 'keywords': self._convert_keywords(test, test_id)}
+ test_id = self._get_id(suite_id, 't', index)
+ return {
+ 'name': test.name,
+ 'fullName': test.longname,
+ 'id': test_id,
+ 'doc': test.doc,
+ 'tags': test.tags,
+ 'timeout': self._get_timeout(test.timeout),
+ 'keywords': self._convert_keywords(test, test_id)
+ }
def _convert_keywords(self, test, test_id):
types = {'kw': 'KEYWORD', 'for': 'FOR'}
@@ -143,11 +147,24 @@
for index, k in enumerate(test.keywords)]
def _convert_keyword(self, kw, test_id, index, type):
- return {'name': kw._get_name(kw.name) if isinstance(kw, Keyword)
else kw.name,
- 'id': test_id + '-k-%d' % index,
- 'arguments': ', '.join(kw.args),
- 'type': type
- }
+ return {
+ 'name': kw._get_name(kw.name) if isinstance(kw, Keyword) else
kw.name,
+ 'id': test_id + '-k-%d' % index,
+ 'arguments': ', '.join(kw.args),
+ 'type': type
+ }
+
+ def _get_timeout(self, timeout):
+ try:
+ tout =
utils.secs_to_timestr(utils.timestr_to_secs(timeout.string))
+ except ValueError:
+ tout = timeout.string
+ if timeout.message:
+ tout += ' | ' + timeout.message
+ return tout
+
+ def _get_id(self, parent_id, type, index):
+ return parent_id + '-%s-%d' % (type, index)
def testdoc_cli(args):