| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
""" |
| 14 |
test_os_api_ref |
| 15 |
---------------------------------- |
| 16 |
|
| 17 |
Tests for `os_api_ref` module. |
| 18 |
""" |
| 19 |
|
| 20 |
from bs4 import BeautifulSoup |
| 21 |
|
| 22 |
from os_api_ref.tests import base |
| 23 |
|
| 24 |
|
| 25 |
class TestMicroversions(base.TestCase): |
| 26 |
"""Test basic rendering. |
| 27 |
|
| 28 |
This can be used to test that basic rendering works for these |
| 29 |
examples, so if someone breaks something we know. |
| 30 |
""" |
| 31 |
|
| 32 |
@base.with_app(buildername='html', |
| 33 |
srcdir=base.example_dir('microversions')) |
| 34 |
def setUp(self, app, status, warning): |
| 35 |
super().setUp() |
| 36 |
self.app = app |
| 37 |
self.app.build() |
| 38 |
self.status = status.getvalue() |
| 39 |
self.warning = warning.getvalue() |
| 40 |
self.html = (app.outdir / 'index.html').read_text(encoding='utf-8') |
| 41 |
self.soup = BeautifulSoup(self.html, 'html.parser') |
| 42 |
self.content = str(self.soup) |
| 43 |
|
| 44 |
def test_rest_method(self): |
| 45 |
"""Test that min / max mv css class attributes are set""" |
| 46 |
content = self.soup.find_all(class_='rp_min_ver_2_17') |
| 47 |
self.assertRegex( |
| 48 |
str(content[0]), |
| 49 |
'^<div class="operation-grp rp_min_ver_2_17 rp_max_ver_2_19 ' |
| 50 |
'?container"') |
| 51 |
content = self.soup.find_all(class_='rp_max_ver_2_19') |
| 52 |
self.assertRegex( |
| 53 |
str(content[0]), |
| 54 |
'^<div class="operation-grp rp_min_ver_2_17 rp_max_ver_2_19 ' |
| 55 |
'?container"') |
| 56 |
|
| 57 |
def test_parameters_table(self): |
| 58 |
"""Test that min / max mv css class attributes are set in params""" |
| 59 |
table = """ |
| 60 |
<table class="docutils align-default"> |
| 61 |
<thead> |
| 62 |
<tr class="row-odd"><th class="head"><p>Name</p></th> |
| 63 |
<th class="head"><p>In</p></th> |
| 64 |
<th class="head"><p>Type</p></th> |
| 65 |
<th class="head"><p>Description</p></th> |
| 66 |
</tr> |
| 67 |
</thead> |
| 68 |
<tbody> |
| 69 |
<tr class="row-even"><td><p>name</p></td> |
| 70 |
<td><p>body</p></td> |
| 71 |
<td><p>string</p></td> |
| 72 |
<td><p>The name of things</p></td> |
| 73 |
</tr> |
| 74 |
<tr class="rp_min_ver_2_11 row-odd"><td><p>name2</p></td> |
| 75 |
<td><p>body</p></td> |
| 76 |
<td><p>string</p></td> |
| 77 |
<td><p>The name of things</p> |
| 78 |
<p><strong>New in version 2.11</strong></p> |
| 79 |
</td> |
| 80 |
</tr> |
| 81 |
<tr class="rp_max_ver_2_20 row-even"><td><p>name3</p></td> |
| 82 |
<td><p>body</p></td> |
| 83 |
<td><p>string</p></td> |
| 84 |
<td><p>The name of things</p> |
| 85 |
<p><strong>Available until version 2.20</strong></p> |
| 86 |
</td> |
| 87 |
</tr> |
| 88 |
</tbody> |
| 89 |
</table> |
| 90 |
""" |
| 91 |
self.assertIn(table, self.content) |
| 92 |
|
| 93 |
def test_mv_selector(self): |
| 94 |
|
| 95 |
button_selectors = '<option selected="selected" value="">All</option><option value="2.1">2.1</option><option value="2.2">2.2</option><option value="2.3">2.3</option><option value="2.4">2.4</option><option value="2.5">2.5</option><option value="2.6">2.6</option><option value="2.7">2.7</option><option value="2.8">2.8</option><option value="2.9">2.9</option><option value="2.10">2.10</option><option value="2.11">2.11</option><option value="2.12">2.12</option><option value="2.13">2.13</option><option value="2.14">2.14</option><option value="2.15">2.15</option><option value="2.16">2.16</option><option value="2.17">2.17</option><option value="2.18">2.18</option><option value="2.19">2.19</option><option value="2.20">2.20</option><option value="2.21">2.21</option><option value="2.22">2.22</option><option value="2.23">2.23</option><option value="2.24">2.24</option><option value="2.25">2.25</option><option value="2.26">2.26</option><option value="2.27">2.27</option><option value="2.28">2.28</option><option value="2.29">2.29</option><option value="2.30">2.30</option>' |
| 96 |
self.assertIn(button_selectors, self.content) |
| 97 |
|
| 98 |
def test_js_declares(self): |
| 99 |
self.assertIn("os_max_mv = 30;", self.content) |
| 100 |
self.assertIn("os_min_mv = 1;", self.content) |