'Test the initial orderby for different types of input.'

def testDataTableInitialOrderby(self):

    table = self.resource.table
    dt = S3DataTable(self.rfields, self.data)
    expected = [[1, 'asc']]
    actual = dt.orderby
    self.assertEqual(expected, actual)
    dt = S3DataTable(self.rfields, self.data, orderby=table.name)
    expected = [[3, 'asc']]
    actual = dt.orderby
    self.assertEqual(expected, actual)
    dt = S3DataTable(self.rfields, self.data, orderby=(~ table.name))
    expected = [[3, 'desc']]
    actual = dt.orderby
    self.assertEqual(expected, actual)
    dt = S3DataTable(self.rfields, self.data, orderby=(table.office_type_id | table.name))
    expected = [[4, 'asc'], [3, 'asc']]
    actual = dt.orderby
    self.assertEqual(expected, actual)
    dt = S3DataTable(self.rfields, self.data, orderby=((~ table.office_type_id) | table.name))
    expected = [[4, 'desc'], [3, 'asc']]
    actual = dt.orderby
    self.assertEqual(expected, actual)
    otable = current.s3db.org_organisation
    dt = S3DataTable(self.rfields, self.data, orderby=((otable.name | (~ table.office_type_id)) | table.name))
    expected = [[1, 'asc'], [4, 'desc'], [3, 'asc']]
    actual = dt.orderby
    self.assertEqual(expected, actual)
