From 8d22ad6ff9ff951a666b0160b3b82e6e2d863178 Mon Sep 17 00:00:00 2001 From: Darren Burns Date: Tue, 14 Feb 2023 11:52:03 +0000 Subject: [PATCH] Adding a test for DataTable.get_row_at --- tests/test_data_table.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/test_data_table.py b/tests/test_data_table.py index cba0a436c..37264a455 100644 --- a/tests/test_data_table.py +++ b/tests/test_data_table.py @@ -363,6 +363,24 @@ async def test_get_row(): assert table.get_row(second_row) == [3, 2, 1] +async def test_get_row_at(): + app = DataTableApp() + async with app.run_test(): + table = app.query_one(DataTable) + a, b, c = table.add_columns("A", "B", "C") + table.add_row(2, 4, 1) + table.add_row(3, 2, 1) + assert table.get_row_at(0) == [2, 4, 1] + assert table.get_row_at(1) == [3, 2, 1] + + # If we sort, then the rows present at the indices *do* change! + table.sort(b) + + # Since we sorted on column "B", the rows at indices 0 and 1 are swapped. + assert table.get_row_at(0) == [3, 2, 1] + assert table.get_row_at(1) == [2, 4, 1] + + async def test_update_cell_cell_exists(): app = DataTableApp() async with app.run_test():