'Create an Organisation
@param items: Organisation(s) to create from the data
@ToDo: currently optimised for a single record
@TestDoc: https://docs.google.com/spreadsheet/ccc?key=0AmB3hMcgB-3idG1XNGhhRG9QWF81dUlKLXpJaFlCMFE
@Test Wiki: http://eden.sahanafoundation.org/wiki/DeveloperGuidelines/Testing'

def test_org001_create_organisation(self, items=[0]):

    settings = current.deployment_settings
    tablename = 'org_organisation'
    url = 'org/organisation/create'
    account = 'admin'
    data = [[('name', 'Romanian    Food    Assistance    Association    (Test)'), ('acronym', 'RFAAT'), ('organisation_type_id', 'Government'), ('website', 'http://www.rfaat.com'), ('comments', 'This    is    a    Test    Organization')]]
    if settings.get_org_regions():
        data[0].append(('region_id', 'Europe'))
    db = current.db
    s3db = current.s3db
    table = s3db[tablename]
    for item in items:
        _data = data[item]
        fieldname = _data[0][0]
        value = _data[0][1]
        query = ((table[fieldname] == value) & (table.deleted == 'F'))
        record = db(query).select(table.id, limitby=(0, 1)).first()
        if record:
            debug = ('org_create_organisation    skipped    as    %s    already    exists    in    the    db\n' % value)
            print debug
            self.s3_debug(debug)
            return False
        self.login(account=account, nexturl=url)
        result = self.create(tablename, _data)
