Esempio n. 1
0
    os.path.join(location, '..', 'data', 'mappings', 'covered-buildings-mapping.csv'))
assert (os.path.isfile(raw_map_file)), 'Missing file ' + raw_map_file
pm_building_file = os.path.relpath(
    os.path.join(location, '..', 'data', 'portfolio-manager-sample.csv'))
assert (os.path.isfile(pm_building_file)), 'Missing file ' + pm_building_file
pm_map_file = os.path.relpath(os.path.join(location, '..', 'data', 'mappings', 'portfolio-manager-mapping.csv'))
assert (os.path.isfile(pm_map_file)), 'Missing file ' + pm_map_file

# -- Accounts
print('\n|-------Accounts-------|\n')
organization_id = account(header, main_url, username, log)
report_memory()

# -- Cycles
print('\n\n|-------Cycles-------|')
cycle_id = cycles(header, main_url, organization_id, log)
report_memory()

# Create a dataset
print('\n\n|-------Create Dataset-------|')
partmsg = 'create_dataset'
params = {'organization_id': organization_id}
payload = {'name': 'API Test'}
result = requests.post(main_url + '/api/v2/datasets/',
                       headers=header,
                       params=params,
                       data=payload)
check_status(result, partmsg, log)

# Get the dataset id to be used
dataset_id = result.json()['id']
Esempio n. 2
0
# Login user
header = {
    'authorization': ':'.join([username.lower(), api_key]),
    'Content-Type': 'application/json',
}

# -- Accounts
print ('\n\n-------Accounts-------')
id = account(header, main_url, username, log, client)
organization_id = id['org']
user_id = id['user']

# -- Cycles
print ('\n\n-------Cycles-------')
cycle_id = cycles(header, main_url, organization_id, log, client)

# Create a dataset
print ('\nAPI Function: create_dataset')
partmsg = 'create_dataset'
payload = {'name': 'API Test'}
result = client.post(main_url + '/api/v2/datasets/',
                     headers=header,
                     params={'organization_id': organization_id},
                     data=json.dumps(payload))
check_status(result, partmsg, log)

# Get the dataset id to be used
dataset_id = result.json()['id']

# Upload and test the raw building file