~mrp/krait

4f5f94ce7f5fb96f7dd8d47f3d01845ccf799a6c — Mark Penner 1 year, 3 months ago 607bf08 main
refactor test_insert_inventory
1 files changed, 16 insertions(+), 24 deletions(-)

M krait/tests/test_insert.py
M krait/tests/test_insert.py => krait/tests/test_insert.py +16 -24
@@ 14,32 14,24 @@ def test_insert_inventory():
    opendb(":memory:")
    data_model = dataModel()
    next_id = data_model.get_next_id("inventory")
    date = "2023-02-01"
    country = "Mexico"
    region = "Chiapas"
    weight = 9100
    price = 100
    notes = "note field"
    data_model.addInventory(
        {
            "date": date,
            "country": country,
            "region": region,
            "weight": weight,
            "price": price,
            "notes": notes,
        }
    )
    record = {
        "date": "2023-02-01",
        "country": "Mexico",
        "region": "Chiapas",
        "weight": 9100,
        "price": 100,
        "notes": "note field",
    }
    data_model.addInventory(record)
    query = QtSql.QSqlQuery()
    query.prepare(
    query.exec_(
        f"SELECT id, date, country, region, weight, price, notes FROM inventory WHERE id == {next_id}"
    )
    query.exec_()
    query.next()
    assert query.value(0) == next_id
    assert query.value(1) == date
    assert query.value(2) == country
    assert query.value(3) == region
    assert query.value(4) == weight
    assert query.value(5) == price
    assert query.value(6) == notes
    assert query.value(1) == record["date"]
    assert query.value(2) == record["country"]
    assert query.value(3) == record["region"]
    assert query.value(4) == record["weight"]
    assert query.value(5) == record["price"]
    assert query.value(6) == record["notes"]