Add support for Sphinx 2.0
Sphinx 2.0 switched the default HTML builder from HTML4 to HTML5 [1]. Since some of our tests are validating raw HTML output, this has caused them to break. We can't drop support for Sphinx < 2.0 yet since Sphinx 2.0 doesn't support Python 2.7, so simply if-else this mofo until such a time as we _can_ drop support. [1] https://github.com/sphinx-doc/sphinx/issues/4587 Change-Id: I4631169908e34fa924f5a0a783a94ad9c1215d9f Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
parent
72de61e3d6
commit
525eee5a72
@ -91,6 +91,32 @@ class TestBasicExample(base.TestCase):
|
|||||||
def test_parameters(self):
|
def test_parameters(self):
|
||||||
"""Do we get some parameters table"""
|
"""Do we get some parameters table"""
|
||||||
|
|
||||||
|
# TODO(stephenfin): Drop support for this once we drop support for both
|
||||||
|
# Python 2.7 and Sphinx < 2.0, likely in "U"
|
||||||
|
if sphinx.version_info >= (2, 0, 0):
|
||||||
|
table = """<table class="docutils align-center">
|
||||||
|
<colgroup>
|
||||||
|
<col style="width: 20%"/>
|
||||||
|
<col style="width: 10%"/>
|
||||||
|
<col style="width: 10%"/>
|
||||||
|
<col style="width: 60%"/>
|
||||||
|
</colgroup>
|
||||||
|
<thead>
|
||||||
|
<tr class="row-odd"><th class="head"><p>Name</p></th>
|
||||||
|
<th class="head"><p>In</p></th>
|
||||||
|
<th class="head"><p>Type</p></th>
|
||||||
|
<th class="head"><p>Description</p></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr class="row-even"><td><p>name</p></td>
|
||||||
|
<td><p>body</p></td>
|
||||||
|
<td><p>string</p></td>
|
||||||
|
<td><p>The name of things</p></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>"""
|
||||||
|
else:
|
||||||
table = """<table border="1" class="docutils">
|
table = """<table border="1" class="docutils">
|
||||||
<colgroup>
|
<colgroup>
|
||||||
<col width="20%"/>
|
<col width="20%"/>
|
||||||
@ -118,6 +144,64 @@ class TestBasicExample(base.TestCase):
|
|||||||
|
|
||||||
def test_rest_response(self):
|
def test_rest_response(self):
|
||||||
|
|
||||||
|
# TODO(stephenfin): Drop support for this once we drop support for both
|
||||||
|
# Python 2.7 and Sphinx < 2.0, likely in "U"
|
||||||
|
if sphinx.version_info >= (2, 0, 0):
|
||||||
|
success_table = """<table class="docutils align-center">
|
||||||
|
<colgroup>
|
||||||
|
<col style="width: 30%"/>
|
||||||
|
<col style="width: 70%"/>
|
||||||
|
</colgroup>
|
||||||
|
<thead>
|
||||||
|
<tr class="row-odd"><th class="head"><p>Code</p></th>
|
||||||
|
<th class="head"><p>Reason</p></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr class="row-even"><td><code>200 - OK</code></td>
|
||||||
|
<td><p>Request was successful.</p></td>
|
||||||
|
</tr>
|
||||||
|
<tr class="row-odd"><td><code>100 - Continue</code></td>
|
||||||
|
<td><p>An unusual code for an API</p></td>
|
||||||
|
</tr>
|
||||||
|
<tr class="row-even"><td><code>201 - Created</code></td>
|
||||||
|
<td><p>Resource was created and is ready to use.</p></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>"""
|
||||||
|
|
||||||
|
error_table = """<table class="docutils align-center">
|
||||||
|
<colgroup>
|
||||||
|
<col style="width: 30%"/>
|
||||||
|
<col style="width: 70%"/>
|
||||||
|
</colgroup>
|
||||||
|
<thead>
|
||||||
|
<tr class="row-odd"><th class="head"><p>Code</p></th>
|
||||||
|
<th class="head"><p>Reason</p></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr class="row-even"><td><code>405 - Method Not Allowed</code></td>
|
||||||
|
<td><p>Method is not valid for this endpoint.</p></td>
|
||||||
|
</tr>
|
||||||
|
<tr class="row-odd"><td><code>403 - Forbidden</code></td>
|
||||||
|
<td><p>Policy does not allow current user to do this operation.</p></td>
|
||||||
|
</tr>
|
||||||
|
<tr class="row-even"><td><code>401 - Unauthorized</code></td>
|
||||||
|
<td><p>User must authenticate before making a request</p></td>
|
||||||
|
</tr>
|
||||||
|
<tr class="row-odd"><td><code>400 - Bad Request</code></td>
|
||||||
|
<td><p>Some content in the request was invalid</p></td>
|
||||||
|
</tr>
|
||||||
|
<tr class="row-even"><td><code>500 - Internal Server Error</code></td>
|
||||||
|
<td><p>Something went wrong inside the service.</p></td>
|
||||||
|
</tr>
|
||||||
|
<tr class="row-odd"><td><code>409 - Conflict</code></td>
|
||||||
|
<td><p>There is already a zone with this name.</p></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>"""
|
||||||
|
else:
|
||||||
success_table = """table border="1" class="docutils">
|
success_table = """table border="1" class="docutils">
|
||||||
<colgroup>
|
<colgroup>
|
||||||
<col width="30%"/>
|
<col width="30%"/>
|
||||||
@ -174,5 +258,6 @@ class TestBasicExample(base.TestCase):
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.assertIn(success_table, self.content)
|
self.assertIn(success_table, self.content)
|
||||||
self.assertIn(error_table, self.content)
|
self.assertIn(error_table, self.content)
|
||||||
|
@ -18,6 +18,7 @@ Tests for `os_api_ref` module.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
|
import sphinx
|
||||||
from sphinx_testing import with_app
|
from sphinx_testing import with_app
|
||||||
|
|
||||||
from os_api_ref.tests import base
|
from os_api_ref.tests import base
|
||||||
@ -55,6 +56,47 @@ class TestMicroversions(base.TestCase):
|
|||||||
|
|
||||||
def test_parameters_table(self):
|
def test_parameters_table(self):
|
||||||
"""Test that min / max mv css class attributes are set in params"""
|
"""Test that min / max mv css class attributes are set in params"""
|
||||||
|
if sphinx.version_info >= (2, 0, 0):
|
||||||
|
table = """<div class="api-detail collapse section" id="list-servers-detail">
|
||||||
|
<table class="docutils align-center">
|
||||||
|
<colgroup>
|
||||||
|
<col style="width: 20%"/>
|
||||||
|
<col style="width: 10%"/>
|
||||||
|
<col style="width: 10%"/>
|
||||||
|
<col style="width: 60%"/>
|
||||||
|
</colgroup>
|
||||||
|
<thead>
|
||||||
|
<tr class="row-odd"><th class="head"><p>Name</p></th>
|
||||||
|
<th class="head"><p>In</p></th>
|
||||||
|
<th class="head"><p>Type</p></th>
|
||||||
|
<th class="head"><p>Description</p></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr class="row-even"><td><p>name</p></td>
|
||||||
|
<td><p>body</p></td>
|
||||||
|
<td><p>string</p></td>
|
||||||
|
<td><p>The name of things</p></td>
|
||||||
|
</tr>
|
||||||
|
<tr class="rp_min_ver_2_11 row-odd"><td><p>name2</p></td>
|
||||||
|
<td><p>body</p></td>
|
||||||
|
<td><p>string</p></td>
|
||||||
|
<td><p>The name of things</p>
|
||||||
|
<p><strong>New in version 2.11</strong></p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr class="rp_max_ver_2_20 row-even"><td><p>name3</p></td>
|
||||||
|
<td><p>body</p></td>
|
||||||
|
<td><p>string</p></td>
|
||||||
|
<td><p>The name of things</p>
|
||||||
|
<p><strong>Available until version 2.20</strong></p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
""" # noqa
|
||||||
|
else:
|
||||||
table = """<div class="api-detail collapse section" id="list-servers-detail">
|
table = """<div class="api-detail collapse section" id="list-servers-detail">
|
||||||
<table border="1" class="docutils">
|
<table border="1" class="docutils">
|
||||||
<colgroup>
|
<colgroup>
|
||||||
@ -94,6 +136,7 @@ class TestMicroversions(base.TestCase):
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
""" # noqa
|
""" # noqa
|
||||||
|
|
||||||
self.assertIn(table, self.content)
|
self.assertIn(table, self.content)
|
||||||
|
|
||||||
def test_mv_selector(self):
|
def test_mv_selector(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user