Re: [Freeipa-devel] [PATCH] jderose 029 host and hostgroup messages, tests

2009-12-14 Thread Jason Gerard DeRose
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 
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 000..58a3671
--- /dev/null
+++ b/tests/test_xmlrpc/objectclasses.py
@@ -0,0 +1,40 @@
+# Authors:
+#   Jason Gerard DeRose 
+#
+# 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 
 #   Pavel Zuna 
 #
-# 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_equa

[Freeipa-devel] [PATCH] jderose 029 host and hostgroup messages, tests

2009-12-14 Thread Jason Gerard DeRose
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-jderose-029-host-hostgroup.pach
Description: application/mbox
___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel