<s> import unittest <EOL> from gluon import current <EOL> class S3ConfigTests ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def testSetOrgDependentFields ( self ) : <EOL> """<STR_LIT>""" <EOL> auth = current . auth <EOL> s3db = current . s3db <EOL> settings = current . deployment_settings <EOL> table = current . s3db . pr_person_details <EOL> s = settings . org . get ( "<STR_LIT>" , None ) <EOL> settings . org . dependent_fields = { "<STR_LIT>" : [ "<STR_LIT>" ] } <EOL> auth . s3_impersonate ( "<STR_LIT>" ) <EOL> check = settings . set_org_dependent_field ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . assertTrue ( check ) <EOL> self . assertTrue ( table . mother_name . readable ) <EOL> self . assertTrue ( table . mother_name . writable ) <EOL> auth . s3_impersonate ( None ) <EOL> check = settings . set_org_dependent_field ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . assertFalse ( check ) <EOL> self . assertFalse ( table . mother_name . readable ) <EOL> self . assertFalse ( table . mother_name . writable ) <EOL> try : <EOL> auth . override = True <EOL> xmlstr = """<STR_LIT>""" <EOL> from lxml import etree <EOL> tree = etree . ElementTree ( etree . fromstring ( xmlstr ) ) <EOL> resource = s3db . resource ( "<STR_LIT>" ) <EOL> msg = resource . import_xml ( tree ) <EOL> resource = s3db . resource ( "<STR_LIT>" , uid = "<STR_LIT>" ) <EOL> org = resource . select ( None , as_rows = True ) [ <NUM_LIT:0> ] <EOL> auth . override = False <EOL> auth . s3_impersonate ( "<STR_LIT>" ) <EOL> check = settings . set_org_dependent_field ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . assertFalse ( check ) <EOL> self . assertFalse ( table . mother_name . readable ) <EOL> self . assertFalse ( table . mother_name . writable ) <EOL> auth . user . organisation_id = org . id <EOL> self . assertEqual ( auth . root_org ( ) , org . id ) <EOL> check = settings . set_org_dependent_field ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . assertTrue ( check ) <EOL> self . assertTrue ( table . mother_name . readable ) <EOL> self . assertTrue ( table . mother_name . writable ) <EOL> settings . org . dependent_fields = None <EOL> check = settings . set_org_dependent_field ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . assertFalse ( check ) <EOL> self . assertFalse ( table . mother_name . readable ) <EOL> self . assertFalse ( table . mother_name . writable ) <EOL> finally : <EOL> current . db . rollback ( ) <EOL> auth . s3_impersonate ( None ) <EOL> if s : <EOL> settings . org . dependent_fields = s <EOL> def run_suite ( * test_classes ) : <EOL> """<STR_LIT>""" <EOL> loader = unittest . TestLoader ( ) <EOL> suite = unittest . TestSuite ( ) <EOL> for test_class in test_classes : <EOL> tests = loader . loadTestsFromTestCase ( test_class ) <EOL> suite . addTests ( tests ) <EOL> if suite is not None : <EOL> unittest . TextTestRunner ( verbosity = <NUM_LIT:2> ) . run ( suite ) <EOL> return <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> run_suite ( <EOL> S3ConfigTests , <EOL> ) </s>
