desc stringlengths 3 26.7k | decl stringlengths 11 7.89k | bodies stringlengths 8 553k |
|---|---|---|
'Test construction of reference field'
| def testReferenceFieldConstruction(self):
| assertEqual = self.assertEqual
assertTrue = self.assertTrue
assertFalse = self.assertFalse
dm = S3DynamicModel(self.TABLENAME)
define_field = dm._field
params = Storage(name='organisation_id', field_type='reference org_organisation')
field = define_field(self.TABLENAME, params)
assert... |
'Test construction of boolean field'
| def testBooleanFieldConstruction(self):
| assertEqual = self.assertEqual
assertTrue = self.assertTrue
assertFalse = self.assertFalse
dm = S3DynamicModel(self.TABLENAME)
define_field = dm._field
from s3 import s3_yes_no_represent
params = Storage(name='flag', field_type='boolean')
field = define_field(self.TABLENAME, params)
... |
'Test construction of integer field'
| def testIntegerFieldConstruction(self):
| assertEqual = self.assertEqual
assertTrue = self.assertTrue
assertFalse = self.assertFalse
dm = S3DynamicModel(self.TABLENAME)
define_field = dm._field
params = Storage(name='number', field_type='integer')
field = define_field(self.TABLENAME, params)
assertEqual(field.name, 'number')
... |
'Test construction of double field'
| def testDoubleFieldConstruction(self):
| assertEqual = self.assertEqual
assertTrue = self.assertTrue
assertFalse = self.assertFalse
dm = S3DynamicModel(self.TABLENAME)
define_field = dm._field
params = Storage(name='number', field_type='double')
field = define_field(self.TABLENAME, params)
assertEqual(field.name, 'number')
... |
'Test construction of date field'
| def testDateFieldConstruction(self):
| assertEqual = self.assertEqual
assertTrue = self.assertTrue
assertFalse = self.assertFalse
dm = S3DynamicModel(self.TABLENAME)
define_field = dm._field
params = Storage(name='start_date', field_type='date')
field = define_field(self.TABLENAME, params)
assertEqual(field.name, 'start_date'... |
'Test construction of date field'
| def testDateTimeFieldConstruction(self):
| import dateutil.tz
from dateutil.relativedelta import relativedelta
assertEqual = self.assertEqual
assertTrue = self.assertTrue
assertFalse = self.assertFalse
dm = S3DynamicModel(self.TABLENAME)
define_field = dm._field
params = Storage(name='start_date', field_type='datetime')
field... |
'Test construction of options-field'
| def testOptionFieldConstruction(self):
| assertEqual = self.assertEqual
assertTrue = self.assertTrue
assertFalse = self.assertFalse
assertIn = self.assertIn
T = current.T
T.force('en')
dm = S3DynamicModel(self.TABLENAME)
define_field = dm._field
params = Storage(name='status', field_type='integer', options=[[1, 'new'], [2, ... |
'Test access to dynamic components'
| def testComponentAccess(self):
| s3db = current.s3db
assertTrue = self.assertTrue
assertEqual = self.assertEqual
resource = s3db.resource('org_organisation')
assertTrue(('test_rating' in resource.components))
component = resource.components['test_rating']
assertEqual(component.tablename, self.TABLENAME)
assertTrue(('org... |
'Test field selector resolution for dynamic components'
| def testFieldSelectorResolution(self):
| s3db = current.s3db
assertEqual = self.assertEqual
resource = s3db.resource('org_organisation')
rfield = resource.resolve_selector('test_rating.value')
assertEqual(rfield.tname, self.TABLENAME)
assertEqual(rfield.fname, 'value')
assertEqual(rfield.ftype, 'integer')
|
'Set up the list of fields each time since the call to S3DataTables
could change it.'
| def setUp(self):
| current.auth.override = True
resource = current.s3db.resource('org_office')
list_fields = ['id', 'organisation_id$name', 'organisation_id$address', 'name', 'office_type_id', 'location_id$L0', 'location_id$L1', 'location_id$L2', 'location_id$L3', 'phone1', 'email']
self.resource = resource
self.list_... |
'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, ac... |
'Master resource has no join'
| def testGetJoinMaster(self):
| resource = current.s3db.resource('pr_person')
self.assertEqual(resource.get_join(), None)
|
'Join for a simple component'
| def testGetJoinSimpleComponent(self):
| resource = current.s3db.resource('pr_person')
component = resource.components['identity']
rtable = resource.table
ctable = component.table
expected = ((ctable.person_id == rtable.id) & (ctable.deleted != True))
join = component.get_join()
self.assertEqual(str(join), str(expected))
|
'Join for a super-component'
| def testGetJoinSuperComponent(self):
| resource = current.s3db.resource('pr_person')
component = resource.components['contact']
rtable = resource.table
ctable = component.table
expected = ((rtable.pe_id == ctable.pe_id) & (ctable.deleted != True))
join = component.get_join()
self.assertEqual(str(join), str(expected))
|
'Join for a link-table component'
| @unittest.skipIf((not current.deployment_settings.has_module('project')), 'project module disabled')
def testGetJoinLinkTableComponent(self):
| resource = current.s3db.resource('project_project')
component = resource.components['task']
project_project = resource.table
project_task_project = component.link.table
project_task = component.table
expected = (((project_task_project.project_id == project_project.id) & (project_task_project.del... |
'Master resource has no left join'
| def testGetLeftJoinMaster(self):
| resource = current.s3db.resource('pr_person')
self.assertEqual(resource.get_left_join(), None)
|
'Left Join for a simple component'
| def testGetLeftJoinSimpleComponent(self):
| assertEqual = self.assertEqual
assertTrue = self.assertTrue
resource = current.s3db.resource('pr_person')
component = resource.components['identity']
rtable = resource.table
ctable = component.table
expected = ctable.on(((ctable.person_id == rtable.id) & (ctable.deleted != True)))
ljoin ... |
'Left Join for a super-component'
| def testGetLeftJoinSuperComponent(self):
| assertEqual = self.assertEqual
assertTrue = self.assertTrue
resource = current.s3db.resource('pr_person')
component = resource.components['contact']
rtable = resource.table
ctable = component.table
expected = ctable.on(((rtable.pe_id == ctable.pe_id) & (ctable.deleted != True)))
ljoin = ... |
'Left Join for a link-table component'
| @unittest.skipIf((not current.deployment_settings.has_module('project')), 'project module disabled')
def testGetLeftJoinLinkTableComponent(self):
| assertEqual = self.assertEqual
assertTrue = self.assertTrue
resource = current.s3db.resource('project_project')
component = resource.components['task']
rtable = resource.table
ltable = component.link.table
ctable = component.table
expected_l = ltable.on(((ltable.project_id == rtable.id) ... |
'Test list:type axis value filtering'
| def testListTypeFilter(self):
| assertTrue = self.assertTrue
assertFalse = self.assertFalse
tablename = 'axis_filter'
db = current.db
db.define_table(tablename, Field('facility_type_id', 'list:reference org_facility_type'), *s3_meta_fields())
table = db[tablename]
try:
s3db = current.s3db
resource = s3db... |
'Test Standard Data Table'
| def testDataTableFilterStandard(self):
| resource = current.s3db.resource('hrm_certificate_skill')
vars = Storage({'bSortable_0': 'false', 'bSortable_1': 'true', 'bSortable_2': 'true', 'sSortDir_0': 'asc', 'iSortCol_0': '1', 'iColumns': '3', 'iSortingCols': '1'})
(searchq, orderby, left) = resource.datatable_filter(['id', 'skill_id', 'competency_i... |
'Test De-Duplicator Data Table'
| def testDataTableFilterWithBulkColumn(self):
| resource = current.s3db.resource('hrm_certificate_skill')
vars = Storage({'bSortable_0': 'false', 'bSortable_1': 'false', 'bSortable_2': 'true', 'bSortable_3': 'true', 'sSortDir_0': 'desc', 'iSortCol_0': '2', 'iColumns': '4', 'iSortingCols': '1'})
(searchq, orderby, left) = resource.datatable_filter(['id', ... |
'Test Other Data Table'
| def testDataTableFilterOther(self):
| resource = current.s3db.resource('hrm_certificate_skill')
vars = Storage({'bSortable_0': 'false', 'bSortable_1': 'true', 'bSortable_2': 'false', 'bSortable_3': 'true', 'sSortDir_0': 'desc', 'iSortCol_0': '3', 'iColumns': '4', 'iSortingCols': '1'})
(searchq, orderby, left) = resource.datatable_filter(['id', ... |
'Test export of a resource as element tree'
| def testExportTree(self):
| assertEqual = self.assertEqual
assertTrue = self.assertTrue
xml = current.xml
auth = current.auth
auth.override = True
xmlstr = '\n<s3xml>\n <resource name="org_organisation">\n <data field="name">TestExportTreeOrganisation1</data>\n ... |
'Text XML output with max bounds'
| def testExportTreeWithMaxBounds(self):
| assertEqual = self.assertEqual
assertTrue = self.assertTrue
xml = current.xml
auth = current.auth
auth.override = True
xmlstr = '\n<s3xml>\n <resource name="org_organisation">\n <data field="name">TestExportTreeOrganisation2</data>\n ... |
'Test automatic ordering of export items by mtime if msince is given'
| def testExportTreeWithMSince(self):
| assertEqual = self.assertEqual
auth = current.auth
auth.override = True
xmlstr = '\n<s3xml>\n <resource name="hms_hospital" uuid="ORDERTESTHOSPITAL1">\n <data field="name">OrderTestHospital1</data>\n </resource>\n <reso... |
'Test XML Export with Sync Filters'
| def testExportXMLWithSyncFilters(self):
| assertEqual = self.assertEqual
assertTrue = self.assertTrue
assertFalse = self.assertFalse
auth = current.auth
s3db = current.s3db
auth.override = True
xmlstr = '\n<s3xml>\n <resource name="org_office_type" uuid="SFT1">\n <data field="na... |
'Test JSON message after XML import'
| def testImportXML(self):
| assertEqual = self.assertEqual
assertTrue = self.assertTrue
xmlstr = '\n<s3xml>\n\n <resource name="pr_person">\n\n <data field="first_name">Jason</data>\n <data field="last_name">Test</data>\n ... |
'Test mtime update in imports'
| def testImportXMLWithMTime(self):
| xmlstr = '\n<s3xml>\n <resource name="hms_hospital" uuid="MTIMETESTHOSPITAL1" modified_on="2012-03-31T00:00:00">\n <data field="name">MTimeTestHospital1</data>\n </resource>\n <resource name="hms_hospital" uuid="MTIMETESTH... |
'Test mtime update in imports with no mtime given'
| def testImportXMLWithoutMTime(self):
| xmlstr = '\n<s3xml>\n <resource name="hms_hospital" uuid="MTIMETESTHOSPITAL3">\n <data field="name">MTimeTestHospital3</data>\n </resource>\n</s3xml>'
xmltree = etree.ElementTree(etree.fromstring(xmlstr))
resource = current.s3db.resource(... |
'Test mtime update in imports if mtime given in only some records'
| def testImportXMLWithPartialMTime(self):
| xmlstr = '\n<s3xml>\n <resource name="hms_hospital" uuid="MTIMETESTHOSPITAL4" modified_on="2012-03-31T00:00:00">\n <data field="name">MTimeTestHospital4</data>\n </resource>\n <resource name="hms_hospital" uuid="MTIMETESTH... |
'Test load status indication by value of _rows'
| def testLoadStatusIndication(self):
| assertEqual = self.assertEqual
assertNotEqual = self.assertNotEqual
assertTrue = self.assertTrue
resource = current.s3db.resource('project_time')
assertEqual(resource._rows, None)
resource.load()
assertNotEqual(resource._rows, None)
assertTrue(isinstance(resource._rows, list))
resour... |
'Test selection of fields in load() with fields and skip'
| def testLoadFieldSelection(self):
| assertEqual = self.assertEqual
assertTrue = self.assertTrue
assertFalse = self.assertFalse
s3db = current.s3db
auth = current.auth
auth.override = True
xmlstr = '\n<s3xml>\n <resource name="org_office" uuid="LOADTESTOFFICE">\n <data fiel... |
'Set up organisation records'
| def setUp(self):
| s3db = current.s3db
otable = s3db.org_organisation
org1 = Storage(name='Merge Test Organisation', acronym='MTO', country='UK', website='http://www.example.org')
org1_id = otable.insert(**org1)
org1.update(id=org1_id)
s3db.update_super(otable, org1)
org2 = Storage(name='Merger Test ... |
'Test merge'
| def testMerge(self):
| assertEqual = self.assertEqual
assertNotEqual = self.assertNotEqual
assertTrue = self.assertTrue
assertFalse = self.assertFalse
success = self.resource.merge(self.id1, self.id2)
assertTrue(success)
(org1, org2) = self.get_records()
assertNotEqual(org1, None)
assertNotEqual(org2, None... |
'Test merge where original record lacks SEs'
| def testMergeMissingOriginalSE(self):
| assertEqual = self.assertEqual
assertNotEqual = self.assertNotEqual
assertTrue = self.assertTrue
resource = self.resource
get_records = self.get_records
(org1, org2) = get_records()
success = current.s3db.delete_super(resource.table, org1)
assertTrue(success)
(org1, org2) = get_recor... |
'Test merge where duplicate record lacks SEs'
| def testMergeMissingDuplicateSE(self):
| assertEqual = self.assertEqual
assertNotEqual = self.assertNotEqual
assertTrue = self.assertTrue
assertFalse = self.assertFalse
resource = self.resource
get_records = self.get_records
(org1, org2) = get_records()
success = current.s3db.delete_super(resource.table, org2)
assertTrue(su... |
'Test merge where both records lack SEs'
| def testMergeMissingSE(self):
| assertEqual = self.assertEqual
assertNotEqual = self.assertNotEqual
assertTrue = self.assertTrue
assertFalse = self.assertFalse
resource = self.resource
get_records = self.get_records
(org1, org2) = get_records()
success = current.s3db.delete_super(resource.table, org1)
success = cur... |
'Test merge with replace'
| def testMergeReplace(self):
| assertEqual = self.assertEqual
assertNotEqual = self.assertNotEqual
assertTrue = self.assertTrue
assertFalse = self.assertFalse
success = self.resource.merge(self.id1, self.id2, replace=['acronym', 'website'])
assertTrue(success)
(org1, org2) = self.get_records()
assertNotEqual(org1, Non... |
'Test merge with replace and Update'
| def testMergeReplaceAndUpdate(self):
| assertEqual = self.assertEqual
assertNotEqual = self.assertNotEqual
assertTrue = self.assertTrue
assertFalse = self.assertFalse
success = self.resource.merge(self.id1, self.id2, replace=['acronym'], update=Storage(website='http://www.example.co.uk'))
assertTrue(success)
(org1, org2) = self.g... |
'Test merge of link table entries'
| def testMergeLinkTable(self):
| assertEqual = self.assertEqual
assertNotEqual = self.assertNotEqual
assertTrue = self.assertTrue
assertFalse = self.assertFalse
db = current.db
s3db = current.s3db
deployment_settings = current.deployment_settings
(org1, org2) = self.get_records()
org1_pe_id = s3db.pr_get_pe_id(org1)... |
'Test merge with virtual references'
| def testMergeVirtualReference(self):
| utable = current.auth.settings.table_user
user = Storage(first_name='Test', last_name='User', password='xyz', email='testuser@example.com', organisation_id=self.id2)
user_id = utable.insert(**user)
success = self.resource.merge(self.id1, self.id2)
self.assertTrue(success)
user = current.db((utab... |
'Test merge of realms when merging two person entities'
| def testMergeRealms(self):
| assertEqual = self.assertEqual
assertTrue = self.assertTrue
(org1, org2) = self.get_records()
s3db = current.s3db
org1_pe_id = s3db.pr_get_pe_id(org1)
org2_pe_id = s3db.pr_get_pe_id(org2)
person = Storage(first_name='Nxthga', realm_entity=org2_pe_id)
ptable = s3db.pr_person
person_id... |
'Set up person records'
| def setUp(self):
| db = current.db
auth = current.auth
s3db = current.s3db
deployment_settings = current.deployment_settings
auth.override = True
ptable = s3db.pr_person
person1 = Storage(first_name='Test', last_name='Person')
person1_id = ptable.insert(**person1)
person1.update(id=person1_id)
s3db... |
'Check for exception if not authorized'
| def testPermissionError(self):
| db = current.db
auth = current.auth
s3db = current.s3db
deployment_settings = current.deployment_settings
auth.override = False
auth.s3_impersonate(None)
with self.assertRaises(current.auth.permission.error):
self.resource.merge(self.id1, self.id2)
ptable = s3db.pr_person
que... |
'Check for exception if record not found'
| def testOriginalNotFoundError(self):
| db = current.db
s3db = current.s3db
deployment_settings = current.deployment_settings
with self.assertRaises(KeyError):
self.resource.merge(0, self.id2)
ptable = s3db.pr_person
query = ptable._id.belongs((self.id1, self.id2))
rows = db(query).select(ptable._id, limitby=(0, 2))
se... |
'Check for exception if record not found'
| def testNotDuplicateFoundError(self):
| db = current.db
s3db = current.s3db
deployment_settings = current.deployment_settings
with self.assertRaises(KeyError):
self.resource.merge(self.id1, 0)
ptable = s3db.pr_person
query = ptable._id.belongs((self.id1, self.id2))
rows = db(query).select(ptable._id, limitby=(0, 2))
se... |
'Test merge'
| def testMerge(self):
| assertEqual = self.assertEqual
assertNotEqual = self.assertNotEqual
assertTrue = self.assertTrue
assertFalse = self.assertFalse
success = self.resource.merge(self.id1, self.id2)
assertTrue(success)
(person1, person2) = self.get_records()
assertNotEqual(person1, None)
assertNotEqual(p... |
'Test merge with update'
| def testMergeWithUpdate(self):
| assertEqual = self.assertEqual
assertNotEqual = self.assertNotEqual
assertTrue = self.assertTrue
assertFalse = self.assertFalse
success = self.resource.merge(self.id1, self.id2, update=Storage(first_name='Changed'))
assertTrue(success)
(person1, person2) = self.get_records()
assertNotEqu... |
'Test merge of single-component'
| def testMergeSingleComponent(self):
| assertEqual = self.assertEqual
assertNotEqual = self.assertNotEqual
assertTrue = self.assertTrue
assertFalse = self.assertFalse
db = current.db
s3db = current.s3db
deployment_settings = current.deployment_settings
(person1, person2) = self.get_records()
dtable = s3db.pr_physical_desc... |
'Test merge of multiple-component'
| def testMergeMultiComponent(self):
| assertEqual = self.assertEqual
assertNotEqual = self.assertNotEqual
assertTrue = self.assertTrue
assertFalse = self.assertFalse
db = current.db
s3db = current.s3db
deployment_settings = current.deployment_settings
(person1, person2) = self.get_records()
itable = s3db.pr_identity
... |
'Set up location records'
| def setUp(self):
| auth = current.auth
s3db = current.s3db
auth.override = True
ltable = s3db.gis_location
location1 = Storage(name='TestLocation')
location1_id = ltable.insert(**location1)
location2 = Storage(name='TestLocation')
location2_id = ltable.insert(**location2)
self.id1 = location1_id
se... |
'Test merge'
| def testMerge(self):
| assertEqual = self.assertEqual
assertNotEqual = self.assertNotEqual
assertTrue = self.assertTrue
assertFalse = self.assertFalse
success = self.resource.merge(self.id1, self.id2)
assertTrue(success)
(location1, location2) = self.get_records()
assertNotEqual(location1, None)
assertNotE... |
'Test merge of a simple reference including super-entity'
| def testMergeSimpleReference(self):
| assertEqual = self.assertEqual
assertNotEqual = self.assertNotEqual
assertTrue = self.assertTrue
db = current.db
s3db = current.s3db
otable = s3db.org_office
office = Storage(name='Test Office', location_id=self.id2)
office_id = otable.insert(**office)
office.update(id=office_id)
... |
'Test merge with replace of a unique-field'
| def testMergeReplaceUnique(self):
| assertEqual = self.assertEqual
assertNotEqual = self.assertNotEqual
assertTrue = self.assertTrue
assertFalse = self.assertFalse
tablename = self.tablename
resource = current.s3db.resource(tablename)
success = resource.merge(self.id1, self.id2, replace=['name'])
assertTrue(success)
db... |
'get() without ID raises a KeyError'
| def testGetError(self):
| resource = current.s3db.resource('org_organisation', uid='GETTESTORG')
self.assertRaises(KeyError, resource.get, None)
|
'get() with an ID returns the record, if accessible'
| def testGetMaster(self):
| assertEqual = self.assertEqual
assertNotEqual = self.assertNotEqual
assertTrue = self.assertTrue
resource = current.s3db.resource('org_organisation', uid='GETTESTORG')
record = resource.get(self.org_id)
assertNotEqual(record, None)
assertTrue(isinstance(record, Row))
assertEqual(record.i... |
'get() with an ID raises a KeyError, if not accessible'
| def testGetMasterFail(self):
| resource = current.s3db.resource('org_organisation', uid='OTHERTESTORG')
with self.assertRaises(KeyError):
resource.get(self.org_id)
|
'get() with ID and component alias returns the components records'
| def testGetComponent(self):
| assertEqual = self.assertEqual
assertNotEqual = self.assertNotEqual
assertTrue = self.assertTrue
resource = current.s3db.resource('org_organisation', uid='GETTESTORG')
records = resource.get(self.org_id, 'office')
assertNotEqual(records, None)
assertTrue(len(records), 1)
record = records... |
'Test application of extra filters'
| def testApplyExtraFilter(self):
| assertTrue = self.assertTrue
assertEqual = self.assertEqual
assertNotEqual = self.assertNotEqual
test_expression = 'test filter expression'
seen = []
def test_filter(resource, ids, expression):
' Test filter method '
assertNotEqual(resource, None)
assert... |
'Test selecting all records'
| def testSelectAll(self):
| s3db = current.s3db
assertTrue = self.assertTrue
assertEqual = self.assertEqual
numitems = len(self.test_data)
resource = s3db.resource('select_master')
data = resource.select(['name', 'status'])
assertEqual(len(data.rows), numitems)
data = resource.select(['name', 'status'], count=True)... |
'Test selection with filter'
| def testSelectFilter(self):
| s3db = current.s3db
assertTrue = self.assertTrue
assertEqual = self.assertEqual
numitems = len([item for item in self.test_data if (item[1] == 'A')])
query = (FS('status') == 'A')
resource = s3db.resource('select_master', filter=query)
data = resource.select(['name', 'status'])
rows = da... |
'Test selection with virtual filter'
| def testSelectVirtualFilter(self):
| s3db = current.s3db
assertTrue = self.assertTrue
assertEqual = self.assertEqual
numitems = len([item for item in self.test_data if (item[1] == 'A')])
query = (FS('code') == 'A')
resource = s3db.resource('select_master', filter=query)
data = resource.select(['name', 'status'])
rows = data... |
'Test selection with extra filter'
| def testSelectExtraFilter(self):
| db = current.db
s3db = current.s3db
assertTrue = self.assertTrue
assertEqual = self.assertEqual
test_expression = 'A'
numitems = len([item for item in self.test_data if (item[1] == test_expression)])
def test_filter(resource, ids, expression):
' Test filter function '
... |
'Test selection of unfiltered subset (pagination)'
| def testSelectSubset(self):
| s3db = current.s3db
assertTrue = self.assertTrue
assertEqual = self.assertEqual
subset = self.test_data
numitems = len(subset)
names = [item[0] for item in subset]
resource = s3db.resource('select_master')
start = 2
limit = 2
subset_names = names[start:(start + limit)]
data =... |
'Test selection of filtered subset (pagination)'
| def testSelectSubsetFilter(self):
| s3db = current.s3db
assertTrue = self.assertTrue
assertEqual = self.assertEqual
subset = [item for item in self.test_data if (item[1] == 'A')]
numitems = len(subset)
names = [item[0] for item in subset]
query = (FS('status') == 'A')
resource = s3db.resource('select_master', filter=query)... |
'Test selection of subset (pagination) with virtual filter'
| def testSelectSubsetVirtualFilter(self):
| s3db = current.s3db
assertTrue = self.assertTrue
assertEqual = self.assertEqual
subset = [item for item in self.test_data if (item[1] == 'A')]
numitems = len(subset)
names = [item[0] for item in subset]
query = (FS('code') == 'A')
resource = s3db.resource('select_master', filter=query)
... |
'Test selection of subset (pagination) with extra filter'
| def testSelectSubsetExtraFilter(self):
| db = current.db
s3db = current.s3db
assertTrue = self.assertTrue
assertEqual = self.assertEqual
test_expression = 'A'
def test_filter(resource, ids, expression):
' Test filter function '
assertEqual(expression, test_expression)
table = resource.table
q... |
'Dummy lazy field'
| def lazy_name(self, row):
| self.record_id = row.pr_person.id
return ('%s %s' % (row.pr_person.first_name, row.pr_person.last_name))
|
'Test whether field selectors for lazy virtual fields
can be properly resolved'
| def testLazyVirtualFieldsResolve(self):
| assertEqual = self.assertEqual
resource = current.s3db.resource('pr_person')
from s3 import S3ResourceField
rfield = S3ResourceField(resource, 'name')
assertEqual(rfield.field, None)
assertEqual(rfield.ftype, 'virtual')
|
'Test whether values for lazy virtual fields can be extracted'
| def testLazyVirtualFieldsExtract(self):
| assertEqual = self.assertEqual
assertTrue = self.assertTrue
self.record_id = None
resource = current.s3db.resource('pr_person')
rows = resource.select(['name', 'first_name', 'last_name'], limit=1, as_rows=True)
row = rows[0]
assertTrue(('name' in row))
assertTrue(callable(row['name']))
... |
'Test whether S3ResourceQueries work with lazy virtual fields'
| def testLazyVirtualFieldsFilter(self):
| assertEqual = self.assertEqual
assertTrue = self.assertTrue
resource = current.s3db.resource('pr_person')
from s3 import FS
query = FS('name').like('Admin%')
resource.add_filter(query)
data = resource.select(['name', 'first_name', 'last_name'], limit=None)
rows = data['rows']
for ite... |
'Test whether URL filters work with lazy virtual fields'
| def testLazyVirtualFieldsURLFilter(self):
| assertEqual = self.assertEqual
assertTrue = self.assertTrue
vars = Storage({'person.name__like': 'Admin*'})
resource = current.s3db.resource('pr_person', vars=vars)
data = resource.select(['name', 'first_name', 'last_name'], limit=None)
rows = data['rows']
for item in rows:
assertTru... |
'Test instantiation of filtered component'
| @unittest.skipIf((not current.deployment_settings.has_module('org')), 'org module disabled')
def testAttachFilteredComponent(self):
| assertEqual = self.assertEqual
s3db = current.s3db
s3db.add_components('org_organisation', org_office={'name': 'test', 'joinby': 'organisation_id', 'filterby': {'office_type_id': 5}})
resource = s3db.resource('org_organisation', components=['test'])
component = resource.components['test']
table ... |
'Test resolution of field selectors for filtered components'
| @unittest.skipIf((not current.deployment_settings.has_module('org')), 'org module disabled')
def testResolveSelectorWithFilteredComponent(self):
| assertEqual = self.assertEqual
s3db = current.s3db
s3db.add_components('org_organisation', org_office={'name': 'test', 'joinby': 'organisation_id', 'filterby': {'office_type_id': 5}})
resource = s3db.resource('org_organisation')
rfield = S3ResourceField(resource, 'test.name')
assertEqual(rfield.... |
'Test resolution of URL queries for fields in filtered components'
| @unittest.skipIf((not current.deployment_settings.has_module('org')), 'org module disabled')
def testURLQueryWithFilteredComponent(self):
| assertEqual = self.assertEqual
auth = current.auth
s3db = current.s3db
org_organisation = s3db.org_organisation
org_test_office = s3db.org_office.with_alias('org_test_office')
s3db.add_components('org_organisation', org_office={'name': 'test', 'joinby': 'organisation_id', 'filterby': {'office_ty... |
'Test translation of datatable filter/sorting for fields in
filtered components'
| @unittest.skipIf((not current.deployment_settings.has_module('org')), 'org module disabled')
def testDataTableFilterWithFilteredComponent(self):
| assertEqual = self.assertEqual
s3db = current.s3db
org_organisation = s3db.org_organisation
org_office_type = s3db.org_office_type
org_test_office = s3db.org_office.with_alias('org_test_office')
s3db.add_components('org_organisation', org_office={'name': 'test', 'joinby': 'organisation_id', 'fil... |
'Test S3Resource.select with fields in a filtered component'
| @unittest.skipIf((not current.deployment_settings.has_module('org')), 'org module disabled')
def testSelectWithFilteredComponent(self):
| assertEqual = self.assertEqual
assertTrue = self.assertTrue
s3db = current.s3db
auth = current.auth
xmlstr = '\n<s3xml>\n <resource name="org_organisation" uuid="FCTESTORG">\n <data field="name">FilteredComponentsTestOrg</data>\n ... |
'Join for a link-table component with alias'
| @unittest.skipIf((not current.deployment_settings.has_module('hrm')), 'hrm module disabled')
def testGetJoinLinkTableComponentAlias(self):
| assertEqual = self.assertEqual
s3db = current.s3db
hrm_human_resource = s3db.hrm_human_resource
pr_person = s3db.pr_person
pr_email_contact = s3db.pr_contact.with_alias('pr_email_contact')
pr_phone_contact = s3db.pr_contact.with_alias('pr_phone_contact')
resource = current.s3db.resource('hrm... |
'Left Join for a link-table component with alias'
| @unittest.skipIf((not current.deployment_settings.has_module('hrm')), 'hrm module disabled')
def testGetLeftJoinLinkTableComponentAlias(self):
| assertEqual = self.assertEqual
assertTrue = self.assertTrue
s3db = current.s3db
resource = s3db.resource('hrm_human_resource')
pr_person = s3db.pr_person
hrm_human_resource = s3db.hrm_human_resource
pr_contact = s3db.pr_contact
component = resource.components['email']
pr_email_contac... |
'Test export of a resource that has components from the same table but different aliases'
| @unittest.skip('disabled until fixed')
@unittest.skipIf((not current.deployment_settings.has_module('org')), 'org module disabled')
def testExportTreeWithComponentAlias(self):
| assertEqual = self.assertEqual
assertTrue = self.assertTrue
current.auth.override = True
s3db = current.s3db
s3db.add_components('org_organisation', org_office=({'name': 'fieldoffice', 'joinby': 'organisation_id', 'filterby': {'office_type_id': 5}}, {'name': 'hq', 'joinby': 'organisation_id', 'filte... |
'Dummy ondelete-callback'
| def master_ondelete(self, row):
| self.master_deleted = row.id
return
|
'Dummy ondelete-callback'
| def super_ondelete(self, row):
| self.super_deleted = row.id
return
|
'Dummy ondelete-callback'
| def component_ondelete(self, row):
| self.component_deleted = row.id
return
|
'Test archiving of a record'
| def testArchiveSimple(self):
| assertEqual = self.assertEqual
assertTrue = self.assertTrue
s3db = current.s3db
s3db.clear_config('del_master', 'super_entity')
master_id = self.master_id
resource = s3db.resource('del_master', id=master_id)
success = resource.delete()
assertEqual(success, 1)
assertEqual(resource.err... |
'Test archiving of a record which is referenced by
other records'
| def testArchiveCascade(self):
| assertEqual = self.assertEqual
assertNotEqual = self.assertNotEqual
assertTrue = self.assertTrue
s3db = current.s3db
s3db.clear_config('del_master', 'super_entity')
master_id = self.master_id
s3db.define_table('del_component', Field('del_master_id', s3db.del_master, ondelete='CASCADE'), *s3_... |
'Test archiving of a record which is referenced by
other records'
| def testArchiveSetNull(self):
| assertEqual = self.assertEqual
assertNotEqual = self.assertNotEqual
assertTrue = self.assertTrue
assertFalse = self.assertFalse
s3db = current.s3db
s3db.clear_config('del_master', 'super_entity')
master_id = self.master_id
s3db.define_table('del_component', Field('del_master_id', s3db.de... |
'Test archiving of a record which is referenced by
other records'
| def testArchiveRestrict(self):
| assertEqual = self.assertEqual
assertNotEqual = self.assertNotEqual
assertTrue = self.assertTrue
assertFalse = self.assertFalse
s3db = current.s3db
s3db.clear_config('del_master', 'super_entity')
master_id = self.master_id
s3db.define_table('del_component', Field('del_master_id', s3db.de... |
'Test archiving of a super-entity instance record'
| def testArchiveSuper(self):
| assertEqual = self.assertEqual
assertTrue = self.assertTrue
s3db = current.s3db
master_id = self.master_id
table = s3db.del_master
record = table[master_id]
super_id = record['del_super_id']
resource = s3db.resource('del_master', id=master_id)
success = resource.delete()
assertEq... |
'Test archiving of a super-entity instance record
where the super-record is referenced by other records
with CASCADE constraint'
| def testArchiveSuperCascade(self):
| assertEqual = self.assertEqual
assertNotEqual = self.assertNotEqual
assertTrue = self.assertTrue
s3db = current.s3db
master_id = self.master_id
s3db.define_table('del_component', s3db.super_link('del_super_id', 'del_super', ondelete='CASCADE'), *s3_meta_fields())
component = s3db['del_compon... |
'Test archiving of a super-entity instance record
where the super-record is referenced by other records
with SET NULL constraint'
| def testArchiveSuperSetNull(self):
| assertEqual = self.assertEqual
assertNotEqual = self.assertNotEqual
assertTrue = self.assertTrue
assertFalse = self.assertFalse
s3db = current.s3db
master_id = self.master_id
s3db.define_table('del_component', s3db.super_link('del_super_id', 'del_super', ondelete='SET NULL'), *s3_meta_fie... |
'Test archiving of a super-entity instance record
where the super-record is referenced by other records
with RESTRICT constraint'
| def testArchiveSuperRestrict(self):
| assertEqual = self.assertEqual
assertNotEqual = self.assertNotEqual
assertTrue = self.assertTrue
assertFalse = self.assertFalse
s3db = current.s3db
master_id = self.master_id
s3db.define_table('del_component', s3db.super_link('del_super_id', 'del_super', ondelete='RESTRICT'), *s3_meta_fields... |
'Test archiving if there are mandatory extra fields
which require a join'
| def testArchiveWithJoinedExtraFields(self):
| assertEqual = self.assertEqual
assertNotEqual = self.assertNotEqual
assertTrue = self.assertTrue
s3db = current.s3db
master_id = self.master_id
s3db.define_table('del_component', Field('del_master_id', s3db.del_master, ondelete='CASCADE'), *s3_meta_fields())
component = s3db['del_component']... |
'Test deletion of link table entry'
| def testLinkDeletion(self):
| assertEqual = self.assertEqual
assertNotEqual = self.assertNotEqual
db = current.db
resource = current.s3db.resource('link_master')
query = (FS('component.id') == self.component1)
resource.add_filter(query)
link = resource.links['link']
rfield = link.resolve_selector('component.id')
... |
'Verify alias registration of link tables'
| def testLinkTableRegistration(self):
| s3db = current.s3db
resource = s3db.resource('test_master')
assertIn = self.assertIn
assertEqual = self.assertEqual
links = resource.links
assertIn('link', links)
assertIn('parent__link', links)
parent_link = links['parent__link']
assertEqual(parent_link.fkey, 'child')
assertIn('... |
'Verify correct resolution of link table selectors'
| def testLinkTableSelectorResolution(self):
| s3db = current.s3db
resource = s3db.resource('test_master')
assertIn = self.assertIn
assertEqual = self.assertEqual
assertNotEqual = self.assertNotEqual
rfield = resource.resolve_selector('parent__link.parent')
assertEqual(rfield.tname, 'test_link')
assertEqual(rfield.fname, 'parent')
... |
'Field selector resolution without components'
| @unittest.skipIf((not current.deployment_settings.has_module('project')), 'project module disabled')
def testResolveSelectorsWithoutComponents(self):
| s3db = current.s3db
assertEqual = self.assertEqual
assertTrue = self.assertTrue
resource = s3db.resource('project_project')
selectors = ['id', 'name', 'organisation_id$name', 'task.description']
(fields, joins, left, distinct) = resource.resolve_selectors(selectors, skip_components=True)
pro... |
'Field selector resolution with components'
| @unittest.skipIf((not current.deployment_settings.has_module('project')), 'project module disabled')
def testResolveSelectorsWithComponents(self):
| s3db = current.s3db
assertEqual = self.assertEqual
assertTrue = self.assertTrue
resource = s3db.resource('project_project')
selectors = ['id', 'name', 'organisation_id$name', 'task.description']
(fields, joins, left, distinct) = resource.resolve_selectors(selectors)
project_project = resourc... |
'Verify detection of numeric types'
| def testNumeric(self):
| assertTrue = self.assertTrue
assertFalse = self.assertFalse
resource = current.s3db.resource('test_ftypes')
rfield = S3ResourceField(resource, 'name')
assertFalse(rfield.is_numeric)
rfield = S3ResourceField(resource, 'category1')
assertFalse(rfield.is_numeric)
rfield = S3ResourceField(re... |
'Verify detection of string types'
| def testString(self):
| assertTrue = self.assertTrue
assertFalse = self.assertFalse
resource = current.s3db.resource('test_ftypes')
rfield = S3ResourceField(resource, 'name')
assertTrue(rfield.is_string)
rfield = S3ResourceField(resource, 'category1')
assertTrue(rfield.is_string)
rfield = S3ResourceField(resour... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.