0

私は Robot Framework に取り組んでいます。私の基本メソッドの 1 つは、n 列と複数の where 条件を持つ SQL クエリを作成するために Python で記述されています。関数は次のようになります。

from pypika import Query, Table, Field
def get_query_with_filter_conditions(table_name, *column, **where):
    table_name_with_no_lock = table_name + ' with (nolock)'
    table = Table(table_name_with_no_lock)
    where_condition = get_where_condition(**where)
    sql_query = Query.from_(table).select(
        *column
    ).where(
        Field(where_condition)
    )
    return str(sql_query).replace('"', '')

Robot キーワードでこのメソッドを次のように呼び出しています。

Get Query With Filter Conditions    ${tableName}    ${column}    &{tableFilter}

この関数は、他の 2 つのキーワードで呼び出されます。1つは、正常に機能します。別の場合、次のようにエラーをスローし続けます

キーワード 'queryBuilderUtility.Get Query With Filter Conditions' は、引数 'table_name' に対して複数の値を取得しました。

正常に機能するキーワードは次のようになります。

Verify the ${element} in ${grid} is fetched from ${column} column in ${tableName} table from DB
    [Documentation]    Verifies Monetary values in the View Sale Grid
    ${feature}=    Get Variable Value    ${FEATURE_NAME}
    ${filterValue}=    Get Variable value    ${FILTER_VALUE}
    ${queryFilter}=    Get the Test Data    valid    ${filterValue}    ${feature}
    &{tableFilter}=    Create Dictionary
    Set To Dictionary    ${tableFilter}    ${filterValue}=${queryFilter}
    Set To Dictionary    ${tableFilter}    form_of_payment_type=${element}
    ${tableName}=    Catenate    SEPARATOR=.    SmartPRASales    ${tableName}
    ${query}=    Get query with Filter Conditions    ${tableName}    ${column}    &{tableFilter}
    Log    ${query}
    @{queryResult}=    CommonPage.Get a Column values from DB    ${query}

常にエラーをスローする関数は次のようになります。

Verify ${element} drop down contains all values from ${column} column in ${tableName} table
    [Documentation]    To verify the drop down has all values from DB
    ${feature}=    Get Variable Value    ${FEATURE_NAME}
    ${filterElement}=    Run Keyword If    '${element}'=='batch_type'    Set Variable    transaction_type
    ...    ELSE IF    '${element}'=='channel'    Set Variable    agency_type
    ...    ELSE    Set Variable    ${element}
    &{tableFilter}=    Create Dictionary
    Set To Dictionary    ${tableFilter}    table_name=GENERAL
    Set To Dictionary    ${tableFilter}    column_name=${filterElement}
    Set To Dictionary    ${tableFilter}    client_id=QR
    Log    ${tableFilter}
    Log    ${tableName}
    Log    ${column}
    ${tableName}=    Catenate    SEPARATOR=.    SmartPRAMaster    ${tableName}
    ${query}=    Get Query With Filter Conditions    ${tableName}    ${column}    &{tableFilter}
    Log    ${query}
    @{expectedvalues}=    CommonPage.Get a Column values from DB    ${query}

誰かが私がここでやっている間違いを修正するのを手伝ってもらえますか?

4

1 に答える 1