From cb5c61f66be54f5437ca78d62c51ed64aacc383e Mon Sep 17 00:00:00 2001 From: Chris Behrens Date: Thu, 27 Dec 2012 22:20:19 +0000 Subject: [PATCH] Allow new XML API sample file generation When GENERATE_SAMPLES is used, it's supposed to generate the docs for you. However, if there's no pre-existing XML doc sample, it fails due to bad handling of this case. Fixes bug 1094141 Change-Id: I186d6ce78886e37a3fdd3268154872c99072fdca --- nova/tests/integrated/test_api_samples.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/nova/tests/integrated/test_api_samples.py b/nova/tests/integrated/test_api_samples.py index a8099a6bb808..12eefa10f19c 100644 --- a/nova/tests/integrated/test_api_samples.py +++ b/nova/tests/integrated/test_api_samples.py @@ -81,6 +81,9 @@ class ApiSampleTestBase(integrated_helpers._IntegratedTestBase): indent=4) else: + if data is None: + # Likely from missing XML file. + return "" xml = etree.XML(data) data = etree.tostring(xml, encoding="UTF-8", xml_declaration=True, pretty_print=True) @@ -235,7 +238,10 @@ class ApiSampleTestBase(integrated_helpers._IntegratedTestBase): with file(self._get_sample(name)) as sample: sample_data = sample.read() except IOError: - sample_data = "{}" + if self.ctype == 'json': + sample_data = "{}" + else: + sample_data = None try: response_result = self._verify_something(subs, expected,