コード例 #1
0
def step_impl(context, action, acc_name, acc_regex):
    hr_id = context.custom_config['sb_user']['hr_id']
    user_id = pgsql_select(
        request=f'SELECT * FROM public.index_customuser WHERE hr_id = {hr_id}',
        **context.custom_config['pg_db'])[0][0]
    acc_type_id = pgsql_select(
        request=
        f"SELECT * FROM public.accounting_system_accounttype WHERE account_regexp = '{acc_regex}'",
        **context.custom_config['pg_db'])[0][0]
    accounts = pgsql_select(
        request=
        f'SELECT * FROM public.reconciliation_reconciliationuserpropaccount '
        f'WHERE user_id = {user_id} and account_type_id = {acc_type_id} and month_adj_net is null',
        **context.custom_config['pg_db'])

    accounts_id = [acc[0] for acc in accounts]
    session = context.super_user
    for acc_id in accounts_id:
        url = context.custom_config[
            "host"] + f'admin/reconciliation/reconciliationuserpropaccount/{acc_id}/change/'
        text = session.get(url).text
        actual_acc_name = re.findall(
            '<input type="text" name="account" value="([0-9a-zA-Z]*)" class="vTextField',
            text)[0]
        if actual_acc_name in acc_name:
            assert True if action == "presence" else False
            break
    else:
        assert False if action == "presence" else True
コード例 #2
0
def step_impl(context, number, user):
    hr_id = context.custom_config['sb_user']['hr_id']
    user_id = pgsql_select(
        request=f'SELECT * FROM public.index_customuser WHERE hr_id = {hr_id}',
        **context.custom_config['pg_db'])[0][0]

    accounts = pgsql_select(
        request=
        f'SELECT * FROM public.reconciliation_reconciliationuserpropaccount '
        f'WHERE user_id = {user_id}',
        **context.custom_config['pg_db'])
    assert len(accounts) == int(number)
コード例 #3
0
def step_impl(context, qty, user):
    hr_id = context.custom_config['sb_user']['hr_id']
    user_id = pgsql_select(
        request=f'SELECT * FROM public.index_customuser WHERE hr_id = {hr_id}',
        **context.custom_config['pg_db'])[0][0]

    user_data = pgsql_select(
        request=
        f'SELECT bill_id FROM public.accounting_system_userbill WHERE user_id = {user_id}',
        **context.custom_config['pg_db'])
    user_data = {i[0] for i in user_data}

    assert len(user_data) == int(qty)
コード例 #4
0
def step_impl(context, period):
    fields_list = [
        'zp_cash',
        'podushka',
        'cash',
        'account_plus_minus',
        'social',
        'compensations_total',
        'office_fees',
        'services_total',
        'total_net_month',
        'total_sterling',
        'total_takion',
        'date_reconciliation',
        'qty_of_reconciliations',
        'entries_created',
    ]
    results = []
    for field in fields_list:
        request = f'SELECT {field} FROM public.reconciliation_userdata ' \
                  f'WHERE user_id = 90000'
        response = pgsql_select(request, **context.custom_config['pg_db'])
        results.append(bool(response[0][0]))
    if period == 'before' and True not in results:
        assert False
    elif period == 'after' and True in results:
        assert False
コード例 #5
0
ファイル: daily_review.py プロジェクト: A-Zorg/msw_api_copy
def step_impl(context):
    review_date = context.dr_dates['target_date']
    request = "SELECT DISTINCT(ticker) FROM public.review_propreportsdata " \
              f"WHERE execution_date = date '{review_date}'"
    raw_result = pgsql_select(request, **context.custom_config['pg_db'])
    clear_result = [ticker[0] for ticker in raw_result]

    context.ticker = random.choice(clear_result)
コード例 #6
0
ファイル: propreports.py プロジェクト: A-Zorg/msw_api_copy
def step_impl(context, number):
    request = "SELECT * FROM public.reconciliation_userpropaccount"
    result = pgsql_select(request=request, **context.custom_config['pg_db'])

    if len(result) < 27 * int(number):
        with open('C:\\Users\\wsu\\Desktop\\xxx.txt', 'a') as file:
            file.write(str(context.scenario.skip)+'\n')
        context.scenario.skip(f"accounts qty < {number}")
