def test_try_remove_all_membership_attr_values(topology): plugin = ReferentialIntegrityPlugin(topology.standalone) #setup test membership_values = plugin.get_membership_attr() assert len(membership_values) > 0 for val in membership_values[:-1]: plugin.remove_membership_attr(val) args = FakeArgs() args.value = membership_values[-1] referint_cli.remove_membership_attr(topology.standalone, None, topology.logcap.log, args) assert topology.logcap.contains("Error: Failed to delete. At least one value for membership attribute should exist.") topology.logcap.flush()
def remove_membership_attr(inst, basedn, log, args): plugin = ReferentialIntegrityPlugin(inst) try: plugin.remove_membership_attr(args.value) except ldap.OPERATIONS_ERROR: log.error( "Error: Failed to delete. At least one value for membership attribute should exist." ) except ldap.NO_SUCH_ATTRIBUTE: log.error('Error: Failed to delete. No value "{0}" found.'.format( args.value)) else: log.info('successfully removed membership attribute "{}"'.format( args.value))