From f88a79aa8ea3cf32ce5dc88db860a9f91f1a6e32 Mon Sep 17 00:00:00 2001 From: Kien Ha <kienha9922@gmail.com> Date: Wed, 10 Aug 2016 22:41:11 -0400 Subject: [PATCH] Update Summary Display plugin to use convert xml - Rename test files to be more descriptive - Add plugin="summary_report" attribute for consistency - Fix docs for 'files' option to be required Change-Id: If0f04dfcc5ae9cdc8c15ec9728b72e9156ea9d7f Signed-off-by: Kien Ha <kienha9922@gmail.com> --- jenkins_jobs/modules/publishers.py | 29 ++++++++++++------- ...ml-summary002.xml => xml-summary-full.xml} | 2 +- ...-summary002.yaml => xml-summary-full.yaml} | 2 +- ...summary001.xml => xml-summary-minimal.xml} | 2 +- ...mmary001.yaml => xml-summary-minimal.yaml} | 0 5 files changed, 22 insertions(+), 13 deletions(-) rename tests/publishers/fixtures/{xml-summary002.xml => xml-summary-full.xml} (75%) rename tests/publishers/fixtures/{xml-summary002.yaml => xml-summary-full.yaml} (64%) rename tests/publishers/fixtures/{xml-summary001.xml => xml-summary-minimal.xml} (75%) rename tests/publishers/fixtures/{xml-summary001.yaml => xml-summary-minimal.yaml} (100%) diff --git a/jenkins_jobs/modules/publishers.py b/jenkins_jobs/modules/publishers.py index e8893c1ce..f71b1341d 100644 --- a/jenkins_jobs/modules/publishers.py +++ b/jenkins_jobs/modules/publishers.py @@ -3312,22 +3312,31 @@ def xml_summary(parser, xml_parent, data): Requires the Jenkins :jenkins-wiki:`Summary Display Plugin <Summary+Display+Plugin>`. - :arg str files: Files to parse (default '') + :arg str files: Files to parse (required) :arg bool shown-on-project-page: Display summary on project page - (default 'false') + (default false) - Example: + Minimal Example: - .. literalinclude:: /../../tests/publishers/fixtures/xml-summary001.yaml + .. literalinclude:: + /../../tests/publishers/fixtures/xml-summary-minimal.yaml + :language: yaml + + Full Example: + + .. literalinclude:: /../../tests/publishers/fixtures/xml-summary-full.yaml :language: yaml """ - summary = XML.SubElement(xml_parent, - 'hudson.plugins.summary__report.' - 'ACIPluginPublisher') - XML.SubElement(summary, 'name').text = data['files'] - XML.SubElement(summary, 'shownOnProjectPage').text = str( - data.get('shown-on-project-page', 'false')) + summary = XML.SubElement( + xml_parent, 'hudson.plugins.summary__report.ACIPluginPublisher') + summary.set('plugin', 'summary_report') + + mapping = [ + ('files', 'name', None), + ('shown-on-project-page', 'shownOnProjectPage', False), + ] + helpers.convert_mapping_to_xml(summary, data, mapping, fail_required=True) def robot(parser, xml_parent, data): diff --git a/tests/publishers/fixtures/xml-summary002.xml b/tests/publishers/fixtures/xml-summary-full.xml similarity index 75% rename from tests/publishers/fixtures/xml-summary002.xml rename to tests/publishers/fixtures/xml-summary-full.xml index 11443ab4b..3ec8101a3 100644 --- a/tests/publishers/fixtures/xml-summary002.xml +++ b/tests/publishers/fixtures/xml-summary-full.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <project> <publishers> - <hudson.plugins.summary__report.ACIPluginPublisher> + <hudson.plugins.summary__report.ACIPluginPublisher plugin="summary_report"> <name>*_summary_report.xml</name> <shownOnProjectPage>true</shownOnProjectPage> </hudson.plugins.summary__report.ACIPluginPublisher> diff --git a/tests/publishers/fixtures/xml-summary002.yaml b/tests/publishers/fixtures/xml-summary-full.yaml similarity index 64% rename from tests/publishers/fixtures/xml-summary002.yaml rename to tests/publishers/fixtures/xml-summary-full.yaml index 2a69d64ef..499f7aa69 100644 --- a/tests/publishers/fixtures/xml-summary002.yaml +++ b/tests/publishers/fixtures/xml-summary-full.yaml @@ -1,4 +1,4 @@ publishers: - xml-summary: files: '*_summary_report.xml' - shown-on-project-page: 'true' + shown-on-project-page: true diff --git a/tests/publishers/fixtures/xml-summary001.xml b/tests/publishers/fixtures/xml-summary-minimal.xml similarity index 75% rename from tests/publishers/fixtures/xml-summary001.xml rename to tests/publishers/fixtures/xml-summary-minimal.xml index 528312249..a4a3e0e92 100644 --- a/tests/publishers/fixtures/xml-summary001.xml +++ b/tests/publishers/fixtures/xml-summary-minimal.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <project> <publishers> - <hudson.plugins.summary__report.ACIPluginPublisher> + <hudson.plugins.summary__report.ACIPluginPublisher plugin="summary_report"> <name>*_summary_report.xml</name> <shownOnProjectPage>false</shownOnProjectPage> </hudson.plugins.summary__report.ACIPluginPublisher> diff --git a/tests/publishers/fixtures/xml-summary001.yaml b/tests/publishers/fixtures/xml-summary-minimal.yaml similarity index 100% rename from tests/publishers/fixtures/xml-summary001.yaml rename to tests/publishers/fixtures/xml-summary-minimal.yaml