'Set up location records'

def setUp(self):

    auth = current.auth
    auth.s3_impersonate('admin@example.com')
    s3db = current.s3db
    gtable = s3db.gis_location
    gis0 = Storage(name='Test    Country', level='L0')
    gis0_id = gtable.insert(**gis0)
    location_code = Storage()
    location_ids = Storage()
    location_code[gis0_id] = 'gis0'
    location_ids['gis0'] = gis0_id
    gis_test_data = [('gis1', 'Test    Region    1', 'L1', 'gis0'), ('gis2_1', 'Test    Province    1', 'L2', 'gis1'), ('gis2_2', 'Test    Province    2', 'L2', 'gis1'), ('gis3_1', 'Test    District    1', 'L3', 'gis2_1'), ('gis3_2', 'Test    District    2', 'L3', 'gis2_1'), ('gis3_3', 'Test    District    3', 'L3', 'gis2_1'), ('gis3_4', 'Test    District    4', 'L3', 'gis2_2'), ('gis3_5', 'Test    District    5', 'L3', 'gis2_2'), ('gis4_1', 'Test    Commune    1', 'L4', 'gis3_1'), ('gis4_2', 'Test    Commune    2', 'L4', 'gis3_1'), ('gis4_3', 'Test    Commune    3', 'L4', 'gis3_1'), ('gis4_4', 'Test    Commune    4', 'L4', 'gis3_2'), ('gis4_5', 'Test    Commune    5', 'L4', 'gis3_2'), ('gis4_6', 'Test    Commune    6', 'L4', 'gis3_3'), ('gis4_7', 'Test    Commune    7', 'L4', 'gis3_3'), ('gis4_8', 'Test    Commune    8', 'L4', 'gis3_3'), ('gis4_9', 'Test    Commune    9', 'L4', 'gis3_4'), ('gis4_10', 'Test    Commune    10', 'L4', 'gis3_4'), ('gis4_11', 'Test    Commune    11', 'L4', 'gis3_5'), ('gis4_12', 'Test    Commune    12', 'L4', 'gis3_5')]
    update_location_tree = current.gis.update_location_tree
    for location in gis_test_data:
        gis_code = location[0]
        gis_data = Storage(name=location[1], level=location[2], parent=location_ids[location[3]])
        gis_id = gtable.insert(**gis_data)
        update_location_tree(dict(id=gis_id, level=location[2]))
        location_code[gis_id] = gis_code
        location_ids[gis_code] = gis_id
    self.location_code = location_code
    self.location_ids = location_ids
    self.indicators = s3db.vulnerability_pids()
    self.resilience_id = s3db.vulnerability_resilience_id()
    self.statisticList = ['max', 'min', 'mean', 'median', 'reported_count', 'ward_count']
