def _test_resource_ops(self, resource, test_identity_attributes,
                           test_required_attributes, test_search_attributes,
                           test_update_attributes, test_default_values,
                           test_dn, res_command):
        """Test basic operations for resources

        :param resource: resource type, eg: BridgeDomain
        :param test_identity_attributes: dictionary with test identity values
        eg: {'tenant_rn': 'foo', 'rn': 'bar'}
        :param test_required_attributes: dictionary with attributes required
        by the DB for successful object creation.
        :param test_search_attributes: dictionary with test search attributes,
        needs to be one/more of the resource's other_attributes suitable for
        search. eg: {'vrf_rn': 'shared'}
        :param test_update_attributes: some attributes already present in
        one of the previously specified ones that hold a different value.
        :param test_default_values: dictionary of default values to verify
        after object has been created
        :param test_dn: expected DN of created resource, if any.
        :return:
        """
        # Run the following only if ID attributes are also required
        if not (set(test_identity_attributes.keys()) -
                set(test_required_attributes.keys())):
            self.run_command('manager ' + res_command + '-create', raises=True)
            self.run_command('manager ' + res_command + '-update', raises=True)
            self.run_command('manager ' + res_command + '-delete', raises=True)
            self.run_command('manager ' + res_command + '-get', raises=True)

        creation_attributes = {}
        creation_attributes.update(test_required_attributes),
        creation_attributes.update(test_identity_attributes)

        # Verify successful creation
        r1 = self.create(res_command, creation_attributes)
        for k, v in creation_attributes.iteritems():
            self.assertEqual(v, test_aim_manager.getattr_canonical(r1, k))

        id_attr_val = {
            k: v
            for k, v in test_identity_attributes.iteritems()
            if k in r1.identity_attributes
        }
        # Verify get
        r1 = self.get(res_command, id_attr_val)
        for k, v in creation_attributes.iteritems():
            self.assertEqual(v, test_aim_manager.getattr_canonical(r1, k))

        # Test update
        updates = {}
        updates.update(id_attr_val)
        updates.update(test_update_attributes)
        r1 = self.update(res_command, updates)
        for k, v in test_update_attributes.iteritems():
            self.assertEqual(v, test_aim_manager.getattr_canonical(r1, k))

        # Test delete
        self.delete(res_command, id_attr_val)
        self.assertIsNone(self.get(res_command, id_attr_val))
    def _test_resource_ops(self, resource, test_identity_attributes,
                           test_required_attributes, test_search_attributes,
                           test_update_attributes,
                           test_default_values,
                           test_dn, res_command):
        """Test basic operations for resources

        :param resource: resource type, eg: BridgeDomain
        :param test_identity_attributes: dictionary with test identity values
        eg: {'tenant_rn': 'foo', 'rn': 'bar'}
        :param test_required_attributes: dictionary with attributes required
        by the DB for successful object creation.
        :param test_search_attributes: dictionary with test search attributes,
        needs to be one/more of the resource's other_attributes suitable for
        search. eg: {'vrf_rn': 'shared'}
        :param test_update_attributes: some attributes already present in
        one of the previously specified ones that hold a different value.
        :param test_default_values: dictionary of default values to verify
        after object has been created
        :param test_dn: expected DN of created resource, if any.
        :return:
        """
        # Run the following only if ID attributes are also required
        if not (set(test_identity_attributes.keys()) -
                set(test_required_attributes.keys())):
            self.run_command('manager ' + res_command + '-create', raises=True)
            self.run_command('manager ' + res_command + '-update', raises=True)
            self.run_command('manager ' + res_command + '-delete', raises=True)
            self.run_command('manager ' + res_command + '-get', raises=True)
            self.run_command('manager ' + res_command + '-show', raises=True)

        creation_attributes = {}
        creation_attributes.update(test_required_attributes),
        creation_attributes.update(test_identity_attributes)

        # Verify successful creation
        r1 = self.create(res_command, creation_attributes)
        for k, v in creation_attributes.iteritems():
            self.assertEqual(v, test_aim_manager.getattr_canonical(r1, k))

        id_attr_val = {k: v for k, v in test_identity_attributes.iteritems()
                       if k in r1.identity_attributes}
        # Verify get
        r1 = self.get(res_command, id_attr_val)
        for k, v in creation_attributes.iteritems():
            self.assertEqual(v, test_aim_manager.getattr_canonical(r1, k))

        # Verify show
        r1 = self.show(res_command, id_attr_val)
        for k, v in creation_attributes.iteritems():
            self.assertEqual(v, test_aim_manager.getattr_canonical(r1, k))

        # Test update
        updates = {}
        updates.update(id_attr_val)
        updates.update(test_update_attributes)
        r1 = self.update(res_command, updates)
        for k, v in test_update_attributes.iteritems():
            self.assertEqual(v, test_aim_manager.getattr_canonical(r1, k))

        # Test delete
        self.delete(res_command, id_attr_val)
        self.assertIsNone(self.get(res_command, id_attr_val))
        self.assertIsNone(self.show(res_command, id_attr_val))