コード例 #7
0
def step_impl(context):
    request = 'SELECT company_bill_id, user_bill_id FROM public.accounting_system_transaction ' \
              f"WHERE entry_id = '{context.response_entry}'"
    result = pgsql_select(request, **context.custom_config['pg_db'])

    for key, value in context.bills_list.items():
        if value[0] not in str(result):
            assert False
    assert len(result) == 3
コード例 #8
0
def step_impl(context, period):
    request = f'SELECT * FROM public.accounting_system_transaction ' \
              f'WHERE user_bill_id in {context.user_bills}'
    response = pgsql_select(request, **context.custom_config['pg_db'])
    with open('C:\\Users\\wsu\\Desktop\\xxx.txt', 'a') as file:
        file.write(str(len(response))+'\n')
    if period == "before":
        context.transaction_qty_before = len(response)
    elif period == "after":
        context.transaction_qty_after = len(response)
コード例 #9
0
def wait_periodictask_to_be_done2(task_name, pgsql, wait_time=3600):
    """
    wait for some periodic task to be done
    take = name of the task
    return task_state
    after 10 min - exit from function if task would not be done
    """
    request = "SELECT * FROM public.django_celery_results_taskresult ORDER BY id DESC "
    start_id = pgsql_select(request=request, **pgsql)[0][0]

    start_time = time.time()
    while (time.time() - start_time) < wait_time:
        request = 'SELECT * FROM public.django_celery_results_taskresult ' \
                  f'WHERE id > {start_id} and task_name=\'{task_name}\'' \
                  'ORDER BY id ASC '
        result = pgsql_select(request=request, **pgsql)

        if result:
            return result[0][2]
    return "FAILURE"
コード例 #10
0
ファイル: daily_review.py プロジェクト: A-Zorg/msw_api_copy
def step_impl(context, req_number, number, review_date):
    sql_requests = pandas.read_csv('./base/DR_sql_requests.csv')
    request = sql_requests['request'][int(number) - 1].format(
        ticker=context.ticker, review_date=review_date)
    response = pgsql_select(request, **context.custom_config['pg_db'])

    if req_number == 'first':
        context.first_req = response
    elif req_number == 'second':
        context.second_req = response
    elif req_number == 'third':
        context.third_req = response
コード例 #11
0
def step_impl(context, acc_group):
    if acc_group == 'all':
        request = f'SELECT * FROM public.accounting_system_accounttype '
    elif acc_group == 'takion':
        request = f'SELECT * FROM public.accounting_system_accounttype as acct ' \
                  f'JOIN public.accounting_system_broker as accb ON acct.broker_id = accb.id ' \
                  f"WHERE accb.name = 'Takion'"
    elif acc_group == 'sterling':
        request = f'SELECT * FROM public.accounting_system_accounttype as acct ' \
                  f'JOIN public.accounting_system_broker as accb ON acct.broker_id = accb.id ' \
                  f"WHERE accb.name LIKE 'Broker%'"
    response = pgsql_select(request, **context.custom_config['pg_db'])
    acc_type_list = [acc[0] for acc in response]
    context.account_type_id = random.choice(acc_type_list)
コード例 #12
0
def step_impl(context, user):
    hr_id = context.custom_config['sb_user']['hr_id']
    user = pgsql_select(
        request=f'SELECT * FROM public.index_customuser WHERE hr_id = {hr_id}',
        **context.custom_config['pg_db'])
    context.db_user_data = [
        user[0][12],
        user[0][11],
        user[0][5],
        user[0][6],
        user[0][7],
        str(user[0][13]),
        str(user[0][14].strftime('%d.%m.%Y %H:%M:%S')),
    ]
コード例 #13
0
def step_impl(context, field, first, second):
    request = f'SELECT * FROM public.reconciliation_userdata ' \
              f'WHERE user_id = 90000'
    response = pgsql_select(request, **context.custom_config['pg_db'])
    userdata_id = response[0][0]

    session = context.super_user
    url = context.custom_config["host"] + f'admin/reconciliation/userdata/{userdata_id}/change/'
    text = session.get(url).text

    actual_number = re.findall(f'name="{field}" value="([0-9-]*)" class="vBigIntegerField', text)[0]
    sign = (float(first) + float(second)) / abs(float(first) + float(second))
    expected_number = round(float(first) + float(second) + 0.00000001*sign)

    assert expected_number == int(actual_number)
