I attached this again in case the incorrect ".pach" extension caused
problems for anyone.

On Mon, 2009-12-14 at 13:37 -0700, Jason Gerard DeRose wrote:
> This patch:
> 
>   * Adds correct translatable `msg_summary` attributes on the host and
> hostgroup plugins
> 
>   * Rewrites the host and hostgroup unit tests as `Declarative` based
> tests and expands there coverage somewhat
> 
>   * Adds new tests.test_xmlrpc.objectclasses module where we can define
> the expected object classes is a single location
> _______________________________________________
> Freeipa-devel mailing list
> Freeipa-devel@redhat.com
> https://www.redhat.com/mailman/listinfo/freeipa-devel
>From 4b21511db40515af35884bfab82ada72ace79c5e Mon Sep 17 00:00:00 2001
From: Jason Gerard DeRose <jder...@redhat.com>
Date: Mon, 14 Dec 2009 13:25:12 -0700
Subject: [PATCH] host and hostgroup summary messages, declarative tests

---
 ipalib/plugins/hostgroup.py                |   17 +-
 tests/test_xmlrpc/objectclasses.py         |   40 ++++
 tests/test_xmlrpc/test_host_plugin.py      |  325 +++++++++++++++++++--------
 tests/test_xmlrpc/test_hostgroup_plugin.py |  336 ++++++++++++++++++----------
 4 files changed, 498 insertions(+), 220 deletions(-)
 create mode 100644 tests/test_xmlrpc/objectclasses.py

diff --git a/ipalib/plugins/hostgroup.py b/ipalib/plugins/hostgroup.py
index 8e5cf5f..2a13170 100644
--- a/ipalib/plugins/hostgroup.py
+++ b/ipalib/plugins/hostgroup.py
@@ -21,9 +21,8 @@
 Groups of hosts.
 """
 
-from ipalib import api
-from ipalib import Int
 from ipalib.plugins.baseldap import *
+from ipalib import api, Int, _, ngettext
 
 
 class hostgroup(LDAPObject):
@@ -50,7 +49,8 @@ class hostgroup(LDAPObject):
     takes_params = (
         Str('cn',
             cli_name='name',
-            doc='group name',
+            doc='host group name',
+            label='Host Group Name',
             primary_key=True,
             normalizer=lambda value: value.lower(),
         ),
@@ -68,6 +68,8 @@ class hostgroup_add(LDAPCreate):
     Create new hostgroup.
     """
 
+    msg_summary = _('Added hostgroup "%(value)s"')
+
 api.register(hostgroup_add)
 
 
@@ -76,6 +78,8 @@ class hostgroup_del(LDAPDelete):
     Delete hostgroup.
     """
 
+    msg_summary = _('Deleted hostgroup "%(value)s"')
+
 api.register(hostgroup_del)
 
 
@@ -84,6 +88,8 @@ class hostgroup_mod(LDAPUpdate):
     Modify hostgroup.
     """
 
+    msg_summary = _('Modified hostgroup "%(value)s"')
+
 api.register(hostgroup_mod)
 
 
@@ -92,6 +98,10 @@ class hostgroup_find(LDAPSearch):
     Search for hostgroups.
     """
 
+    msg_summary = ngettext(
+        '%(count)d hostgroup matched', '%(count)d hostgroups matched'
+    )
+
 api.register(hostgroup_find)
 
 
@@ -117,4 +127,3 @@ class hostgroup_remove_member(LDAPRemoveMember):
     """
 
 api.register(hostgroup_remove_member)
