Coverage for tests/test_xmlrpc/xmlrpc_test : 85%
        
        
Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
| 
 # Authors: # Rob Crittenden <rcritten@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, either version 3 of the License, or # (at your option) any later version. # # 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, see <http://www.gnu.org/licenses/>. 
 Base class for all XML-RPC tests """ 
 
 
 # Matches a gidnumber like '1391016742' # FIXME: Does it make more sense to return gidnumber, uidnumber, etc. as `int` # or `long`? If not, we still need to return them as `unicode` instead of `str`. 
 # Matches an ipauniqueid like u'784d85fd-eae7-11de-9d01-54520012478b' '^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$' ) 
 # Matches netgroup dn 'ipauniqueid=[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12},cn=ng,cn=alt,%s' % api.env.basedn ) 
 # Matches a hash signature, not enforcing length 
 # Matches a date, like Tue Apr 26 17:45:35 2016 UTC 
 
 
 # Matches password - password consists of all printable characters without whitespaces # The only exception is space, but space cannot be at the beggingin or end of the pwd 
 # Matches generalized time value. Time format is: %Y%m%d%H%M%SZ 
 # match any string 
 server_available = False server_available = False 
 
 
 raise AssertionError( 'assert_attr_equal: entry must be a %r; got a %r: %r' % ( dict, type(entry), entry) ) raise AssertionError( 'assert_attr_equal: entry has no key %r: %r' % (key, entry) ) raise AssertionError( 'assert_attr_equal: %r: %r not in %r' % (key, value, entry[key]) ) 
 
 if type(entry) is not dict: raise AssertionError( 'assert_is_member: entry must be a %r; got a %r: %r' % ( dict, type(entry), entry) ) if key not in entry: raise AssertionError( 'assert_is_member: entry has no key %r: %r' % (key, entry) ) for member in entry[key]: if member.startswith(value): return raise AssertionError( 'assert_is_member: %r: %r not in %r' % (key, value, entry[key]) ) 
 
 # Initialize the API. We do this here so that one can run the tests # individually instead of at the top-level. If API.bootstrap() # has already been called we continue gracefully. Other errors will be # raised. 
 """ Base class for all XML-RPC plugin tests """ 
 def setUpClass(cls): raise nose.SkipTest('%r: Server not available: %r' % (cls.__module__, api.env.xmlrpc_uri)) 
 
 """ nose tear-down fixture. """ 
 """ Delete possible leftover entry first, then add. 
 This helps speed us up when a partial test failure has left LDAP in a dirty state. 
 :param obj: An Object like api.Object.user :param pk: The primary key of the entry to be created :param options: Kwargs to be passed to obj.add() """ 
 
 args = %r options = %r entry = %r""" 
 
 args = %r options = %r output = %r""" 
 
 args = %r options = %r %s: %s""" 
 
 args = %r options = %r kw_expected = %r kw_got = %r""" 
 
 """A declarative-style test suite 
 A Declarative test suite is controlled by the ``tests`` and ``cleanup_commands`` class variables. 
 The ``tests`` is a list of dictionaries with the following keys: 
 ``desc`` A name/description of the test ``command`` A (command, args, kwargs) triple specifying the command to run ``expected`` Can be either an ``errors.PublicError`` instance, in which case the command must fail with the given error; or the expected result. The result is checked with ``tests.util.assert_deepequal``. ``extra_check`` (optional) A checking function that is called with the response. It must return true for the test to pass. 
 The ``cleanup_commands`` is a list of (command, args, kwargs) triples. These are commands get run both before and after tests, and must not fail. """ 
 
 self.__class__.__name__, stage, i, command ) 
 raise nose.SkipTest( 'cleanup command %r not in api.Command' % cmd ) 
 """ Iterate through tests. 
 nose reports each one as a seperate test. """ 
 # Iterate through pre-cleanup: 
 # Iterate through the tests: name, i, test['command'][0], test.get('desc', '') ) 
 # Iterate through post-cleanup: 
 raise nose.SkipTest('%r not in api.Command' % cmd) else: 
 else: EXPECTED % (cmd, name, args, options, output) ) UNEXPECTED % (cmd, name, args, options, e.__class__.__name__, e) ) # FIXME: the XML-RPC transport doesn't allow us to return structured # information through the exception, so we can't test the kw on the # client side. However, if we switch to using JSON-RPC for the default # transport, the exception is a free-form data structure (dict). # For now just compare the strings 
 raise AssertionError( UNEXPECTED % (cmd, args, options, e.__class__.__name__, e) ) 
 raise AssertionError('Extra check %s failed' % extra_check)  |