summaryrefslogtreecommitdiffstats
path: root/tests/test_xmlrpc/xmlrpc_test.py
diff options
context:
space:
mode:
authorJason Gerard DeRose <jderose@redhat.com>2009-12-17 06:16:18 -0700
committerRob Crittenden <rcritten@redhat.com>2009-12-17 11:22:14 -0500
commit29f243bf4e2f6cd82362849872d1481dab8543b8 (patch)
tree02ef329a2794fcdd984d57922ce3d4e7cc56088a /tests/test_xmlrpc/xmlrpc_test.py
parentc3f9ec14d90c46f20bd03311e9b31e8fa7c116ce (diff)
downloadfreeipa-29f243bf4e2f6cd82362849872d1481dab8543b8.tar.gz
freeipa-29f243bf4e2f6cd82362849872d1481dab8543b8.tar.xz
freeipa-29f243bf4e2f6cd82362849872d1481dab8543b8.zip
Fuzzy feelings
Diffstat (limited to 'tests/test_xmlrpc/xmlrpc_test.py')
-rw-r--r--tests/test_xmlrpc/xmlrpc_test.py46
1 files changed, 17 insertions, 29 deletions
diff --git a/tests/test_xmlrpc/xmlrpc_test.py b/tests/test_xmlrpc/xmlrpc_test.py
index a51a82bb3..02b1f92c8 100644
--- a/tests/test_xmlrpc/xmlrpc_test.py
+++ b/tests/test_xmlrpc/xmlrpc_test.py
@@ -24,11 +24,22 @@ Base class for all XML-RPC tests
import sys
import socket
import nose
-from tests.util import assert_deepequal
+from tests.util import assert_deepequal, Fuzzy
from ipalib import api, request
from ipalib import errors
+# 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`.
+fuzzy_digits = Fuzzy('^\d+$', type=str)
+
+# Matches an ipauniqueid like u'784d85fd-eae7-11de-9d01-54520012478b'
+fuzzy_uuid = Fuzzy(
+ '^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$'
+)
+
+
try:
if not api.Backend.xmlclient.isconnected():
api.Backend.xmlclient.connect()
@@ -146,10 +157,10 @@ class Declarative(XMLRPC_test):
tests = tuple()
def cleanup_generate(self, stage):
- for command in self.cleanup_commands:
+ for (i, command) in enumerate(self.cleanup_commands):
func = lambda: self.cleanup(command)
- func.description = '%s %s-cleanup: %r' % (
- self.__class__.__name__, stage, command
+ func.description = '%s %s-cleanup[%d]: %r' % (
+ self.__class__.__name__, stage, i, command
)
yield (func,)
@@ -194,11 +205,10 @@ class Declarative(XMLRPC_test):
if cmd not in api.Command:
raise nose.SkipTest('%r not in api.Command' % cmd)
expected = test['expected']
- ignore_values = test.get('ignore_values')
if isinstance(expected, errors.PublicError):
self.check_exception(nice, cmd, args, options, expected)
else:
- self.check_output(nice, cmd, args, options, expected, ignore_values)
+ self.check_output(nice, cmd, args, options, expected)
def check_exception(self, nice, cmd, args, options, expected):
klass = expected.__class__
@@ -224,28 +234,6 @@ class Declarative(XMLRPC_test):
# KWARGS % (cmd, name, args, options, expected.kw, e.kw)
# )
- def check_output(self, nice, cmd, args, options, expected, ignore_values):
+ def check_output(self, nice, cmd, args, options, expected):
got = api.Command[cmd](*args, **options)
- result = got['result']
- if ignore_values:
- if isinstance(result, dict):
- self.clean_entry(
- nice, cmd, args, options, result, ignore_values
- )
- elif isinstance(result, (list, tuple)):
- for entry in result:
- self.clean_entry(
- nice, cmd, args, options, entry, ignore_values
- )
assert_deepequal(expected, got, nice)
-
- def clean_entry(self, nice, cmd, args, options, entry, ignore_values):
- """
- Remove attributes like 'ipauniqueid' whose value is unpredictable.
- """
- for key in ignore_values:
- if key not in entry:
- raise AssertionError(
- IGNORE % (cmd, key, args, options, entry)
- )
- entry.pop(key)