Testing: apply default and user setting local databases (MB#9332)

Use default local database, same as the client-test. If
CLIENT_TEST_EVOLUTION_PREFIX is not set, the default local
database is 'Syncevolution_Test_[sourcename]_1'. Else,
databases are replaced with '[$CLIENT_TEST_EVOLUTION_PREFIX]
[sourcename]_1. Thus the default local database won't be affected
by the dbus tests.
This commit is contained in:
Zhu, Yongsheng 2010-02-02 12:52:40 +08:00 committed by Patrick Ohly
parent d46299c7f5
commit 4a52ddbdb7
1 changed files with 34 additions and 9 deletions

View File

@ -502,6 +502,26 @@ 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 getEvolutionSources(self, config):
# get 'evolutionsource' for each source
updateProps = { }
for key, value in config.items():
if key != "":
tmpdict = { }
[source, sep, name] = key.partition('/')
if sep == '/':
tmpdict["evolutionsource"] = self.getDatabaseName(name)
updateProps[key] = tmpdict
return updateProps
class TestDBusServer(unittest.TestCase, DBusUtil):
"""Tests for the read-only Server API."""
@ -823,6 +843,11 @@ class TestSessionAPIsDummy(unittest.TestCase, DBusUtil):
}
self.sources = ['addressbook', 'calendar', 'todo', 'memo']
#create default or user settings evolutionsource
updateProps = self.getEvolutionSources(self.config)
for key, dict in updateProps.items():
self.config[key]["evolutionsource"] = dict["evolutionsource"]
def run(self, result):
self.runTest(result)
@ -1336,15 +1361,9 @@ class TestSessionAPIsReal(unittest.TestCase, DBusUtil):
except dbus.DBusException, ex:
self.fail(str(ex) +
". To test this case, please first set up a correct config named 'dbus_unittest'.")
prefix = os.getenv("CLIENT_TEST_EVOLUTION_PREFIX")
if prefix != None:
updateProps = { }
for key, value in configProps.items():
if key != "":
tmpdict = { }
tmpdict["evolutionsource"] = prefix
updateProps[key] = tmpdict
self.session.SetConfig(True, True, updateProps, utf8_strings=True)
updateProps = self.getEvolutionSources(configProps)
# temporarily set evolutionsource and don't change them
self.session.SetConfig(True, True, updateProps, utf8_strings=True)
def doSync(self):
self.setupConfig()
@ -1509,6 +1528,12 @@ class TestConnection(unittest.TestCase, DBusUtil):
"uri" : "text"
}
}
#create default or user settings evolutionsource
updateProps = self.getEvolutionSources(self.config)
for key, dict in updateProps.items():
self.config[key]["evolutionsource"] = dict["evolutionsource"]
def setupConfig(self, name="dummy-test", deviceId="sc-api-nat"):
self.setUpSession(name)
self.config[""]["remoteDeviceId"] = deviceId