tests/_helpers.py
def matching_imeis_for_cond_name(db_conn, *, cond_name):
    """Helper function to return current classifications from a condition name."""
    with db_conn.cursor() as cursor:
        base_sql = sql.SQL("""SELECT imei_norm
                                FROM classification_state
                               WHERE end_date IS NULL
                                     {0}
                            ORDER BY imei_norm, cond_name ASC""")

        if cond_name:
            cond_sql = 'AND cond_name = %s'
            sql_bytes = cursor.mogrify(cond_sql, [cond_name])
            cond_filter_sql = sql.SQL(str(sql_bytes, db_conn.encoding))
        else:
            cond_filter_sql = sql.SQL('')

        cursor.execute(base_sql.format(cond_filter_sql))
        return [x.imei_norm for x in cursor.fetchall()]
Helper function to return current classifications from a condition name.
Helper function to return current classifications from a condition name.
Helper function to return current classifications from a condition name .
def matching_imeis_for_cond_name(db_conn, *, cond_name):
    with db_conn.cursor() as cursor:
        base_sql = sql.SQL("""SELECT imei_norm
                                FROM classification_state
                               WHERE end_date IS NULL
                                     {0}
                            ORDER BY imei_norm, cond_name ASC""")
        if cond_name:
            cond_sql = 'AND cond_name = %s'
            sql_bytes = cursor.mogrify(cond_sql, [cond_name])
            cond_filter_sql = sql.SQL(str(sql_bytes, db_conn.encoding))
        else:
            cond_filter_sql = sql.SQL('')
        cursor.execute(base_sql.format(cond_filter_sql))
        return [x.imei_norm for x in cursor.fetchall()]
def matching_imeis_for_cond_name ( db_conn , * , cond_name ) : with db_conn . cursor ( ) as cursor : base_sql = sql . SQL ( """SELECT imei_norm
                                FROM classification_state
                               WHERE end_date IS NULL
                                     {0}
                            ORDER BY imei_norm, cond_name ASC""" ) if cond_name : cond_sql = 'AND cond_name = %s' sql_bytes = cursor . mogrify ( cond_sql , [ cond_name ] ) cond_filter_sql = sql . SQL ( str ( sql_bytes , db_conn . encoding ) ) else : cond_filter_sql = sql . SQL ( '' ) cursor . execute ( base_sql . format ( cond_filter_sql ) ) return [ x . imei_norm for x in cursor . fetchall ( ) ]
Helper function to return current classifications from a condition name.
Helper function to return current classifications from a condition name .
"""Helper function to return current classifications from a condition name."""
db_conn
cond_name