-
diff --git a/tests/test_xmlrpc/objectclasses.py b/tests/test_xmlrpc/objectclasses.py
new file mode 100644
index 0000000..58a3671
--- /dev/null
+++ b/tests/test_xmlrpc/objectclasses.py
@@ -0,0 +1,40 @@
+# Authors:
+#   Jason Gerard DeRose <jder...@redhat.com>
+#
+# Copyright (C) 2008  Red Hat
+# see file 'COPYING' for use and warranty information
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; version 2 only
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+"""
+Defines the expected objectclass for various entries.
+"""
+
+host = (
+    u'ipaobject',
+    u'nshost',
+    u'ipahost',
+    u'pkiuser',
+    u'krbprincipalaux',
+    u'krbprincipal',
+    u'top',
+)
+
+hostgroup = (
+    u'ipaobject',
+    u'ipahostgroup',
+    u'nestedGroup',
+    u'groupOfNames',
+    u'top',
+)
diff --git a/tests/test_xmlrpc/test_host_plugin.py b/tests/test_xmlrpc/test_host_plugin.py
index 009e98e..6bb6277 100644
--- a/tests/test_xmlrpc/test_host_plugin.py
+++ b/tests/test_xmlrpc/test_host_plugin.py
@@ -2,7 +2,7 @@
 #   Rob Crittenden <rcrit...@redhat.com>
 #   Pavel Zuna <pz...@redhat.com>
 #
-# Copyright (C) 2008  Red Hat
+# Copyright (C) 2008, 2009  Red Hat
 # see file 'COPYING' for use and warranty information
 #
 # This program is free software; you can redistribute it and/or
@@ -17,105 +17,230 @@
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
 """
-Test the `ipalib/plugins/host.py` module.
+Test the `ipalib.plugins.host` module.
 """
 
