예제 #1
0
def step_impl(context):
    session = context.fin_user

    url = context.custom_config["host"] + 'api/accounting_system/bills/users/'
    worker = GetRequest(session, url)
    user_bills = worker.json_list

    url = context.custom_config["host"] + 'api/accounting_system/bills/company/'
    worker = GetRequest(session, url)
    company_bills = worker.json_list

    context.request = {
        "entry": {
            "date_to_execute": str(datetime.now()),
            "description": "autotest"
        },
        "mass_transaction_out": [{
            "user_bill": user_bills[0]['id'],
            "amount_usd": 5
        }, {
            "user_bill": user_bills[1]['id'],
            "amount_usd": 3
        }],
        "mass_transaction_in": [{
            "company_bill": company_bills[0]['id'],
            "amount_usd": 5
        }, {
            "company_bill": company_bills[1]['id'],
            "amount_usd": 8
        }],
        "mass_transaction_common": {
            "description": "autotest"
        }
    }
예제 #2
0
def step_impl(context):
    session = context.fin_user
    url = context.custom_config["host"] + 'api/accounting_system/bills/company/'
    worker = GetRequest(session, url)
    template_list = [
        'Company Daily Net', 'Company ServComp', 'Company Office Fees',
        'Company Net Income', 'Company Social Fund'
    ]

    assert worker.check_text(template_list)
예제 #3
0
def step_impl(context):
    session = context.fin_user
    url = context.custom_config[
        "host"] + 'api/accounting_system/bills/user/types/'
    worker = GetRequest(session, url)
    template_list = [
        'Current Net balance', 'Cash hub', 'SmartPoints', 'Investments',
        'Account', 'Withdrawal'
    ]

    assert worker.check_text(template_list)
예제 #4
0
def step_impl(context, key):
    url = context.custom_config["host"] + 'api/accounting_system/entries/?user[]=all&account[]=all&'

    if key == 'first':
        worker = GetRequest(context.fin_user, url + context.date_one)
        subject_dict = worker.json_list
        context.result_first = set(str(part) for part in subject_dict)
    elif key == 'second':
        worker = GetRequest(context.fin_user, url + context.date_two)
        subject_dict = worker.json_list
        context.result_second = set(str(part) for part in subject_dict)
예제 #5
0
def step_impl(context):
    session = context.fin_user
    url = context.custom_config["host"] + 'api/accounting_system/bills/users/'
    worker = GetRequest(session, url)

    lis = []
    for key, value in context.bills.items():
        for part in value:
            index = value.index(part) + 1
            id = part['id']
            lis.append([key, index, id])

    assert worker.check_json(lis)
예제 #6
0
def step_impl(context):
    url = context.custom_config["host"] + 'api/accounting_system/report_fields/'

    worker = GetRequest(context.fin_user, url)
    subject_dict = worker.json_list

    context.report_fields_list = [key for key in subject_dict.keys()]
예제 #7
0
def step_impl(context):
    session = context.super_user
    url = context.custom_config["host"] + 'admin/reconciliation/userdata/'
    worker = GetRequest(session, url)
    html = worker.text
    hr_id = context.custom_config['manager_id']['hr_id']
    context.part_url = re.findall(
        r'<a href="([a-z0-9/]*)">{0}</a>'.format(hr_id), html)[0]
예제 #8
0
def step_impl(context, cont_type):
    url = context.custom_config["host"] + 'api/index/contests/'
    session = context.manager_user
    response = GetRequest(session, url)
    contests = response.json_list
    result = [contest for contest in contests if contest['name_key'] == cont_type and contest['button_thumb'].endswith('.png') and contest['image'].endswith('.jpg')]

    assert result
예제 #9
0
def step_impl(context, type_image):
    url = context.custom_config["host"] + f'api/media/contest/{type_image}/image'
    session = context.super_user
    response = GetRequest(session, url)

    image = response.json_list['image']
    head, body= image.split(',', 1)

    context.endpoint_image = io.BytesIO(b64decode(body))
예제 #10
0
def step_impl(context, key, answer):
    if key == 'reports update':
        url = context.custom_config["host"] + 'api/reconciliation/reports_update/'
    elif key == 'services and compensations update':
        url = context.custom_config["host"] + 'api/reconciliation/services_compensations/'
    elif key == 'risk update':
        url = context.custom_config["host"] + 'api/reconciliation/status_accounts/'
    response = GetRequest(context.super_user, url)
    assert answer in response.text
