URL: https://github.com/freeipa/freeipa/pull/181 Author: gkaihorodova Title: #181: Tests : User Tracker creation of user with minimal values Action: synchronized
To pull the PR as Git branch: git remote add ghfreeipa https://github.com/freeipa/freeipa git fetch ghfreeipa pull/181/head:pr181 git checkout pr181
From 65608285943b7c0a43dfc9e28a81e23ff58bdabc Mon Sep 17 00:00:00 2001 From: Ganna Kaihorodova <gkaih...@redhat.com> Date: Mon, 24 Oct 2016 11:27:01 +0200 Subject: [PATCH] User Tracker: creation of user with minimal values Fix provide possibility to create user-add test with minimal values, where uid is not specified, to provide better coverage. Also provide check for non-empty unicode string for attributes required in init method https://fedorahosted.org/freeipa/ticket/6126 --- ipatests/test_xmlrpc/tracker/user_plugin.py | 40 +++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/ipatests/test_xmlrpc/tracker/user_plugin.py b/ipatests/test_xmlrpc/tracker/user_plugin.py index 4485fd9..669b9bb 100644 --- a/ipatests/test_xmlrpc/tracker/user_plugin.py +++ b/ipatests/test_xmlrpc/tracker/user_plugin.py @@ -62,22 +62,40 @@ class UserTracker(KerberosAliasMixin, Tracker): primary_keys = {u'uid', u'dn'} - def __init__(self, name, givenname, sn, **kwargs): + def __init__(self, name=None, givenname=None, sn=None, **kwargs): + """ Check for non-empty unicode string for the required attributes + in the init method """ + + if not isinstance(givenname, (str, unicode)) and len(givenname) > 0: + raise ValueError("No name provided: %s" % givenname) + if not isinstance(sn, (str, unicode)) and len(sn) > 0: + raise ValueError("No name provided: %s" % sn) + super(UserTracker, self).__init__(default_version=None) - self.uid = name - self.givenname = givenname - self.sn = sn + self.uid = unicode(name) + self.givenname = unicode(givenname) + self.sn = unicode(sn) self.dn = DN(('uid', self.uid), api.env.container_user, api.env.basedn) self.kwargs = kwargs - def make_create_command(self): - """ Make function that crates a user using user-add """ - return self.make_command( - 'user_add', self.uid, - givenname=self.givenname, - sn=self.sn, **self.kwargs - ) + def make_create_command(self, force=None): + + """ Make function that creates a user using user-add + with all set of attributes and with minimal values, + where uid is not specified """ + + if self.uid is not None: + return self.make_command( + 'user_add', self.uid, + givenname=self.givenname, + sn=self.sn, **self.kwargs + ) + else: + return self.make_command( + 'user_add', givenname=self.givenname, + sn=self.sn, **self.kwargs + ) def make_delete_command(self, no_preserve=True, preserve=False): """ Make function that deletes a user using user-del """
-- Manage your subscription for the Freeipa-devel mailing list: https://www.redhat.com/mailman/listinfo/freeipa-devel Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code