-import sys
-from xmlrpc_test import XMLRPC_test, assert_attr_equal
-from ipalib import api
-from ipalib import errors
-
-
-class test_host(XMLRPC_test):
-    """
-    Test the `host` plugin.
-    """
-    fqdn = u'ipatesthost.%s' % api.env.domain
-    description = u'Test host'
-    localityname = u'Undisclosed location'
-    kw = {'fqdn': fqdn, 'description': description, 'localityname': localityname, 'raw': True}
-
-    def test_1_host_add(self):
-        """
-        Test the `xmlrpc.host_add` method.
-        """
-        res = api.Command['host_add'](**self.kw)['result']
-        assert type(res) is dict
-        assert_attr_equal(res, 'description', self.description)
-        assert_attr_equal(res, 'fqdn', self.fqdn)
-        assert_attr_equal(res, 'localityname', self.localityname)
-        assert_attr_equal(res, 'objectclass', 'ipaobject')
-
-    def test_2_host_show(self):
-        """
-        Test the `xmlrpc.host_show` method with all attributes.
-        """
-        kw = {'fqdn': self.fqdn, 'all': True, 'raw': True}
-        res = api.Command['host_show'](**kw)['result']
-        assert res
-        assert_attr_equal(res, 'description', self.description)
-        assert_attr_equal(res, 'fqdn', self.fqdn)
-        assert_attr_equal(res, 'l', self.localityname)
-
-    def test_3_host_show(self):
-        """
-        Test the `xmlrpc.host_show` method with default attributes.
-        """
-        kw = {'fqdn': self.fqdn, 'raw': True}
-        res = api.Command['host_show'](**kw)['result']
-        assert res
-        assert_attr_equal(res, 'description', self.description)
-        assert_attr_equal(res, 'fqdn', self.fqdn)
-        assert_attr_equal(res, 'localityname', self.localityname)
-
-    def test_4_host_find(self):
-        """
-        Test the `xmlrpc.host_find` method with all attributes.
-        """
-        kw = {'fqdn': self.fqdn, 'all': True, 'raw': True}
-        res = api.Command['host_find'](**kw)['result']
-        assert res
-        assert_attr_equal(res[0], 'description', self.description)
-        assert_attr_equal(res[0], 'fqdn', self.fqdn)
-        assert_attr_equal(res[0], 'l', self.localityname)
-
-    def test_5_host_find(self):
-        """
-        Test the `xmlrpc.host_find` method with default attributes.
-        """
-        res = api.Command['host_find'](self.fqdn, raw=True)['result']
-        assert res
-        assert_attr_equal(res[0], 'description', self.description)
-        assert_attr_equal(res[0], 'fqdn', self.fqdn)
-        assert_attr_equal(res[0], 'localityname', self.localityname)
-
-    def test_6_host_mod(self):
-        """
-        Test the `xmlrpc.host_mod` method.
-        """
-        newdesc = u'Updated host'
-        modkw = {'fqdn': self.fqdn, 'description': newdesc, 'raw': True}
-        res = api.Command['host_mod'](**modkw)['result']
-        assert res
-        assert_attr_equal(res, 'description', newdesc)
-
-        # Ok, double-check that it was changed
-        res = api.Command['host_show'](self.fqdn, raw=True)['result']
-        assert res
-        assert_attr_equal(res, 'description', newdesc)
-        assert_attr_equal(res, 'fqdn', self.fqdn)
-
-    def test_7_host_del(self):
-        """
-        Test the `xmlrpc.host_del` method.
-        """
-        assert api.Command['host_del'](self.fqdn)['result'] is True
-
-        # Verify that it is gone
-        try:
-            api.Command['host_show'](self.fqdn)
-        except errors.NotFound:
-            pass
-        else:
-            assert False
+from ipalib import api, errors
+from tests.test_xmlrpc.xmlrpc_test import Declarative
+from tests.test_xmlrpc import objectclasses
+
+
+fqdn1 = u'testhost1.%s' % api.env.domain
+
+
+class test_host(Declarative):
+
+    cleanup_commands = [
+        ('host_del', [fqdn1], {}),
+    ]
+
+    tests = [
+
+        dict(
+            desc='Try to retrieve non-existent %r' % fqdn1,
+            command=('host_show', [fqdn1], {}),
+            expected=errors.NotFound(reason='no such entry'),
+        ),
+
+
+        dict(
+            desc='Try to update non-existent %r' % fqdn1,
+            command=('host_mod', [fqdn1], dict(description=u'Nope')),
+            expected=errors.NotFound(reason='no such entry'),
+        ),
+
+
+        dict(
+            desc='Try to delete non-existent %r' % fqdn1,
+            command=('host_del', [fqdn1], {}),
+            expected=errors.NotFound(reason='no such entry'),
+        ),
+
+
+        dict(
+            desc='Create %r' % fqdn1,
+            command=('host_add', [fqdn1],
+                dict(
+                    description=u'Test host 1',
+                    localityname=u'Undisclosed location 1',
+                ),
+            ),
+            expected=dict(
+                value=fqdn1,
+                summary=u'Added host "%s"' % fqdn1,
+                result=dict(
+                    cn=(fqdn1,),  # FIXME: we should only return fqdn
+                    fqdn=(fqdn1,),
+                    description=(u'Test host 1',),
+                    localityname=(u'Undisclosed location 1',),
+                    krbprincipalname=(u'host/%...@%s' % (fqdn1, api.env.realm),),
+                    serverhostname=(u'testhost1',),
+                    objectclass=objectclasses.host,
+                ),
+            ),
+            ignore_values=['ipauniqueid'],
+        ),
+
+
+        dict(
+            desc='Try to create duplicate %r' % fqdn1,
+            command=('host_add', [fqdn1],
+                dict(
+                    description=u'Test host 1',
+                    localityname=u'Undisclosed location 1',
+                ),
+            ),
+            expected=errors.DuplicateEntry(),
+        ),
+
+
+        dict(
+            desc='Retrieve %r' % fqdn1,
+            command=('host_show', [fqdn1], {}),
+            expected=dict(
+                value=fqdn1,
+                summary=None,
+                result=dict(
+                    fqdn=(fqdn1,),
+                    description=(u'Test host 1',),
+                    localityname=(u'Undisclosed location 1',),
+                ),
+            ),
+            ignore_values=['dn'],
+        ),
+
+
+        dict(
+            desc='Retrieve %r with all=True' % fqdn1,
+            command=('host_show', [fqdn1], dict(all=True)),
+            expected=dict(
+                value=fqdn1,
+                summary=None,
+                result=dict(
+                    cn=(fqdn1,),
+                    fqdn=(fqdn1,),
+                    description=(u'Test host 1',),
+                    # FIXME: Why is 'localalityname' returned as 'l' with --all?
+                    # It is intuitive for --all to return additional attributes,
+                    # but not to return existing attributes under different
+                    # names.
+                    l=(u'Undisclosed location 1',),
+                    krbprincipalname=(u'host/%...@%s' % (fqdn1, api.env.realm),),
+                    serverhostname=(u'testhost1',),
+                    objectclass=objectclasses.host,
+                ),
+            ),
+            ignore_values=['dn', 'ipauniqueid'],
+        ),
+
+
+        dict(
+            desc='Search for %r' % fqdn1,
+            command=('host_find', [fqdn1], {}),
+            expected=dict(
+                count=1,
+                truncated=False,
+                summary=u'1 host matched',
+                result=(
+                    dict(
+                        fqdn=(fqdn1,),
+                        description=(u'Test host 1',),
+                        localityname=(u'Undisclosed location 1',),
+                    ),
+                ),
+            ),
+        ),
+
+
+        dict(
+            desc='Search for %r with all=True' % fqdn1,
+            command=('host_find', [fqdn1], dict(all=True)),
+            expected=dict(
+                count=1,
+                truncated=False,
+                summary=u'1 host matched',
+                result=(
+                    dict(
+                        cn=(fqdn1,),
+                        fqdn=(fqdn1,),
+                        description=(u'Test host 1',),
+                        # FIXME: Why is 'localalityname' returned as 'l' with --all?
+                        # It is intuitive for --all to return additional attributes,
+                        # but not to return existing attributes under different
+                        # names.
+                        l=(u'Undisclosed location 1',),
+                        krbprincipalname=(u'host/%...@%s' % (fqdn1, api.env.realm),),
+                        serverhostname=(u'testhost1',),
+                        objectclass=objectclasses.host,
+                    ),
+                ),
+            ),
+            # FIXME: With --all, host_show() returns the 'dn', but host_find()
+            # doesn't.
+            ignore_values=['ipauniqueid'],
+        ),
+
+
+        dict(
+            desc='Update %r' % fqdn1,
+            command=('host_mod', [fqdn1], dict(description=u'Updated host 1')),
+            expected=dict(
+                value=fqdn1,
+                summary=u'Modified host "%s"' % fqdn1,
+                result=dict(
+                    description=(u'Updated host 1',),
+                ),
+            ),
+        ),
+
+
+        dict(
+            desc='Retrieve %r to verify update' % fqdn1,
+            command=('host_show', [fqdn1], {}),
+            expected=dict(
+                value=fqdn1,
+                summary=None,
+                result=dict(
+                    fqdn=(fqdn1,),
+                    description=(u'Updated host 1',),
+                    localityname=(u'Undisclosed location 1',),
+                ),
+            ),
+            ignore_values=['dn'],
+        ),
+
+
+        dict(
+            desc='Delete %r' % fqdn1,
+            command=('host_del', [fqdn1], {}),
+            expected=dict(
+                value=fqdn1,
+                summary=u'Deleted host "%s"' % fqdn1,
+                result=True,
+            ),
+        ),
+
+
+        dict(
+            desc='Try to retrieve non-existent %r' % fqdn1,
+            command=('host_show', [fqdn1], {}),
+            expected=errors.NotFound(reason='no such entry'),
+        ),
+
+
+        dict(
+            desc='Try to update non-existent %r' % fqdn1,
+            command=('host_mod', [fqdn1], dict(description=u'Nope')),
+            expected=errors.NotFound(reason='no such entry'),
+        ),
+
+
+        dict(
+            desc='Try to delete non-existent %r' % fqdn1,
+            command=('host_del', [fqdn1], {}),
+            expected=errors.NotFound(reason='no such entry'),
+        ),
+
+    ]
diff --git a/tests/test_xmlrpc/test_hostgroup_plugin.py b/tests/test_xmlrpc/test_hostgroup_plugin.py
index 7fa227a..e20982b 100644
--- a/tests/test_xmlrpc/test_hostgroup_plugin.py
+++ b/tests/test_xmlrpc/test_hostgroup_plugin.py
@@ -2,7 +2,7 @@
 #   Rob Crittenden <rcrit...@redhat.com>
 #   Pavel Zuna <pz...@redhat.com>
 #
