D-Bus testing: avoid dependency on default backend and its databases

TestConnection and TestSessionAPIsDummy used configs with
backend=addressbook/calendar/todo/memo which had to have databases
with a name derived from CLIENT_TEST_EVOLUTION_SOURCE and the source
name. This was neither documented nor did the required databases match
the ones used by the client-test programs anymore.

For the sake of making the test setup easier, this commit changes
these tests so that they use the file backend (always available) and
file://temp-test-dbus/<source name> databases (created if needed by
the backend). In other words, the tests now run without manual setup
of the host.

The downside is that D-Bus testing no longer covers the real
sources. That's okay, client-test covers that, whereas test-dbus.py
should focus on the D-Bus API itself.
This commit is contained in:
Patrick Ohly 2011-07-04 17:10:41 +02:00
parent 32c78d4d81
commit be08788419
1 changed files with 33 additions and 43 deletions

View File

@ -563,26 +563,6 @@ class DBusUtil(Timeout):
if os.access(sourcepath, os.F_OK):
shutil.copytree(sourcepath, destpath)
def getDatabaseName(self, configName):
# get database names with the environment variable
prefix = os.getenv("CLIENT_TEST_EVOLUTION_PREFIX")
source = configName + '_1'
if prefix == None:
prefix = 'SyncEvolution_Test_'
return prefix + source;
def getDatabases(self, config):
# get 'database' for each source
updateProps = { }
for key, value in config.items():
if key != "":
tmpdict = { }
[source, sep, name] = key.partition('/')
if sep == '/':
tmpdict["database"] = self.getDatabaseName(name)
updateProps[key] = tmpdict
return updateProps
def checkSync(self, expectedError=0, expectedResult=0):
# check recorded events in DBusUtil.events, first filter them
statuses = []
@ -1226,19 +1206,27 @@ class TestSessionAPIsDummy(unittest.TestCase, DBusUtil):
"configName" : "dummy-test"
},
"source/addressbook" : { "sync" : "slow",
"backend" : "addressbook",
"backend" : "file",
"database" : "file://" + xdg_root + "/addressbook",
"databaseFormat" : "text/vcard",
"uri" : "card"
},
"source/calendar" : { "sync" : "disabled",
"backend" : "calendar",
"backend" : "file",
"database" : "file://" + xdg_root + "/calendar",
"databaseFormat" : "text/calendar",
"uri" : "cal"
},
"source/todo" : { "sync" : "disabled",
"backend" : "todo",
"backend" : "file",
"database" : "file://" + xdg_root + "/todo",
"databaseFormat" : "text/calendar",
"uri" : "task"
},
"source/memo" : { "sync" : "disabled",
"backend" : "memo",
"backend" : "file",
"database" : "file://" + xdg_root + "/memo",
"databaseFormat" : "text/calendar",
"uri" : "text"
}
}
@ -1249,11 +1237,6 @@ class TestSessionAPIsDummy(unittest.TestCase, DBusUtil):
}
self.sources = ['addressbook', 'calendar', 'todo', 'memo']
#create default or user settings database
updateProps = self.getDatabases(self.config)
for key, dict in updateProps.items():
self.config[key]["database"] = dict["database"]
def run(self, result):
self.runTest(result)
@ -1544,8 +1527,12 @@ class TestSessionAPIsDummy(unittest.TestCase, DBusUtil):
def testGetDatabasesUpdateConfigTemp(self):
"""TestSessionAPIsDummy.testGetDatabasesUpdateConfigTemp - test the config is temporary updated and in effect for GetDatabases in the current session. """
self.setupConfig()
# file backend: reports a short help text instead of a real database list
databases1 = self.session.GetDatabases("calendar", utf8_strings=True)
tempConfig = {"source/temp" : { "backend" : "calendar"}}
# databaseFormat is required for file backend, otherwise it
# cannot be instantiated and even simple operations as reading
# the (in this case fixed) list of databases fail
tempConfig = {"source/temp" : { "backend" : "file", "databaseFormat" : "text/calendar" }}
self.session.SetConfig(True, True, tempConfig, utf8_strings=True)
databases2 = self.session.GetDatabases("temp", utf8_strings=True)
self.failUnlessEqual(databases2, databases1)
@ -1936,29 +1923,32 @@ class TestConnection(unittest.TestCase, DBusUtil):
"RetryInterval" : "1",
"RetryDuration" : "10"
},
"source/addressbook" : { "sync" : "two-way",
"backend" : "addressbook",
"source/addressbook" : { "sync" : "slow",
"backend" : "file",
"database" : "file://" + xdg_root + "/addressbook",
"databaseFormat" : "text/vcard",
"uri" : "card"
},
"source/calendar" : { "sync" : "two-way",
"backend" : "calendar",
"source/calendar" : { "sync" : "disabled",
"backend" : "file",
"database" : "file://" + xdg_root + "/calendar",
"databaseFormat" : "text/calendar",
"uri" : "cal"
},
"source/todo" : { "sync" : "two-way",
"backend" : "todo",
"source/todo" : { "sync" : "disabled",
"backend" : "file",
"database" : "file://" + xdg_root + "/todo",
"databaseFormat" : "text/calendar",
"uri" : "task"
},
"source/memo" : { "sync" : "two-way",
"backend" : "memo",
"source/memo" : { "sync" : "disabled",
"backend" : "file",
"database" : "file://" + xdg_root + "/memo",
"databaseFormat" : "text/calendar",
"uri" : "text"
}
}
#create default or user settings evolutionsource
updateProps = self.getDatabases(self.config)
for key, dict in updateProps.items():
self.config[key]["database"] = dict["database"]
def setupConfig(self, name="dummy-test", deviceId="sc-api-nat"):
self.setUpSession(name)
self.config[""]["remoteDeviceId"] = deviceId