예제 #11
0
def step_impl(context, subject):
    if subject == 'company':
        url = context.custom_config["host"] + 'api/accounting_system/bills/company/'
    elif subject == 'user':
        url = context.custom_config["host"] + 'api/accounting_system/bills/user/types/'

    worker = GetRequest(context.fin_user, url)
    subject_dict = worker.json_list
    context.bill_list = [part['id'] for part in subject_dict]
    context.id_name_bill = {part['id']: part['name'] for part in subject_dict}
예제 #12
0
def step_impl(context, status):
    session = context.super_user
    url = context.custom_config[
        "host"] + f'admin/accounting_system/entry/{context.response_entry}/change/'
    worker = GetRequest(session, url)
    html_text = worker.text
    if status == 'applied':
        assert 'selected>Applied' in html_text
    elif status == 'pending':
        assert 'selected>Pending' in html_text
예제 #13
0
def step_impl(context):
    url = context.custom_config["host"] + 'api/index/news/'
    session = context.super_user
    response = GetRequest(session, url)
    items = response.json_list['items']
    test_news=''

    for item in items:
        if item['id'] == context.id:
            test_news = item

    assert test_news['likes'] == 0 and test_news['views'] == 1 and test_news['title'] == context.title
예제 #14
0
def step_impl(context):
    session = context.fin_user
    url = context.custom_config["host"] + 'api/accounting_system/bills/users/'
    worker = GetRequest(session, url)
    context.user_bill = worker.json_list[0]['id']

    url = context.custom_config["host"] + 'api/accounting_system/bills/company/'
    worker = GetRequest(session, url)
    context.company_bills = worker.json_list[0]['id']

    context.request = {
        'transaction_out.user_bill': context.user_bill,
        'transaction_out.company_bill': '',
        'transaction_in.user_bill': '',
        'transaction_in.company_bill': context.company_bills,
        'entry.date_to_execute': datetime.now() - timedelta(minutes=40),
        'entry.description': 'autotest',
        'transaction_common.amount_usd': '100',
        'transaction_common.description': 'autotest',
        'csrfmiddlewaretoken': '',
    }
예제 #15
0
def step_impl(context):
    url = context.custom_config["host"] + "api/reconciliation/all_users_data/"
    session = context.super_user
    response = GetRequest(session, url)
    expected_result = response.json_list

    for part in expected_result:
        del part['qty_of_reconciliations']

    for i in context.actual_result:
        if i not in expected_result:
            assert False
    assert True
예제 #16
0
def step_impl(context):
    url = context.custom_config["host"] + f'api/index/books/?search_string=' \
          f'&sections_id=&include=themes&limit=500&offset=0&sort_by=popularity' \
          f'&sort_order=desc'
    session = context.manager_user
    response = GetRequest(session, url)
    lib = response.json_list
    authors = {}
    for book in lib:
        if authors.get(book['author']):
            authors[book['author']].append(book['title'])
        else:
            authors[book['author']] = [book['title']]
    context.authors = authors
예제 #17
0
def step_impl(context):
    worker = GetRequest(context.fin_user, context.url)
    actual_report = worker.json_list
    expected_report = context.expected_report
    if actual_report != expected_report:
        with open('C:\\Users\\wsu\\Desktop\\xxx.txt', 'a') as file:
            file.write(str(expected_report) + '\n')
        with open('C:\\Users\\wsu\\Desktop\\xxx.txt', 'a') as file:
            file.write(str(actual_report) + '\n')
        with open('C:\\Users\\wsu\\Desktop\\xxx.txt', 'a') as file:
            file.write(str(context.url) + '\n')
        with open('C:\\Users\\wsu\\Desktop\\xxx.txt', 'a') as file:
            file.write(str("----------------------------------------") + '\n')
    assert actual_report == expected_report
예제 #18
0
def step_impl(context):
    url = context.custom_config["host"] + 'api/reconciliation/all_users_data/'
    response = GetRequest(context.super_user, url)
    context.response_list = response.json_list
    for part in context.response_list:
        del part['date_reconciliation']
예제 #19
0
def step_impl(context, key):
    worker = GetRequest(context.fin_user, context.url)
    subject_dict = worker.json_list
    entries = context.entries
    result = check_comming_entries(entries, subject_dict, key)
    assert result
예제 #20
0
def step_impl(context, key):
    worker = GetRequest(context.fin_user, context.url)
    subject_dict = worker.json_list
    entries = context.choosen_entries if key == 'appropriate' else context.not_choosen_entries
    result = check_comming_entries(entries, subject_dict, key)
    assert result
예제 #21
0
def step_impl(context):
    url = context.url
    session = context.manager_user
    response = GetRequest(session, url)

    context.response = response.json_list
예제 #22
0
def step_impl(context, answer):
    url = context.custom_config["host"] + 'api/reconciliation/status/'
    response = GetRequest(context.manager_user, url)
    assert answer in response.text