jeudi 2 août 2018

How to unit test SQL in python?

Does anyone know how to unit test this python function below that contains a SQL query:

def print_manager_name():
    global manager_first_name
    global manager_last_name
    global manager_name

    sql = """SELECT  hrr_first_name,
                     hrr_last_name
             FROM   hris.hrr_reference
             WHERE  hrr_id =:manager_id"""

    cursor = app.connection().cursor()
    cursor.execute(sql, manager_id=manager_id)
    for (manager_first_name, manager_last_name) in cursor:
        manager_name = manager_last_name + ', ' + manager_first_name
    report.alter_printer(font=4, point_size=12)
    report.print(manager_name, (rel(+1), 1))

Aucun commentaire:

Enregistrer un commentaire