# Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. """ test_os_api_ref ---------------------------------- Tests for `os_api_ref` module. """ from bs4 import BeautifulSoup import sphinx from sphinx_testing import with_app from os_api_ref.tests import base # FIXME(stephenfin): This is horrible. We're monkeypatching this to work around # the fact that Sphinx 1.8+ started called 'abspath' from within the # 'sphinx.application.Application' class [1]. This means our careful use of # 'sphinx_testing.path.path' for 'Application.outdir' etc. gets stomped on. # We're correcting that but we're doing so globally because mock doesn't work # for some reason and this is bound to have some side effects # # [1] https://github.com/sphinx-doc/sphinx/commit/3a85b3502f try: sphinx.application.abspath = lambda x: x except ImportError: # Sphinx < 1.8 pass class TestBasicExample(base.TestCase): """Test basic rendering. This can be used to test that basic rendering works for these examples, so if someone breaks something we know. """ @with_app(buildername='html', srcdir=base.example_dir('basic'), copy_srcdir_to_tmpdir=True) def setUp(self, app, status, warning): super(TestBasicExample, self).setUp() self.app = app self.status = status self.warning = warning self.app.build() self.html = (app.outdir / 'index.html').read_text(encoding='utf-8') self.soup = BeautifulSoup(self.html, 'html.parser') self.content = str(self.soup) def test_expand_all(self): """Do we get an expand all button like we expect.""" content = str(self.soup.find(id='expand-all')) example_button = ('') self.assertEqual( example_button, content) def test_rest_method(self): """Do we get a REST method call block""" # TODO(sdague): it probably would make sense to do this as a # whole template instead of parts. content = str(self.soup.find_all(class_='operation-grp')) self.assertIn( '', str(content)) self.assertIn( 'GET', str(content)) self.assertIn( '
Name |
In |
Type |
Description |
---|---|---|---|
name |
body |
string |
The name of things |
Name | In | Type | Description |
---|---|---|---|
name | body | string | The name of things |
Code |
Reason |
---|---|
200 - OK |
Request was successful. |
100 - Continue |
An unusual code for an API |
201 - Created |
Resource was created and is ready to use. |
Code |
Reason |
---|---|
405 - Method Not Allowed |
Method is not valid for this endpoint. |
403 - Forbidden |
Policy does not allow current user to do this operation. |
401 - Unauthorized |
User must authenticate before making a request |
400 - Bad Request |
Some content in the request was invalid |
500 - Internal Server Error |
Something went wrong inside the service. |
409 - Conflict |
There is already a zone with this name. |
200 - OK
100 - Continue
201 - Created
Code | Reason |
---|---|
405 - Method Not Allowed |
Method is not valid for this endpoint. |
403 - Forbidden |
Policy does not allow current user to do this operation. |
401 - Unauthorized |
User must authenticate before making a request |
400 - Bad Request |
Some content in the request was invalid |
500 - Internal Server Error |
Something went wrong inside the service. |
409 - Conflict |
There is already a zone with this name. |