def clean_scenario(transaction): # This shouldn't be needed - controller class shouln't expose flask dependent params # TODO remove args = MultiDict([ ('page_size', 10), ('page_num', 1), ('attr_format', 'both') ]) req = { 'headers': { 'authorization': generate_token() }, 'args': args, 'body': '' } params = { 'page_size': 10, 'page_num': 1, 'attr_format': 'both', 'attr': [], 'attr_type': [], 'idsOnly':'false' } token = generate_token() result = DeviceHandler.get_devices(token, params) for device in result['devices']: DeviceHandler.delete_device(device['id'], token) result = TemplateHandler.get_templates(params, token) for template in result['templates']: TemplateHandler.remove_template(template['id'], token)
def prepare_copy_psk_env(transaction): device_id = create_single_device(transaction) transaction['fullPath'] = transaction['fullPath'].replace( 'efac', device_id) DeviceHandler.gen_psk(generate_token(), device_id, 16, None) device_id = create_single_device(transaction) transaction['fullPath'] = transaction['fullPath'].replace( 'acaf', device_id)
def create_actuator_device(transaction): template_id = create_actuator_template(); if not 'proprietary' in transaction: transaction['proprietary'] = {} transaction['proprietary']['template_id'] = template_id device = { "label": "test_device", "templates": [template_id] } req = { 'headers': { 'authorization': generate_token(), 'Content-Type': 'application/json' }, 'args': { 'count': 1, 'verbose': False }, 'body': json.dumps(device) } params = { 'count': '1', 'verbose': 'False', 'content_type': 'application/json', 'data': json.dumps(device) } result = DeviceHandler.create_device(params, generate_token()) device_id = result['devices'][0]['id'] transaction['proprietary']['device_id'] = device_id return device_id
def clean_scenario(transaction): # This shouldn't be needed - controller class shouln't expose flask dependent params # TODO remove args = MultiDict([('page_size', 10), ('page_num', 1), ('attr_format', 'both')]) req = { 'headers': { 'authorization': generate_token() }, 'args': args, 'body': '' } result = DeviceHandler.get_devices(Request(req)) for device in result['devices']: DeviceHandler.delete_device(Request(req), device['id']) result = TemplateHandler.get_templates(Request(req)) for template in result['templates']: # print(template) TemplateHandler.remove_template(Request(req), template['id'])
def create_single_device(transaction): global template_id, device_id create_sample_template() device = {"label": "test_device", "templates": [template_id]} req = { 'headers': { 'authorization': generate_token(), 'Content-Type': 'application/json' }, 'args': { 'count': 1, 'verbose': False }, 'body': json.dumps(device) } result = DeviceHandler.create_device(Request(req)) device_id = result['devices'][0]['id']
def prepare_env_psk(transaction): device_id = create_device_and_update_device_id(transaction) DeviceHandler.gen_psk(generate_token(), device_id, 16, None)
def create_single_device_and_gen_psk(transaction): device_id = create_single_device(transaction) DeviceHandler.gen_psk(generate_token(), device_id, 16, None)