fix(query-tool): show hold lot id via containername and align export
This commit is contained in:
@@ -136,3 +136,27 @@ def test_fetch_events_rejects_branch_replaces_aliased_container_filter(
|
||||
assert "r.CONTAINERID = :container_id" not in sql
|
||||
assert "IN" in sql.upper()
|
||||
assert params == {"p0": "CID-1", "p1": "CID-2"}
|
||||
|
||||
|
||||
@patch("mes_dashboard.services.event_fetcher.cache_set")
|
||||
@patch("mes_dashboard.services.event_fetcher.cache_get", return_value=None)
|
||||
@patch("mes_dashboard.services.event_fetcher.read_sql_df")
|
||||
@patch("mes_dashboard.services.event_fetcher.SQLLoader.load")
|
||||
def test_fetch_events_holds_branch_replaces_aliased_container_filter(
|
||||
mock_sql_load,
|
||||
mock_read_sql_df,
|
||||
_mock_cache_get,
|
||||
_mock_cache_set,
|
||||
):
|
||||
mock_sql_load.return_value = (
|
||||
"SELECT * FROM t h LEFT JOIN c ON c.CONTAINERID = h.CONTAINERID "
|
||||
"WHERE h.CONTAINERID = :container_id ORDER BY h.HOLDTXNDATE DESC"
|
||||
)
|
||||
mock_read_sql_df.return_value = pd.DataFrame([])
|
||||
|
||||
EventFetcher.fetch_events(["CID-1", "CID-2"], "holds")
|
||||
|
||||
sql, params = mock_read_sql_df.call_args.args
|
||||
assert "h.CONTAINERID = :container_id" not in sql
|
||||
assert "IN" in sql.upper()
|
||||
assert params == {"p0": "CID-1", "p1": "CID-2"}
|
||||
|
||||
@@ -749,6 +749,48 @@ class TestExportCsvEndpoint:
|
||||
decoded = response.data.decode('utf-8-sig')
|
||||
assert 'LOT ID' in decoded
|
||||
assert 'GA25010001-A01' in decoded
|
||||
|
||||
@patch('mes_dashboard.routes.query_tool_routes.get_lot_holds')
|
||||
def test_export_lot_holds_uses_container_name_as_lot_id(
|
||||
self,
|
||||
mock_get_holds,
|
||||
client,
|
||||
):
|
||||
mock_get_holds.return_value = {
|
||||
'data': [
|
||||
{
|
||||
'CONTAINERID': '488103800029578b',
|
||||
'CONTAINERNAME': 'GA25010001-A01',
|
||||
'WORKCENTERNAME': '成型',
|
||||
'HOLDTXNDATE': '2026-02-22 16:53:27',
|
||||
'RELEASETXNDATE': None,
|
||||
'HOLD_STATUS': 'HOLD',
|
||||
'HOLD_HOURS': 1.46,
|
||||
'HOLDREASONNAME': 'Q-Time Fail',
|
||||
'HOLDCOMMENTS': '',
|
||||
'HOLDEMP': 'U001',
|
||||
'HOLDEMPDEPTNAME': '成型(D)',
|
||||
'RELEASEEMP': '',
|
||||
'RELEASECOMMENTS': '',
|
||||
'NCRID': '',
|
||||
}
|
||||
],
|
||||
'total': 1,
|
||||
}
|
||||
|
||||
response = client.post(
|
||||
'/api/query-tool/export-csv',
|
||||
json={
|
||||
'export_type': 'lot_holds',
|
||||
'params': {'container_id': '488103800029578b'}
|
||||
}
|
||||
)
|
||||
|
||||
assert response.status_code == 200
|
||||
assert 'lot_holds_488103800029578b.csv' in response.headers.get('Content-Disposition', '')
|
||||
decoded = response.data.decode('utf-8-sig')
|
||||
assert 'LOT ID' in decoded
|
||||
assert 'GA25010001-A01' in decoded
|
||||
|
||||
|
||||
class TestEquipmentListEndpoint:
|
||||
|
||||
Reference in New Issue
Block a user