From d77e55c03bb0c234db67cae7c85559fa2e5adbed Mon Sep 17 00:00:00 2001 From: Chris Allan Date: Mon, 8 Jul 2024 12:05:52 +0000 Subject: [PATCH] Add a test case for ome/omero-py#418 --- .../integration/tablestest/test_service.py | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/components/tools/OmeroPy/test/integration/tablestest/test_service.py b/components/tools/OmeroPy/test/integration/tablestest/test_service.py index 865d716714a..c66b06188d5 100755 --- a/components/tools/OmeroPy/test/integration/tablestest/test_service.py +++ b/components/tools/OmeroPy/test/integration/tablestest/test_service.py @@ -714,4 +714,40 @@ def testColumnSpaceNames(self): table.delete() table.close() + def tesIncludeRowNumbers(self): + grid = self.client.sf.sharedResources() + table = grid.newTable(1, "/testIncludeRowNumbers") + assert table + + lc = columns.LongColumnI('lc', 'desc', [1, 2, 3, 4, 5]) + table.initialize([lc]) + table.addData([lc]) + + colNumbers = [0] + rowNumbers = [0, 1, 2, 3, 4] + # Check that row numbers come back when defaulting to "true" + data = table.slice(colNumbers, rowNumbers) + assert 1 == len(data.columns) + assert 5 == len(data.columns[0].values) + assert 5 == len(data.rowNumbers) + + # Check that row numbers come back when explicitly stating "true" + data = table.slice( + colNumbers, rowNumbers, { + 'omero.tables.include_row_numbers': "true" + } + ) + assert 5 == len(data.rowNumbers) + + # Check that no row numbers come back when explicitly stating "false" + data = table.slice( + colNumbers, rowNumbers, { + 'omero.tables.include_row_numbers': "false" + } + ) + assert 0 == len(data.rowNumbers) + + table.delete() + table.close() + # TODO: Add tests for error conditions