def testSelectSubset(self):

        s3db = current.s3db

        assertTrue = self.assertTrue
        assertEqual = self.assertEqual

        # Define subset
        subset = self.test_data
        numitems = len(subset)
        names = [item[0] for item in subset]

        # Define resource
        resource = s3db.resource("select_master")

        # Page limits
        start = 2
        limit = 2
        subset_names = names[start:start+limit]

        # Simple select
        data = resource.select(["name", "status"],
                               start = start,
                               limit = limit,
                               orderby = "select_master.name",
                               )
        # - returns only rows in page
        rows = data.rows
        assertEqual(len(rows), min(numitems - start, limit))
        assertTrue(all(row["select_master.name"] in subset_names for row in rows))

        # Page with only start
        start = 2
        limit = None
        subset_names = names[start:]

        # Simple select
        data = resource.select(["name", "status"],
                               start = start,
                               limit = limit,
                               orderby = "select_master.name",
                               )
        # - returns only rows in page
        rows = data.rows
        assertEqual(len(rows), numitems - start)
        assertTrue(all(row["select_master.name"] in subset_names for row in rows))

        # Page with only limit
        start = None
        limit = 3
        subset_names = names[:limit]

        # Simple select
        data = resource.select(["name", "status"],
                               start = start,
                               limit = limit,
                               orderby = "select_master.name",
                               )
        # - returns only rows in page
        rows = data.rows
        assertEqual(len(rows), limit)
        assertTrue(all(row["select_master.name"] in subset_names for row in rows))

        # Page limits
        start = 4
        limit = 5
        subset_names = names[start:start+limit]

        # Select with counting
        data = resource.select(["name", "status"],
                               start = start,
                               limit = limit,
                               count = True,
                               orderby = "select_master.name",
                               )
        # - returns only rows in page
        rows = data.rows
        assertEqual(len(rows), min(numitems - start, limit))
        assertTrue(all(row["select_master.name"] in subset_names for row in rows))
        # - counts all matching records, however
        assertEqual(data.numrows, numitems)

        # Select with getids
        data = resource.select(["id", "name", "status"],
                               start = start,
                               limit = limit,
                               getids = True,
                               orderby = "select_master.name",
                               )
        # - returns only rows in page
        rows = data.rows
        assertEqual(len(rows), min(numitems - start, limit))
        assertTrue(all(row["select_master.name"] in subset_names for row in rows))
        # - returns all matching record ids, however
        assertEqual(len(data.ids), numitems)

        # Page beyond subset
        start = numitems
        limit = 10

        # Select with counting
        data = resource.select(["name", "status"],
                               start = start,
                               limit = limit,
                               count = True,
                               orderby = "select_master.name",
                               )
        # - gives no rows
        assertEqual(len(data.rows), 0)
        # - counts all matching records, however
        assertEqual(data.numrows, numitems)

        # Select with getids
        data = resource.select(["id", "name", "status"],
                               start = start,
                               limit = limit,
                               getids = True,
                               orderby = "select_master.name",
                               )
        # - gives no rows
        assertEqual(len(data.rows), 0)
        # - returns all matching record ids, however
        assertEqual(len(data.ids), numitems)

    # -------------------------------------------------------------------------
Test selection of unfiltered subset (pagination)
dataset/ETHPy150Open sahana/eden/modules/unit_tests/s3/s3resource.py/ResourceSelectTests.testSelectSubset