blob: 48205f2aea2409b7453afc2e87973452191e8013 [file] [log] [blame]
Filip Krzywka66e2ad62019-03-20 14:03:02 +01001# ============LICENSE_START=======================================================
2# csit-dcaegen2-collectors-hv-ves
3# ================================================================================
4# Copyright (C) 2018 NOKIA
5# ================================================================================
6# Licensed under the Apache License, Version 2.0 (the "License");
7# you may not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS,
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17# ============LICENSE_END=========================================================
Gary Wu9abb61c2018-09-27 10:38:50 -070018import requests
19from robot.api import logger
20
21valid_status_codes = [
22 requests.codes.ok,
23 requests.codes.accepted
24]
25
26
27def session_without_env():
28 session = requests.Session()
29 session.trust_env = False
30 return session
31
32
33def checkStatusCode(status_code, server_name):
34 if status_code not in valid_status_codes:
35 logger.error("Response status code from " + server_name + ": " + str(status_code))
Filip Krzywkaca7b7822019-04-02 13:03:56 +020036 raise (Exception(server_name + " returned status code " + str(status_code)))