def send_post_request(self, url, request_name, filename): source_file = Path("data") / filename data = read_json(source_file) with self.session.post(url, name=request_name, data=data, verify=False, catch_response=True) as response: assert_status_code(response)
def send_get_request(self, url, request_name, filename=None): if filename: source_file = Path("data") / filename params = read_json(source_file) else: params = None with self.session.get(url, name=request_name, params=params, verify=False, catch_response=True) as response: assert_status_code(response)
def change_tan(session, source_filename, tan_filename): file_to_open = Path("data") / source_filename data = read_json(file_to_open) df = pandas.read_csv(f'data\\{tan_filename}') tan_value = str(df["tan"].iloc[len(df.index) - 1]) df = df.iloc[0:len(df.index) - 1] tan_filename = Path("data") / tan_filename df.to_csv(f'{tan_filename}', index=False) data["tanValue"] = tan_value write_json(file_to_open, data) session.headers.update({"X-TAN": tan_value})
import os from pathlib import Path from helpers.assertion_helper import assert_status_code from helpers.json_helper import read_json filepath = os.path.abspath("target.json") target = read_json(filepath) def get_request_by_id(session, request_id): with session.get(f"/{target['requests']['host']}/requests/{request_id}", catch_response=True, verify=False, name="/REQUESTS/[ID]") as response: assert_status_code(response) rs_json = response.json() return rs_json def create_request(session, filename, user_id, endpoint): source_file = Path("data") / filename with open(source_file, "rb") as data: with session.post( f"/{target['requests']['host']}/admin/{endpoint}/user/{user_id}", data=data, name=f"/{endpoint}", catch_response=True, verify=False) as response: assert_status_code(response) rs_json = response.json() return rs_json