コード例 #14
0
def step_impl(context, value):
    request = f'SELECT * FROM public.reconciliation_service ' \
              f'WHERE user_id = 90000'
    response = pgsql_select(request, **context.custom_config['pg_db'])


    session = context.super_user
    url = context.custom_config["host"] + 'admin/reconciliation/service/?q=90000'
    text = session.get(url).text
    if value == 'none':
        asd = re.findall('Bonus</td><td class="field-amount">([0-9/.]*)</td><td class="field-service_type">Fee', text)
        assert len(response) == 0
        assert asd == []
    else:
        asd = re.findall('Bonus</td><td class="field-amount">([0-9/.]*)</td><td class="field-service_type">Fee', text)
        assert len(response) == 1
        assert float(asd[0]) == float(value)
コード例 #15
0
def step_impl(context, user):
    hr_id = context.custom_config['sb_user']['hr_id']
    try:
        user_id = pgsql_select(
            request=
            f'SELECT * FROM public.index_customuser WHERE hr_id = {hr_id}',
            **context.custom_config['pg_db'])[0][0]
    except:
        return True
    del_request = f'DELETE FROM public.reconciliation_userdata WHERE user_id = {user_id};'\
                  f'DELETE FROM public.reconciliation_reconciliationuserpropaccount WHERE user_id = {user_id}; ' \
                  f'DELETE FROM public.reconciliation_userpropaccount WHERE user_id = {user_id};' \
                  f'DELETE FROM public.reconciliation_service WHERE user_id = {user_id};' \
                  f'DELETE FROM public.accounting_system_historyuserbill WHERE user_id = {user_id};' \
                  f'DELETE FROM public.accounting_system_transaction ' \
                  f'WHERE user_bill_id in(SELECT id FROM public.accounting_system_userbill WHERE user_id = {user_id});' \
                  f'DELETE FROM public.accounting_system_userbill WHERE user_id = {user_id};' \
                  f'DELETE FROM public.otp_totp_totpdevice WHERE user_id = {user_id};' \
                  f'DELETE FROM public.index_customuser WHERE id = {user_id};'

    assert pgsql_del(request=del_request, **context.custom_config['pg_db'])
コード例 #16
0
ファイル: daily_review.py プロジェクト: A-Zorg/msw_api_copy
def step_impl(context, response_number, req_name, review_date, session):
    with open('./base/dr_sql_requests.json', 'r') as json_file:
        sql_requests = json.load(json_file)
    request = sql_requests[req_name]
    session = session.upper()
    if 'and execution_time' in request or 'WHERE execution_time' in request:
        if session == "PRE":
            session = "< time '10:00:00'"
        elif session == "INT":
            session = "< time '16:00:00' and execution_time >= time '10:00:00'"
        elif session == "POS":
            session = ">= time '16:00:00'"

    request = sql_requests[req_name].format(
        ticker=context.ticker,
        review_date=context.dr_dates[review_date],
        session=session)
    response = pgsql_select(request, **context.custom_config['pg_db'])

    if hasattr(context, 'sql_responses'):
        context.sql_responses[response_number] = response
    else:
        context.sql_responses = {}
        context.sql_responses[response_number] = response
コード例 #17
0
ファイル: daily_review.py プロジェクト: A-Zorg/msw_api_copy
def step_impl(context, account, selected_data):
    request = "SELECT review_date, execution_date, execution_time, ticker, account, side, shares_amount, price  " \
               "FROM public.review_propreportsdata " \
               f"WHERE execution_date = date '{context.custom_config['propreports']['execution_date']}'"
    context.db_result = pgsql_select(request, **context.custom_config['pg_db'])
コード例 #18
0
def step_impl(context, result):
    request = f'SELECT * FROM public.reconciliation_userdata ' \
              f'WHERE user_id = 90000'
    response = pgsql_select(request, **context.custom_config['pg_db'])
    assert response[0][21] == eval(result)