本文整理汇总了Python中falcon.testing.TestClient方法的典型用法代码示例。如果您正苦于以下问题:Python testing.TestClient方法的具体用法?Python testing.TestClient怎么用?Python testing.TestClient使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类falcon.testing
的用法示例。
在下文中一共展示了testing.TestClient方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from falcon import testing [as 别名]
# 或者: from falcon.testing import TestClient [as 别名]
def setUp(self):
super(BaseControllerTest, self).setUp()
# Override the default configuration file lookup with references to
# the sample configuration files to avoid oslo.conf errors when
# creating the server below.
current_dir = os.path.dirname(os.path.realpath(__file__))
sample_conf_dir = os.path.join(
current_dir, os.pardir, os.pardir, os.pardir, os.pardir, 'etc',
'armada')
sample_conf_files = ['api-paste.ini', 'armada.conf.sample']
with mock.patch.object(armada.conf,
'_get_config_files') as mock_get_config_files:
mock_get_config_files.return_value = [
os.path.join(sample_conf_dir, x) for x in sample_conf_files
]
self.app = falcon_testing.TestClient(
server.create(enable_middleware=False))
self.policy = self.useFixture(fixtures.RealPolicyFixture())
示例2: setUp
# 需要导入模块: from falcon import testing [as 别名]
# 或者: from falcon.testing import TestClient [as 别名]
def setUp(self):
super(BaseControllerTest, self).setUp()
# Override the default configuration file lookup with references to
# the sample configuration files to avoid oslo.conf errors when
# creating the server below.
current_dir = os.path.dirname(os.path.realpath(__file__))
sample_conf_dir = os.path.join(current_dir, os.pardir, os.pardir,
os.pardir, os.pardir, 'etc', 'armada')
sample_conf_files = ['api-paste.ini', 'armada.conf.sample']
with mock.patch.object(
armada.conf, '_get_config_files') as mock_get_config_files:
mock_get_config_files.return_value = [
os.path.join(sample_conf_dir, x) for x in sample_conf_files
]
self.app = falcon_testing.TestClient(
server.create(enable_middleware=False))
self.policy = self.useFixture(fixtures.RealPolicyFixture())
示例3: test_both_schemas_validation_failure
# 需要导入模块: from falcon import testing [as 别名]
# 或者: from falcon.testing import TestClient [as 别名]
def test_both_schemas_validation_failure():
with pytest.raises(HTTPError) as excinfo:
Resource().both_validated(GoodData(), BadData())
assert excinfo.value.title == falcon.HTTP_INTERNAL_SERVER_ERROR
assert excinfo.value.description == "Response data failed validation"
with pytest.raises(HTTPError) as excinfo:
Resource().both_validated(BadData(), GoodData())
msg = "Request data failed validation: data must contain ['message'] properties"
assert excinfo.value.title == falcon.HTTP_BAD_REQUEST
assert excinfo.value.description == msg
client = testing.TestClient(falcon.API())
client.app.add_route("/test", Resource())
result = client.simulate_put("/test", json=BadData.media)
assert result.status_code == 400
示例4: falcontest
# 需要导入模块: from falcon import testing [as 别名]
# 或者: from falcon.testing import TestClient [as 别名]
def falcontest(self, drydock_state, deckhand_ingester,
deckhand_orchestrator):
"""Create a test harness for the Falcon API framework."""
policy.policy_engine = policy.DrydockPolicy()
policy.policy_engine.register_policy()
return testing.TestClient(
start_api(
state_manager=drydock_state,
ingester=deckhand_ingester,
orchestrator=deckhand_orchestrator))
示例5: falcontest
# 需要导入模块: from falcon import testing [as 别名]
# 或者: from falcon.testing import TestClient [as 别名]
def falcontest(self, drydock_state, deckhand_ingester,
deckhand_orchestrator, mock_get_build_data):
"""Create a test harness for the Falcon API framework."""
return testing.TestClient(
start_api(
state_manager=drydock_state,
ingester=deckhand_ingester,
orchestrator=deckhand_orchestrator))
示例6: falcontest
# 需要导入模块: from falcon import testing [as 别名]
# 或者: from falcon.testing import TestClient [as 别名]
def falcontest(self, drydock_state, yaml_ingester, yaml_orchestrator):
"""Create a test harness for the Falcon API framework."""
return testing.TestClient(
start_api(
state_manager=drydock_state,
ingester=yaml_ingester,
orchestrator=yaml_orchestrator))
示例7: falcontest
# 需要导入模块: from falcon import testing [as 别名]
# 或者: from falcon.testing import TestClient [as 别名]
def falcontest(self, drydock_state, yaml_ingester, yaml_orchestrator,
mock_get_build_data):
"""Create a test harness for the Falcon API framework."""
return testing.TestClient(
start_api(
state_manager=drydock_state,
ingester=yaml_ingester,
orchestrator=yaml_orchestrator))
示例8: falcontest
# 需要导入模块: from falcon import testing [as 别名]
# 或者: from falcon.testing import TestClient [as 别名]
def falcontest(self, drydock_state, deckhand_ingester,
deckhand_orchestrator, mock_get_build_data):
"""Create a test harness for the Falcon API framework."""
policy.policy_engine = policy.DrydockPolicy()
policy.policy_engine.register_policy()
return testing.TestClient(
start_api(
state_manager=drydock_state,
ingester=deckhand_ingester,
orchestrator=deckhand_orchestrator))
示例9: client
# 需要导入模块: from falcon import testing [as 别名]
# 或者: from falcon.testing import TestClient [as 别名]
def client():
from certidude.api import certidude_app
from falcon import testing
app = certidude_app()
return testing.TestClient(app)
示例10: client
# 需要导入模块: from falcon import testing [as 别名]
# 或者: from falcon.testing import TestClient [as 别名]
def client():
return testing.TestClient(app)
示例11: client
# 需要导入模块: from falcon import testing [as 别名]
# 或者: from falcon.testing import TestClient [as 别名]
def client(get_fake_model):
rest_api = create_rest_api(models={"test": get_fake_model})
return testing.TestClient(rest_api)
示例12: client
# 需要导入模块: from falcon import testing [as 别名]
# 或者: from falcon.testing import TestClient [as 别名]
def client(app):
return testing.TestClient(app)
示例13: client
# 需要导入模块: from falcon import testing [as 别名]
# 或者: from falcon.testing import TestClient [as 别名]
def client():
with mock.patch('management_api.main.AuthMiddleware') as middleware:
middleware.return_value = AuthMiddlewareMock()
return testing.TestClient(create_app())
示例14: client_with_auth
# 需要导入模块: from falcon import testing [as 别名]
# 或者: from falcon.testing import TestClient [as 别名]
def client_with_auth():
return testing.TestClient(create_app())
示例15: client
# 需要导入模块: from falcon import testing [as 别名]
# 或者: from falcon.testing import TestClient [as 别名]
def client(self, app):
return TestClient(app)