feat(db): add datetime column dual-caret sort on inventory and weighing lists.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
7579c36fc6
commit
100b0880f0
11 files changed
+42746
-40718
No files matched your search
@@ -0,0 +1,41 @@
|
||||
from app.models.db_models import DbInboundOutbound, DbWeighingSlip
|
||||
from app.services.db.list_sort import (
|
||||
order_inventory,
|
||||
order_weighing,
|
||||
parse_sort_params,
|
||||
weighing_needs_inventory_join,
|
||||
)
|
||||
|
||||
|
||||
def test_inventory_date_asc():
|
||||
expr = order_inventory("date", "asc")
|
||||
assert "date" in str(expr).lower()
|
||||
assert "asc" in str(expr).lower()
|
||||
|
||||
|
||||
def test_inventory_invalid_falls_back():
|
||||
default = DbInboundOutbound.date.desc()
|
||||
assert order_inventory("hack", "asc", default=default) is default
|
||||
|
||||
|
||||
def test_weighing_inventory_date_desc():
|
||||
expr = order_weighing("inventoryDate", "desc")
|
||||
assert "date" in str(expr).lower()
|
||||
assert "desc" in str(expr).lower()
|
||||
|
||||
|
||||
def test_weighing_needs_join():
|
||||
assert weighing_needs_inventory_join("inventoryDate", "asc") is True
|
||||
assert weighing_needs_inventory_join("inventoryDate", "nope") is False
|
||||
assert weighing_needs_inventory_join(None, "asc") is False
|
||||
|
||||
|
||||
def test_parse_sort_params_camel():
|
||||
sf, so = parse_sort_params({"sortField": "date", "sortOrder": "asc"})
|
||||
assert sf == "date"
|
||||
assert so == "asc"
|
||||
|
||||
|
||||
def test_weighing_invalid_falls_back():
|
||||
default = DbWeighingSlip.gross_weight_time.desc()
|
||||
assert order_weighing("hack", "asc", default=default) is default
|
||||
Reference in new issue
Block a user