Ejemplo n.º 1
0
def test_cars_drop():
    dbase = run_cars('sqlite', no_close=True)
    assert dbase.tables == ['cars']
    cars_list = list(dbase.query('cars'))
    n_cars = len(cars_list)
    assert n_cars == 32
    dbase.drop('cars')
    assert dbase.tables == []
Ejemplo n.º 2
0
def test_format_in_context_postgres_with_template_and_values():
    dbase = run_cars('sqlite', no_close=True)

    params = {'field': 'name', 'table': 'cars'}

    template = 'select {field} from {table} where cylinders = ?'
    sql = format_sql_in_context(template, params, None)
    cars = dbase.raw_sql_query(sql, values=(6,))
    car_names = [car['name'] for car in cars]
    assert len(car_names) == 7

    expected = ['Mazda RX4', 'Mazda RX4 Wag', 'Hornet 4 Drive',
                'Valiant', 'Merc 280', 'Merc 280C', 'Ferrari Dino']

    assert set(car_names) == set(expected)

    dbase.drop('cars')
    dbase.close()
Ejemplo n.º 3
0
def test_cars_non_block():
    run_cars('sqlite', block=False)
Ejemplo n.º 4
0
def test_cars_block():
    run_cars('sqlite', block=True)
Ejemplo n.º 5
0
def test_cars_postgres_non_block():
    run_cars('postgres', block=False)
Ejemplo n.º 6
0
def test_cars_postgres_block():
    run_cars('postgres', block=True)