def step_impl(context, proc): url = context.custom_config["host"] + f'api/index/news/{context.id}/{proc}/' session = context.manager_user token = get_token(session, url, 'X-CSRFToken') headers = { "Referer": url, "X-CSRFToken": token, } response = session.post( url, headers=headers, ) assert response.ok
def step_impl(context, answer): url = context.custom_config["host"] + 'api/reconciliation/' token = get_token(context.manager_user, url) request_form = { 'csrfmiddlewaretoken': token, 'zp_cash': '', 'podushka': '', 'account_plus_minus': '', 'cash': '', 'social': '', } session = context.manager_user response = session.post(url, data=request_form, headers={"Referer": url}) assert answer in response.text
def step_impl(context, number): session = context.super_user url = context.custom_config["host"] + 'api/accounting_system/entry/' token = get_token(session, url) request_dict = { 'transaction_out.user_bill': '31482', 'transaction_out.company_bill': '', 'entry.date_to_execute': datetime.datetime.now(), 'entry.description': '', 'transaction_common.amount_usd': number, 'transaction_common.description': '', 'csrfmiddlewaretoken': token, } response = session.post(url, data=request_dict, headers={"Referer": url})
def step_impl(context, podushka, zp_cash, account_plus_minus, cash, social): url = context.custom_config["host"] + 'api/reconciliation/' token = get_token(context.manager_user, url) request_form = { 'csrfmiddlewaretoken': token, 'zp_cash': zp_cash, 'podushka': podushka, 'account_plus_minus': account_plus_minus, 'cash': cash, 'social': social, } session = context.manager_user context.response = session.post(url, data=request_form, headers={"Referer": url})
def step_impl(context): url = context.custom_config["host"] + 'api/reconciliation/questions/' session = context.manager_user token = get_token(session, url) context.request_form['csrfmiddlewaretoken'] = token json_data = json.dumps(context.request_form) response = session.post(url, data=json_data, headers={ "Referer": url, "X-CSRFToken": token, 'Content-Type': 'application/json;charset=UTF-8' }) assert response.ok
def step_impl(context): session = context.super_user url = context.custom_config[ "host"] + 'api/accounting_system/entry/multiple_transactions/' token = get_token(session=session, url=url) request_dict = context.request response = session.post(url, json=request_dict, headers={ "Referer": url, "X-CSRFTOKEN": token }) context.response_entry = response.text
def step_impl(context, person, method, part): url = context.custom_config["host"] + 'api' + part session = eval(persons[person]) if method == 'get': context.response = session.get(url) elif method == 'post': context.response = session.post(url) if part == '/reconciliation/status/' and method == 'post' and person != 'alien': token = get_token(session, url) data = { 'csrfmiddlewaretoken': token, 'status': 'false', } context.response = session.post(url, data=data, headers={"Referer": url})
def step_impl(context): url = context.custom_config["host"] + 'api/reconciliation/feedback/' session = context.manager_user token = get_token(session, url) files = {'file': ''} headers = { 'Accept': 'application/octet-stream,application/xhtml+xml,application/xml;q=0.9,image/avif,' 'image/png,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9', "Referer": url, 'Content-Type': 'multipart/form-data; boundary=--', "X-CSRFToken": token, } response = session.post(url, data=context.request_form, files=files, headers=headers) assert response.ok
def step_impl(context, direction): url = context.custom_config["host"] + 'api/index/reset/' + context.key session = context.session token = get_token(session, url) if direction == 'old': datum={ 'username': context.custom_config['manager_user']['username'], 'csrfmiddlewaretoken': context.token, 'password1': context.custom_config['manager_user']['password'], 'password2': context.custom_config['manager_user']['password'] } elif direction == 'new': datum = { 'username': '******', 'csrfmiddlewaretoken': context.token, 'password1': 'zxcqwe123', 'password2': 'zxcqwe123' } response = session.post(url, data=datum, headers={"Referer": url}) assert response.ok
def step_impl(context, amount): session = context.super_user url = context.custom_config[ "host"] + 'api/accounting_system/entry/custom/net_buyout/' token = get_token(session=session, url=url) request_dict = { 'transaction_out.user_bill': context.bills_list['userbill_2'][0], 'transaction_out.company_bill': '', 'transaction_in.user_bill': context.bills_list['userbill_1'][0], 'transaction_in.company_bill': '', 'entry.date_to_execute': datetime.now(), 'entry.description': 'NET buyout', 'transaction_common.amount_usd': amount, 'transaction_common.description': 'NET buyout', 'csrfmiddlewaretoken': token, } response = session.post(url, data=request_dict, headers={ "Referer": url, }) context.response_entry = response.json()['entry']
def step_impl(context): context.url = context.custom_config["host"][:-1] + context.part_url context.token = get_token(context.super_user, context.url)