-# Copyright (C) 2008  Red Hat
+# Copyright (C) 2008, 2009  Red Hat
 # see file 'COPYING' for use and warranty information
 #
 # This program is free software; you can redistribute it and/or
@@ -17,121 +17,225 @@
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
 """
-Test the `ipalib/plugins/hostgroup.py` module.
+Test the `ipalib.plugins.hostgroup` module.
 """
 
-import sys
-from xmlrpc_test import XMLRPC_test, assert_attr_equal
-from ipalib import api
-from ipalib import errors
-
-
-class test_hostgroup(XMLRPC_test):
-    """
-    Test the `hostgroup` plugin.
-    """
-    cn = u'testgroup'
-    description = u'Test host group'
-    kw = {'cn': cn, 'description': description, 'raw': True}
-
-    host_fqdn = u'ipatesthost.%s' % api.env.domain
-    host_description = u'Test host'
-    host_localityname = u'Undisclosed location'
-
-    def test_1_hostgroup_add(self):
-        """
-        Test the `xmlrpc.hostgroup_add` method.
-        """
-        entry = api.Command['hostgroup_add'](**self.kw)['result']
-        assert_attr_equal(entry, 'description', self.description)
-        assert_attr_equal(entry, 'cn', self.cn)
-        assert_attr_equal(entry, 'objectclass', 'ipaobject')
-
-    def test_2_host_add(self):
-        """
-        Add a host to test add/remove member.
-        """
-        kw = {'fqdn': self.host_fqdn, 'description': self.host_description, 'localityname': self.host_localityname, 'raw': True}
-        entry = api.Command['host_add'](**kw)['result']
-        assert_attr_equal(entry, 'description', self.host_description)
-        assert_attr_equal(entry, 'fqdn', self.host_fqdn)
-
-    def test_3_hostgroup_add_member(self):
-        """
-        Test the `xmlrpc.hostgroup_add_member` method.
-        """
-        kw = {'raw': True}
-        kw['host'] = self.host_fqdn
-        ret = api.Command['hostgroup_add_member'](self.cn, **kw)
-        assert ret['result']['member'] != []
-        assert ret['completed'] == 1
-
-    def test_4_hostgroup_show(self):
-        """
-        Test the `xmlrpc.hostgroup_show` method.
-        """
-        entry = api.Command['hostgroup_show'](self.cn, raw=True)['result']
-        assert_attr_equal(entry, 'description', self.description)
-        assert_attr_equal(entry, 'cn', self.cn)
-
-    def test_5_hostgroup_find(self):
-        """
-        Test the `xmlrpc.hostgroup_find` method.
-        """
-        ret = api.Command['hostgroup_find'](cn=self.cn, raw=True)
-        assert ret['truncated'] is False
-        entries = ret['result']
-        assert_attr_equal(entries[0], 'description', self.description)
-        assert_attr_equal(entries[0], 'cn', self.cn)
-
-    def test_6_hostgroup_mod(self):
-        """
-        Test the `xmlrpc.hostgroup_mod` method.
-        """
-        newdesc = u'Updated host group'
-        modkw = {'cn': self.cn, 'description': newdesc, 'raw': True}
-        entry = api.Command['hostgroup_mod'](**modkw)['result']
-        assert_attr_equal(entry, 'description', newdesc)
-
-        # Ok, double-check that it was changed
-        entry = api.Command['hostgroup_show'](self.cn, raw=True)['result']
-        assert_attr_equal(entry, 'description', newdesc)
-        assert_attr_equal(entry, 'cn', self.cn)
-
-    def test_7_hostgroup_remove_member(self):
-        """
-        Test the `xmlrpc.hostgroup_remove_member` method.
-        """
-        kw = {'raw': True}
-        kw['host'] = self.host_fqdn
-        ret = api.Command['hostgroup_remove_member'](self.cn, **kw)
-        assert ret['completed'] == 1
-
-    def test_8_hostgroup_del(self):
-        """
-        Test the `xmlrpc.hostgroup_del` method.
-        """
-        assert api.Command['hostgroup_del'](self.cn)['result'] is True
-
-        # Verify that it is gone
-        try:
-            api.Command['hostgroup_show'](self.cn)
-        except errors.NotFound:
-            pass
-        else:
-            assert False
-
-    def test_9_host_del(self):
-        """
-        Test the `xmlrpc.host_del` method.
-        """
-        assert api.Command['host_del'](self.host_fqdn)['result'] is True
-
-        # Verify that it is gone
-        try:
-            api.Command['host_show'](self.host_fqdn)
-        except errors.NotFound:
-            pass
-        else:
-            assert False
+from ipalib import api, errors
+from tests.test_xmlrpc.xmlrpc_test import Declarative
+from tests.test_xmlrpc import objectclasses
+
+
+fqdn1 = u'testhost1.%s' % api.env.domain
+
+
+class test_hostgroup(Declarative):
+
+    cleanup_commands = [
+        ('hostgroup_del', [u'testhostgroup1'], {}),
+        ('host_del', [fqdn1], {}),
+    ]
+
+    tests=[
+
+        dict(
+            desc='Try to retrieve non-existent testhostgroup1',
+            command=('hostgroup_show', [u'testhostgroup1'], {}),
+            expected=errors.NotFound(reason='no such entry'),
+        ),
+
+
+        dict(
+            desc='Try to update non-existent testhostgroup1',
+            command=('hostgroup_mod', [u'testhostgroup1'],
+                dict(description=u'Updated hostgroup 1')
+            ),
+            expected=errors.NotFound(reason='no such entry'),
+        ),
+
+
+        dict(
+            desc='Try to delete non-existent testhostgroup1',
+            command=('hostgroup_del', [u'testhostgroup1'], {}),
+            expected=errors.NotFound(reason='no such entry'),
+        ),
+
+
+        dict(
+            desc='Create hostgroup testhostgroup1',
+            command=('hostgroup_add', [u'testhostgroup1'],
+                dict(description=u'Test hostgroup 1')
+            ),
+            expected=dict(
+                value=u'testhostgroup1',
+                summary=u'Added hostgroup "testhostgroup1"',
+                result=dict(
+                    cn=(u'testhostgroup1',),
+                    objectclass=objectclasses.hostgroup,
+                    description=(u'Test hostgroup 1',),
+                ),
+            ),
+            ignore_values=['ipauniqueid'],
+        ),
+
+
+        dict(
+            desc='Try to create duplicate testhostgroup1',
+            command=('hostgroup_add', [u'testhostgroup1'],
+                dict(description=u'Test hostgroup 1')
+            ),
+            expected=errors.DuplicateEntry(),
+        ),
+
+
+        dict(
+            desc='Create host %r' % fqdn1,
+            command=('host_add', [fqdn1],
+                dict(
+                    description=u'Test host 1',
+                    localityname=u'Undisclosed location 1',
+                ),
+            ),
+            expected=dict(
+                value=fqdn1,
+                summary=u'Added host "%s"' % fqdn1,
+                result=dict(
+                    cn=(fqdn1,),  # FIXME: we should only return fqdn
+                    fqdn=(fqdn1,),
+                    description=(u'Test host 1',),
+                    localityname=(u'Undisclosed location 1',),
+                    krbprincipalname=(u'host/%...@%s' % (fqdn1, api.env.realm),),
+                    serverhostname=(u'testhost1',),
+                    objectclass=objectclasses.host,
+                ),
+            ),
+            ignore_values=['ipauniqueid'],
+        ),
+
+
+        dict(
+            desc=u'Add %r to testhostgroup1' % fqdn1,
+            command=(
+                'hostgroup_add_member', [u'testhostgroup1'], dict(host=fqdn1)
+            ),
+            expected=dict(
+                completed=1,
+                failed=dict(
+                    member=dict(
+                        host=tuple(),
+                        hostgroup=tuple(),
+                    ),
+                ),
+                result={
+                    'member host': (fqdn1,),
+                },
+            ),
+        ),
+
+
+        dict(
+            desc='Retrieve testhostgroup1',
+            command=('hostgroup_show', [u'testhostgroup1'], {}),
+            expected=dict(
+                value=u'testhostgroup1',
+                summary=None,
+                result={
+                    'member host': (u'testhost1.example.com',),
+                    'cn': (u'testhostgroup1',),
+                    'description': (u'Test hostgroup 1',)
+                },
+            ),
+            ignore_values=['dn'],
+        ),
+
+
+        dict(
+            desc='Search for testhostgroup1',
+            command=('hostgroup_find', [], dict(cn=u'testhostgroup1')),
+            expected=dict(
+                count=1,
+                truncated=False,
+                summary=u'1 hostgroup matched',
+                result=(
+                    {
+                        'member host': (u'testhost1.example.com',),
+                        'cn': (u'testhostgroup1',),
+                        'description': (u'Test hostgroup 1',),
+                    },
+                ),
+            ),
+        ),
+
+
+        dict(
+            desc='Update testhostgroup1',
+            command=('hostgroup_mod', [u'testhostgroup1'],
+                dict(description=u'Updated hostgroup 1')
+            ),
+            expected=dict(
+                value=u'testhostgroup1',
+                summary=u'Modified hostgroup "testhostgroup1"',
+                result=dict(
+                    description=(u'Updated hostgroup 1',),
+                ),
+            ),
+        ),
+
+
+        dict(
+            desc='Retrieve testhostgroup1 to verify update',
+            command=('hostgroup_show', [u'testhostgroup1'], {}),
+            expected=dict(
+                value=u'testhostgroup1',
+                summary=None,
+                result={
+                    'member host': (u'testhost1.example.com',),
+                    'cn': (u'testhostgroup1',),
+                    'description': (u'Updated hostgroup 1',)
+                },
+            ),
+            ignore_values=['dn'],
+        ),
+
+
+        dict(
+            desc='Remove %s from testhostgroup1',
+            command=('hostgroup_remove_member', [u'testhostgroup1'],
+                dict(host=fqdn1)
+            ),
+            expected=dict(
+                failed=dict(
+                    member=dict(
+                        host=tuple(),
+                        hostgroup=tuple(),
+                    ),
+                ),
+                completed=1,
+                result={},
+            ),
+        ),
+
+
+        dict(
+            desc='Delete testhostgroup1',
+            command=('hostgroup_del', [u'testhostgroup1'], {}),
+            expected=dict(
+                value=u'testhostgroup1',
+                summary=u'Deleted hostgroup "testhostgroup1"',
+                result=True,
+            ),
+        ),
+
+
+        dict(
+            desc='Delete %s' % fqdn1,
+            command=('host_del', [fqdn1], {}),
+            expected=dict(
+                value=fqdn1,
+                summary=u'Deleted host "%s"' % fqdn1,
+                result=True,
+            ),
+        )
+
+    ]
-- 
1.6.3.3

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to