D-Bus testing: fixed TestSessionAPIsDummy.testCheckSourceInvalidType

The test was meant to check the error triggered by setting an
invalid backend value. Instead it checked the usability of such
a source and thus duplicated the (badly named) testCheckSourceNoType.

testCheckSourceInvalidType itself failed to pass when SyncEvolution
was compiled with modules, because then the "apple-contacts" backend
wasn't installed and SetConfig() failed with an unexpected error.

Now the test triggers that error in call cases with "backend = no-such-backend"
and checks that the right error is reported.
This commit is contained in:
Patrick Ohly 2011-07-05 20:59:34 +08:00
parent 03a2b875a9
commit 5bcb6e4827
1 changed files with 4 additions and 7 deletions

View File

@ -1451,15 +1451,12 @@ class TestSessionAPIsDummy(unittest.TestCase, DBusUtil):
def testCheckSourceInvalidType(self):
"""TestSessionAPIsDummy.testCheckSourceInvalidType - test the right error is reported when the type is invalid """
self.setupConfig()
# we cannot set an invalid type here, so pick one which is likely
# to be not supported in syncevo-dbus-server
config = { "source/memo" : { "backend" : "apple-contacts"} }
self.session.SetConfig(True, False, config, utf8_strings=True)
config = { "source/memo" : { "backend" : "no-such-backend"} }
try:
self.session.CheckSource("memo", utf8_strings=True)
self.session.SetConfig(True, False, config, utf8_strings=True)
except dbus.DBusException, ex:
self.failUnlessEqual(str(ex),
"org.syncevolution.SourceUnusable: The source 'memo' is not usable")
expected = "org.syncevolution.InvalidCall: invalid value 'no-such-backend' for property 'backend': "
self.failUnlessEqual(str(ex)[0:len(expected)], expected)
else:
self.fail("no exception thrown")