Fix expected error messages in tests

Have the test suite check error messages.
Since XMLRPC doesn't give us structured error information, just
compare the resulting text.
Fix messages that tests expect to cause.

Minor changes:

Make netgroup-mod's NotFound message consistent with other objects
and methods.

In test_automember_plugin, test with nonexistent automember rules
of both types, instead of nonexistent users.

https://fedorahosted.org/freeipa/ticket/2549
This commit is contained in:
Petr Viktorin
2012-03-27 09:27:11 -04:00
committed by Rob Crittenden
parent 689bea6575
commit 6d0e4e58fc
20 changed files with 340 additions and 185 deletions

View File

@@ -81,7 +81,8 @@ class test_netgroup(Declarative):
dict(
desc='Try to retrieve non-existent %r' % netgroup1,
command=('netgroup_show', [netgroup1], {}),
expected=errors.NotFound(reason='no such entry'),
expected=errors.NotFound(
reason=u'%s: netgroup not found' % netgroup1),
),
@@ -90,35 +91,42 @@ class test_netgroup(Declarative):
command=('netgroup_mod', [netgroup1],
dict(description=u'Updated hostgroup 1')
),
expected=errors.NotFound(reason='no such entry'),
expected=errors.NotFound(
reason=u'%s: netgroup not found' % netgroup1),
),
dict(
desc='Try to delete non-existent %r' % netgroup1,
command=('netgroup_del', [netgroup1], {}),
expected=errors.NotFound(reason='no such entry'),
expected=errors.NotFound(
reason=u'%s: netgroup not found' % netgroup1),
),
dict(
desc='Test an invalid netgroup name %r' % invalidnetgroup1,
command=('netgroup_add', [invalidnetgroup1], dict(description=u'Test')),
expected=errors.ValidationError(name='cn', error='may only include letters, numbers, _, - and .'),
expected=errors.ValidationError(name='name',
error=u'may only include letters, numbers, _, -, and .'),
),
dict(
desc='Test an invalid nisdomain1 name %r' % invalidnisdomain1,
command=('netgroup_add', [netgroup1], dict(description=u'Test',nisdomainname=invalidnisdomain1)),
expected=errors.ValidationError(name='nisdomainname', error='may only include letters, numbers, _, - and .'),
command=('netgroup_add', [netgroup1],
dict(description=u'Test',nisdomainname=invalidnisdomain1)),
expected=errors.ValidationError(name='nisdomain',
error='may only include letters, numbers, _, -, and .'),
),
dict(
desc='Test an invalid nisdomain2 name %r' % invalidnisdomain2,
command=('netgroup_add', [netgroup1], dict(description=u'Test',nisdomainname=invalidnisdomain2)),
expected=errors.ValidationError(name='nisdomainname', error='may only include letters, numbers, _, - and .'),
command=('netgroup_add', [netgroup1],
dict(description=u'Test',nisdomainname=invalidnisdomain2)),
expected=errors.ValidationError(name='nisdomain',
error='may only include letters, numbers, _, -, and .'),
),
@@ -169,7 +177,8 @@ class test_netgroup(Declarative):
command=('netgroup_add', [netgroup1],
dict(description=u'Test netgroup 1')
),
expected=errors.DuplicateEntry(),
expected=errors.DuplicateEntry(
message=u'netgroup with name "%s" already exists' % netgroup1),
),