blob: 7f8dc7501b7f63baeea224ea37ccaad6f4456df3 [file] [log] [blame]
Wei-Yu Chenad55cb82022-02-15 20:07:01 +08001# SPDX-FileCopyrightText: 2020 The Magma Authors.
2# SPDX-FileCopyrightText: 2022 Open Networking Foundation <support@opennetworking.org>
3#
4# SPDX-License-Identifier: BSD-3-Clause
Wei-Yu Chen49950b92021-11-08 19:19:18 +08005
6from unittest import mock
7
8from spyne.server.wsgi import WsgiMethodContext
9
10
11def get_spyne_context_with_ip(
12 req_ip: str = "192.168.60.145",
13) -> WsgiMethodContext:
14 with mock.patch('spyne.server.wsgi.WsgiApplication') as MockTransport:
15 MockTransport.req_env = {"REMOTE_ADDR": req_ip}
16 with mock.patch('spyne.server.wsgi.WsgiMethodContext') as MockContext:
17 MockContext.transport = MockTransport
18 return MockContext