blob: 0717aad3e71c1330c7c18c3ae70df40485aba936 [file] [log] [blame]
Wei-Yu Chen49950b92021-11-08 19:19:18 +08001"""
2Copyright 2020 The Magma Authors.
3
4This source code is licensed under the BSD-style license found in the
5LICENSE file in the root directory of this source tree.
6
7Unless required by applicable law or agreed to in writing, software
8distributed under the License is distributed on an "AS IS" BASIS,
9WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10See the License for the specific language governing permissions and
11limitations under the License.
12"""
13
14from unittest import mock
15
16from spyne.server.wsgi import WsgiMethodContext
17
18
19def get_spyne_context_with_ip(
20 req_ip: str = "192.168.60.145",
21) -> WsgiMethodContext:
22 with mock.patch('spyne.server.wsgi.WsgiApplication') as MockTransport:
23 MockTransport.req_env = {"REMOTE_ADDR": req_ip}
24 with mock.patch('spyne.server.wsgi.WsgiMethodContext') as MockContext:
25 MockContext.transport = MockTransport
26 return MockContext