Python RESTfulServer Example

说明

python restfulserver示例是从最受好评的开源项目中提取的实现代码,你可以参考下面示例的使用方式。

编程语言: Python

命名空间/包名称: pixelatedmanager

示例#1
文件: manager_test.py项目: mmircea16/pixelated-dispatcher

    def test_that_serve_forever_runs_without_ssl_context(self, run_mock, wsgiRefServer_mock):
        # given
        server = RESTfulServer(None, RESTfulServerTest.mock_provider)

        # when
        server.serve_forever()

        # then
        wsgiRefServer_mock.assert_called_once_with(host='localhost', port=4443)

示例#2
文件: manager_test.py项目: vivekbsable/pixelated-dispatcher

    def test_that_ssl_server_adapter_gets_used_when_ssl_config_is_provided(self, run_mock, ssl_adapter_mock):
        server = RESTfulServer(RESTfulServerTest.ssl_config, RESTfulServerTest.mock_users, RESTfulServerTest.mock_authenticator, RESTfulServerTest.mock_provider)

        # when
        server.serve_forever()

        expected_ca_certs = None  # which means system ciphers
        expected_ciphers = DEFAULT_CIPHERS
        expected_ssl_version = latest_available_ssl_version()
        expected_host = '127.0.0.1'
        expected_port = 4443
        expected_certfile = certfile()
        expected_keyfile = keyfile()

        ssl_adapter_mock.assert_called_once_with(ssl_ca_certs=expected_ca_certs, ssl_ciphers=expected_ciphers, ssl_version=expected_ssl_version, host=expected_host, port=expected_port, ssl_cert_file=expected_certfile, ssl_key_file=expected_keyfile)

展开阅读全文