def test_edit_repository(self, appliance, repository, from_collection): """Tests editing repositories using REST API. Metadata: test_flag: rest """ new_description = "Test Repository {}".format(fauxfactory.gen_alphanumeric(5)) if from_collection: repository.reload() repository_data_edited = { "href": repository.href, "description": new_description, } appliance.rest_api.collections.configuration_script_sources.action.edit( repository_data_edited) else: repository.action.edit(description=new_description) assert_response(appliance) record, __ = wait_for( lambda: appliance.rest_api.collections.configuration_script_sources.find_by( description=new_description) or False, num_sec=180, delay=10, ) repository.reload() assert repository.description == record[0].description
def test_edit_tags(self, appliance, tags): """Tests tags editing from collection. Metadata: test_flag: rest """ collection = appliance.rest_api.collections.tags tags_len = len(tags) tags_data_edited = [] for tag in tags: tags_data_edited.append({ "href": tag.href, "name": "test_tag_{}".format(fauxfactory.gen_alphanumeric().lower()), }) edited = collection.action.edit(*tags_data_edited) assert_response(appliance, results_num=tags_len) for index in range(tags_len): record, _ = wait_for(lambda: collection.find_by(name="%/{}".format( tags_data_edited[index]["name"])) or False, num_sec=180, delay=10) assert record[0].id == edited[index].id assert record[0].name == edited[index].name
def test_edit_blueprints(self, appliance, blueprints, from_detail): """Tests editing of blueprints. Metadata: test_flag: rest """ response_len = len(blueprints) new = [{ 'ui_properties': { 'automate_entrypoints': { 'Reconfigure': 'foo' } } } for _ in range(response_len)] if from_detail: edited = [] for i in range(response_len): edited.append(blueprints[i].action.edit(**new[i])) assert_response(appliance) else: for i in range(response_len): new[i].update(blueprints[i]._ref_repr()) edited = appliance.rest_api.collections.blueprints.action.edit( *new) assert_response(appliance) assert len(edited) == response_len for i in range(response_len): assert edited[i].ui_properties == new[i]['ui_properties'] blueprints[i].reload() assert blueprints[i].ui_properties == new[i]['ui_properties']
def test_edit_conditions(self, conditions, appliance, from_detail): """Tests edit conditions. Metadata: test_flag: rest """ num_conditions = len(conditions) uniq = [fauxfactory.gen_alphanumeric(5) for _ in range(num_conditions)] new = [{ 'description': 'Edited Test Condition {}'.format(u) } for u in uniq] if from_detail: edited = [] for index in range(num_conditions): edited.append(conditions[index].action.edit(**new[index])) assert_response(appliance) else: for index in range(num_conditions): new[index].update(conditions[index]._ref_repr()) edited = appliance.rest_api.collections.conditions.action.edit( *new) assert_response(appliance) assert len(edited) == num_conditions for index, condition in enumerate(conditions): record, __ = wait_for( lambda: appliance.rest_api.collections.conditions.find_by( description=new[index]['description']) or False, num_sec=100, delay=5, ) condition.reload() assert condition.description == edited[ index].description == record[0].description
def test_bulk_assign_and_unassign_invalid_tag(self, appliance, dummy_services, vm, collection_name): """Tests bulk assigning and unassigning invalid tags. Metadata: test_flag: rest """ collection = getattr(appliance.rest_api.collections, collection_name) collection.reload() if len(collection) > 1: entities = [collection[-2], collection[-1]] # slice notation doesn't work here else: entities = [collection[-1]] new_tags = ['invalid_tag1', 'invalid_tag2'] tags_count = len(new_tags) * len(entities) tags_per_entities_count = [] for entity in entities: entity.tags.reload() tags_per_entities_count.append(entity.tags.subcount) def _check_tags_counts(): for index, entity in enumerate(entities): entity.tags.reload() assert entity.tags.subcount == tags_per_entities_count[index] collection.action.assign_tags(*entities, tags=new_tags) assert_response(appliance, success=False, results_num=tags_count) _check_tags_counts() collection.action.unassign_tags(*entities, tags=new_tags) assert_response(appliance, success=False, results_num=tags_count) _check_tags_counts()
def test_assign_unassign_service_template_to_service_catalog( self, appliance, service_catalogs, service_templates): """Tests assigning and unassigning the service templates to service catalog. Prerequisities: * An appliance with ``/api`` available. Steps: * POST /api/service_catalogs/<id>/service_templates (method ``assign``) with the list of dictionaries service templates list * Check if the service_templates were assigned to the service catalog * POST /api/service_catalogs/<id>/service_templates (method ``unassign``) with the list of dictionaries service templates list * Check if the service_templates were unassigned to the service catalog Metadata: test_flag: rest """ stpl = service_templates[0] scl = service_catalogs[0] unassign_templates([stpl]) scl.service_templates.action.assign(stpl) assert_response(appliance) scl.reload() stpl.reload() assert stpl.id in [st.id for st in scl.service_templates.all] assert stpl.service_template_catalog_id == scl.id scl.service_templates.action.unassign(stpl) assert_response(appliance) scl.reload() assert stpl.id not in [st.id for st in scl.service_templates.all] # load data again so we get rid of attributes that are no longer there stpl = appliance.rest_api.collections.service_templates.get(id=stpl.id) assert not hasattr(stpl, 'service_template_catalog_id')
def test_delete_parent_service(self, appliance): """Tests that when parent service is deleted, child service is deleted automatically. Metadata: test_flag: rest """ collection = appliance.rest_api.collections.services grandparent = collection.action.create(service_body())[0] parent = collection.action.create( service_body(parent_service={'id': grandparent.id}))[0] child = collection.action.create( service_body(parent_service={'id': parent.id}))[0] assert parent.ancestry == str(grandparent.id) assert child.ancestry == '{}/{}'.format(grandparent.id, parent.id) grandparent.action.delete() assert_response(appliance) wait_for( lambda: not appliance.rest_api.collections.services.find_by( name=grandparent.name), num_sec=600, delay=10, ) for gen in child, parent, grandparent: with error.expected("ActiveRecord::RecordNotFound"): gen.action.delete()
def _action_and_check(action, resulting_state): if from_detail: getattr(service.action, action)() else: getattr(collection.action, action)(service) assert_response(appliance) wait_for_vm_power_state(vm, resulting_state)
def test_retire_service_future(self, appliance, services, from_detail): """Test retiring a service in future. Metadata: test_flag: rest """ date = (datetime.datetime.now() + datetime.timedelta(days=5)).strftime("%Y/%m/%d") future = { "date": date, "warn": "4", } if from_detail: for service in services: service.action.retire(**future) assert_response(appliance) else: appliance.rest_api.collections.services.action.retire( *services, **future) assert_response(appliance) def _finished(service): service.reload() return hasattr(service, "retires_on") and hasattr( service, "retirement_warn") for service in services: wait_for(lambda: _finished(service), num_sec=60, delay=5)
def test_invalid_copy_orchestration_templates(self, appliance, orchestration_templates, from_detail): """Tests copying of orchestration templates without changing content. Metadata: test_flag: rest """ num_orch_templates = len(orchestration_templates) new = [] for _ in range(num_orch_templates): new.append({ "name": "test_copied_{}".format(fauxfactory.gen_alphanumeric(5)) }) if from_detail: for i in range(num_orch_templates): with error.expected("content must be unique"): orchestration_templates[i].action.copy(**new[i]) assert_response(appliance, http_status=400) else: for i in range(num_orch_templates): new[i].update(orchestration_templates[i]._ref_repr()) with error.expected("content must be unique"): appliance.rest_api.collections.orchestration_templates.action.copy( *new) assert_response(appliance, http_status=400)
def test_sorting_by_attributes(appliance): """Test that it's possible to sort resources by attributes. Metadata: test_flag: rest """ url_string = '{}{}'.format( appliance.rest_api.collections.groups._href, '?expand=resources&attributes=id&sort_by=id&sort_order={}') response_asc = appliance.rest_api.get(url_string.format('asc')) assert_response(appliance) assert 'resources' in response_asc response_desc = appliance.rest_api.get(url_string.format('desc')) assert_response(appliance) assert 'resources' in response_desc assert response_asc['subcount'] == response_desc['subcount'] id_last = 0 for resource in response_asc['resources']: assert resource['id'] > id_last id_last = resource['id'] id_last += 1 for resource in response_desc['resources']: assert resource['id'] < id_last id_last = resource['id']
def test_edit_multiple_service_templates(self, appliance, service_templates): """Tests editing multiple service templates at time. Prerequisities: * An appliance with ``/api`` available. Steps: * POST /api/service_templates (method ``edit``) with the list of dictionaries used to edit * Check if the service_templates with ``new_name`` each exists Metadata: test_flag: rest """ new_names = [] service_tpls_data_edited = [] for tpl in service_templates: new_name = fauxfactory.gen_alphanumeric() new_names.append(new_name) service_tpls_data_edited.append({ "href": tpl.href, "name": new_name, }) response = appliance.rest_api.collections.service_templates.action.edit( *service_tpls_data_edited) assert_response(appliance) for i, resource in enumerate(response): assert resource.name == new_names[i] service_template = service_templates[i] service_template.reload() assert service_template.name == new_names[i]
def vm_snapshot(appliance, collection, vm_obj): """Creates VM/instance snapshot using REST API Returns: Tuple with VM and snapshot resources in REST API """ uid = fauxfactory.gen_alphanumeric(8) snap_name = 'snpshot_{}'.format(uid) vm = collection.get(name=vm_obj.name) vm.snapshots.action.create( name=snap_name, description='snapshot {}'.format(uid), memory=False) assert_response(appliance) snap, __ = wait_for( lambda: vm.snapshots.find_by(name=snap_name) or False, num_sec=600, delay=5) snap = snap[0] yield vm, snap collection.reload() to_delete = vm.snapshots.find_by(name=snap_name) if to_delete: vm.snapshots.action.delete(to_delete[0])
def test_edit_arbitration_settings(self, appliance, arbitration_settings, from_detail): """Tests edit arbitration settings. Metadata: test_flag: rest """ num_settings = len(arbitration_settings) uniq = [fauxfactory.gen_alphanumeric(5) for _ in range(num_settings)] new = [{ 'name': 'test_edit{}'.format(u), 'display_name': 'Test Edit{}'.format(u) } for u in uniq] if from_detail: edited = [] for i in range(num_settings): edited.append(arbitration_settings[i].action.edit(**new[i])) assert_response(appliance) else: for i in range(num_settings): new[i].update(arbitration_settings[i]._ref_repr()) edited = appliance.rest_api.collections.arbitration_settings.action.edit( *new) assert_response(appliance) assert len(edited) == num_settings for i in range(num_settings): assert (edited[i].name == new[i]['name'] and edited[i].display_name == new[i]['display_name'])
def test_edit_arbitration_rules(self, arbitration_rules, appliance, from_detail): """Tests edit arbitration rules. Metadata: test_flag: rest """ num_rules = len(arbitration_rules) uniq = [fauxfactory.gen_alphanumeric(5) for _ in range(num_rules)] new = [{ 'description': 'new test admin rule {}'.format(u) } for u in uniq] if from_detail: edited = [] for i in range(num_rules): edited.append(arbitration_rules[i].action.edit(**new[i])) assert_response(appliance) else: for i in range(num_rules): new[i].update(arbitration_rules[i]._ref_repr()) edited = appliance.rest_api.collections.arbitration_rules.action.edit( *new) assert_response(appliance) assert len(edited) == num_rules for i in range(num_rules): assert edited[i].description == new[i]['description']
def test_edit_orchestration_templates(self, appliance, orchestration_templates, from_detail): """Tests editing of orchestration templates. Metadata: test_flag: rest """ response_len = len(orchestration_templates) new = [{ 'description': 'Updated Test Template {}'.format(fauxfactory.gen_alphanumeric(5)) } for _ in range(response_len)] if from_detail: edited = [] for i in range(response_len): edited.append(orchestration_templates[i].action.edit(**new[i])) assert_response(appliance) else: for i in range(response_len): new[i].update(orchestration_templates[i]._ref_repr()) edited = appliance.rest_api.collections.orchestration_templates.action.edit( *new) assert_response(appliance) assert len(edited) == response_len for i in range(response_len): assert edited[i].description == new[i]['description'] orchestration_templates[i].reload() assert orchestration_templates[i].description == new[i][ 'description']
def arbitration_rules(self, request, appliance): num_rules = 2 response = _arbitration_rules(request, appliance.rest_api, num=num_rules) assert_response(appliance) assert len(response) == num_rules return response
def test_http_options(appliance): """Tests OPTIONS http method. Metadata: test_flag: rest """ assert 'boot_time' in appliance.rest_api.collections.vms.options()['attributes'] assert_response(appliance)
def test_http_options_subcollections(appliance): """Tests that OPTIONS returns supported subcollections. Metadata: test_flag: rest """ assert 'tags' in appliance.rest_api.collections.vms.options()['subcollections'] assert_response(appliance)
def orchestration_templates(self, request, appliance): num = 2 response = _orchestration_templates(request, appliance.rest_api, num=num) assert_response(appliance) assert len(response) == num return response
def test_http_options_node_types(appliance, collection_name): """Tests that OPTIONS http method on Hosts and Clusters collection returns node_types. Metadata: test_flag: rest """ collection = getattr(appliance.rest_api.collections, collection_name) assert 'node_types' in collection.options()['data'] assert_response(appliance)
def test_http_options(appliance): """Tests OPTIONS http method. Metadata: test_flag: rest """ assert 'boot_time' in appliance.rest_api.collections.vms.options( )['attributes'] assert_response(appliance)
def test_http_options_subcollections(appliance): """Tests that OPTIONS returns supported subcollections. Metadata: test_flag: rest """ assert 'tags' in appliance.rest_api.collections.vms.options( )['subcollections'] assert_response(appliance)
def test_authentications_options(self, appliance, config_manager): """Tests that credential types can be listed through OPTIONS HTTP method.. Metadata: test_flag: rest """ collection = appliance.rest_api.collections.authentications assert 'credential_types' in collection.options()['data'] assert_response(appliance)
def authentications(appliance, config_manager): """Creates and returns authentication resources under /api/authentications.""" auth_num = 2 collection = appliance.rest_api.collections.authentications user_id = appliance.rest_api.collections.users[0].id prov = appliance.rest_api.collections.providers.get(name='{} %'.format(config_manager.name)) data = [] cred_names = [] for __ in range(auth_num): uniq = fauxfactory.gen_alphanumeric(5) cred_name = 'test_credentials_{}'.format(uniq) cred_names.append(cred_name) data.append({ 'description': 'Test Description {}'.format(uniq), 'name': cred_name, 'related': {}, 'user': user_id, 'username': '******', 'password': '******', 'host': 'baz', 'type': 'ManageIQ::Providers::AnsibleTower::AutomationManager::VmwareCredential', 'manager_resource': {'href': prov.href} }) results = collection.action.create(*data) assert_response(appliance) auths = [] for cred in cred_names: search, __ = wait_for(lambda: collection.find_by(name=cred) or False, num_sec=300, delay=5) auths.append(search[0]) assert len(auths) == auth_num def _check_task(task): # TODO: https://github.com/ManageIQ/manageiq-api-client-python/pull/24 # branch below can be removed once this PR is released if isinstance(task, dict): task = appliance.rest_api.get_entity('tasks', task['task_id']) task.reload() wait_for( lambda: task.state.lower() == 'finished', fail_func=task.reload, num_sec=300, delay=5) if isinstance(results, list): for task in results: _check_task(task) else: _check_task(results) yield auths collection.reload() ids = [e.id for e in auths] delete_entities = [e for e in collection if e.id in ids] if delete_entities: collection.action.delete(*delete_entities)
def test_delete_tags_from_collection(self, appliance, tags): """Tests deleting tags from collection. Metadata: test_flag: rest """ appliance.rest_api.collections.tags.action.delete(*tags) assert_response(appliance) with error.expected("ActiveRecord::RecordNotFound"): appliance.rest_api.collections.tags.action.delete(*tags) assert_response(appliance, http_status=404)
def test_bulk_query_users(self, appliance): """Tests bulk query on 'users' collection Metadata: test_flag: rest """ data = appliance.rest_api.collections.users[0]._data response = appliance.rest_api.collections.users.action.query( {'name': data['name']}, {'userid': data['userid']}) assert_response(appliance) assert len(response) == 2 assert data['id'] == response[0]._data['id'] == response[1]._data['id']
def test_delete_service_template_post(self, appliance, service_templates): """Tests deleting service templates from detail using POST method. Metadata: test_flag: rest """ for service_template in service_templates: service_template.action.delete.POST() assert_response(appliance) with error.expected("ActiveRecord::RecordNotFound"): service_template.action.delete.POST() assert_response(appliance, http_status=404)
def test_query_simple_collections(appliance, collection_name): """This test tries to load each of the listed collections. 'Simple' collection means that they have no usable actions that we could try to run Steps: * GET /api/<collection_name> Metadata: test_flag: rest """ collection = getattr(appliance.rest_api.collections, collection_name) assert_response(appliance) collection.reload() list(collection)
def test_delete_blueprints_from_collection(self, appliance, blueprints): """Tests deleting blueprints from collection. Metadata: test_flag: rest """ collection = appliance.rest_api.collections.blueprints collection.action.delete(*blueprints) assert_response(appliance) with error.expected("ActiveRecord::RecordNotFound"): collection.action.delete(*blueprints) assert_response(appliance, http_status=404)
def test_delete_tags_from_detail(self, appliance, tags, method): """Tests deleting tags from detail. Metadata: test_flag: rest """ for tag in tags: tag.action.delete(force_method=method) assert_response(appliance) with error.expected("ActiveRecord::RecordNotFound"): tag.action.delete(force_method=method) assert_response(appliance, http_status=404)
def test_query_with_api_version(api_version, collection_name): """Loads each of the listed collections using /api/<version>/<collection>. Steps: * GET /api/<version>/<collection_name> Metadata: test_flag: rest """ collection = getattr(api_version.collections, collection_name) assert_response(api_version) collection.reload() list(collection)
def test_delete_arbitration_rules_from_collection(self, arbitration_rules, appliance): """Tests delete arbitration rules from collection. Metadata: test_flag: rest """ collection = appliance.rest_api.collections.arbitration_rules collection.action.delete(*arbitration_rules) assert_response(appliance) with error.expected('ActiveRecord::RecordNotFound'): collection.action.delete(*arbitration_rules) assert_response(appliance, http_status=404)
def test_delete_arbitration_settings_from_detail(self, appliance, arbitration_settings, method): """Tests delete arbitration settings from detail. Metadata: test_flag: rest """ for setting in arbitration_settings: setting.action.delete(force_method=method) assert_response(appliance) with error.expected('ActiveRecord::RecordNotFound'): setting.action.delete(force_method=method) assert_response(appliance, http_status=404)
def test_delete_arbitration_rules_from_detail_post(self, arbitration_rules, appliance): """Tests delete arbitration rules from detail. Metadata: test_flag: rest """ for entity in arbitration_rules: entity.action.delete.POST() assert_response(appliance) with error.expected('ActiveRecord::RecordNotFound'): entity.action.delete.POST() assert_response(appliance, http_status=404)
def test_bulk_query_groups(self, appliance): """Tests bulk query on 'groups' collection Metadata: test_flag: rest """ collection = appliance.rest_api.collections.groups data0, data1 = collection[0]._data, collection[1]._data response = appliance.rest_api.collections.groups.action.query( {'description': data0['description']}, {'description': data1['description']}) assert_response(appliance) assert len(response) == 2 assert data0 == response[0]._data and data1 == response[1]._data
def test_bulk_query_roles(self, appliance): """Tests bulk query on 'roles' collection Metadata: test_flag: rest """ collection = appliance.rest_api.collections.roles data0, data1 = collection[0]._data, collection[1]._data response = appliance.rest_api.collections.roles.action.query( {'name': data0['name']}, {'name': data1['name']}) assert_response(appliance) assert len(response) == 2 assert data0 == response[0]._data and data1 == response[1]._data
def test_create_tag_with_wrong_arguments(self, appliance): """Tests creating tags with missing category "id", "href" or "name". Metadata: test_flag: rest """ data = { "name": "test_tag_{}".format(fauxfactory.gen_alphanumeric().lower()), "description": "test_tag_{}".format(fauxfactory.gen_alphanumeric().lower()) } with error.expected("BadRequestError: Category id, href or name needs to be specified"): appliance.rest_api.collections.tags.action.create(data) assert_response(appliance, http_status=400)
def test_vm_scan(appliance, vm, from_detail): rest_vm = appliance.rest_api.collections.vms.get(name=vm) if from_detail: response = rest_vm.action.scan() else: response, = appliance.rest_api.collections.vms.action.scan(rest_vm) assert_response(appliance) @wait_for_decorator(timeout="5m", delay=5, message="REST running scanning vm finishes") def _finished(): response.task.reload() if response.task.status.lower() in {"error"}: pytest.fail("Error when running scan vm method: `{}`".format(response.task.message)) return response.task.state.lower() == 'finished'
def test_delete_notifications_from_collection(self, appliance, generate_notifications): """Tests delete notifications from collection. Metadata: test_flag: rest """ collection = appliance.rest_api.collections.notifications collection.reload() notifications = [collection[-i] for i in range(1, 3)] collection.action.delete(*notifications) assert_response(appliance) with error.expected("ActiveRecord::RecordNotFound"): collection.action.delete(*notifications) assert_response(appliance, http_status=404)
def test_bulk_query(self, appliance): """Tests bulk query referencing resources by attributes id, href and guid Metadata: test_flag: rest """ collection = appliance.rest_api.collections.events data0, data1, data2 = collection[0]._data, collection[1]._data, collection[2]._data response = appliance.rest_api.collections.events.action.query( {'id': data0['id']}, {'href': data1['href']}, {'guid': data2['guid']}) assert_response(appliance) assert len(response) == 3 assert (data0 == response[0]._data and data1 == response[1]._data and data2 == response[2]._data)
def test_resources_hiding(appliance): """Test that it's possible to hide resources in response. Metadata: test_flag: rest """ roles = appliance.rest_api.collections.roles resources_visible = appliance.rest_api.get(roles._href + '?filter[]=read_only=true') assert_response(appliance) assert 'resources' in resources_visible resources_hidden = appliance.rest_api.get( roles._href + '?filter[]=read_only=true&hide=resources') assert_response(appliance) assert 'resources' not in resources_hidden assert resources_hidden['subcount'] == resources_visible['subcount']
def test_add_picture(appliance): """Tests adding picture. Metadata: test_flag: rest """ collection = appliance.rest_api.collections.pictures count = collection.count collection.action.create({ "extension": "png", "content": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcS" "JAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg=="}) assert_response(appliance) collection.reload() assert collection.count == count + 1
def test_add_picture_invalid_data(appliance): """Tests adding picture with invalid content. Metadata: test_flag: rest """ collection = appliance.rest_api.collections.pictures count = collection.count with error.expected('invalid base64'): collection.action.create({ "extension": "png", "content": "invalid"}) assert_response(appliance, http_status=400) collection.reload() assert collection.count == count
def test_authentications_edit_single(self, appliance, authentications): """Tests editing single authentication at a time. Metadata: test_flag: rest """ new_names = [] responses = [] for auth in authentications: new_name = 'test_edited_{}'.format(fauxfactory.gen_alphanumeric().lower()) new_names.append(new_name) responses.append(auth.action.edit(name=new_name)) assert_response(appliance) assert len(responses) == len(authentications) _check_edited_authentications(appliance, authentications, new_names)
def test_delete_snapshot_from_collection(self, appliance, vm_snapshot): """Deletes VM/instance snapshot from collection using REST API Metadata: test_flag: rest """ vm, snapshot = vm_snapshot vm.snapshots.action.delete.POST(snapshot) assert_response(appliance) wait_for(lambda: not vm.snapshots.find_by(name=snapshot.name), num_sec=300, delay=5) # this will fail once BZ1466225 is fixed vm.snapshots.action.delete.POST(snapshot) assert_response(appliance, success=False)
def dummy_services(self, request, appliance): # create simple service using REST API bodies = [self.service_body() for _ in range(3)] collection = appliance.rest_api.collections.services new_services = collection.action.create(*bodies) assert_response(appliance) @request.addfinalizer def _finished(): collection.reload() ids = [service.id for service in new_services] delete_entities = [service for service in collection if service.id in ids] if delete_entities: collection.action.delete(*delete_entities) return new_services
def test_select_attributes(appliance, collection_name): """Tests that it's possible to limit returned attributes. Metadata: test_flag: rest """ if collection_name in COLLECTIONS_BUGGY_ATTRS and current_version() < '5.9': pytest.skip("Affected by BZ 1437201, cannot test.") collection = getattr(appliance.rest_api.collections, collection_name) response = appliance.rest_api.get( '{}{}'.format(collection._href, '?expand=resources&attributes=id')) assert_response(appliance) for resource in response['resources']: assert 'id' in resource expected_len = 2 if 'href' in resource else 1 assert len(resource) == expected_len
def test_add_picture_invalid_extension(appliance): """Tests adding picture with invalid extension. Metadata: test_flag: rest """ collection = appliance.rest_api.collections.pictures count = collection.count with error.expected('Extension must be'): collection.action.create({ "extension": "xcf", "content": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcS" "JAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg=="}) assert_response(appliance, http_status=400) collection.reload() assert collection.count == count
def test_delete_authentications_from_detail_delete(self, appliance, authentications): """Tests deleting authentications from detail using DELETE method. Metadata: test_flag: rest """ for auth in authentications: auth.action.delete.DELETE() assert_response(appliance) wait_for( lambda: not appliance.rest_api.collections.authentications.find_by(name=auth.name), num_sec=180, delay=5) # this will fail once BZ1476869 is fixed auth.action.delete.DELETE() assert_response(appliance, success=False)