Test configuration updates in CSITs
[integration/csit.git] / tests / dcaegen2-collectors-hv-ves / testcases / libraries / HttpRequests.py
1 # ============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=========================================================
18 import requests
19 from robot.api import logger
20
21 valid_status_codes = [
22     requests.codes.ok,
23     requests.codes.accepted
24 ]
25
26
27 def session_without_env():
28     session = requests.Session()
29     session.trust_env = False
30     return session
31
32
33 def 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))
36         raise (Exception(server_name + " returned status code " + str(status_code)))