diff options
author | matthew <matthew@38b22f21-9aea-0310-abfc-843a9883df58> | 2005-05-26 03:30:24 (GMT) |
---|---|---|
committer | matthew <matthew@38b22f21-9aea-0310-abfc-843a9883df58> | 2005-05-26 03:30:24 (GMT) |
commit | 8dfb87e20127a5c27c1bba243a77ae8ef10d1fa1 (patch) | |
tree | 1aee3227c0ebe8fe3e36b3fe14228e510b8081be /testing | |
parent | 25c3150e21856be2f37038b3853f28f5a1b8897d (diff) |
Renamed exeDataDir to configDir and made it point to ~/.exe (or c:\doc..\myuser\application data\exe on windows) and autocreate it if it doesn't exist.
Automatically upgrades old config files :)
git-svn-id: https://exe.svn.sourceforge.net/svnroot/exe/trunk@707 38b22f21-9aea-0310-abfc-843a9883df58
Diffstat (limited to 'testing')
-rw-r--r-- | testing/test.conf | 1 | ||||
-rw-r--r-- | testing/testconfig.py | 30 | ||||
-rw-r--r-- | testing/testexport.py | 6 | ||||
-rw-r--r-- | testing/testidevicestore.py | 6 | ||||
-rw-r--r-- | testing/testpackage.py | 10 | ||||
-rw-r--r-- | testing/testxmlhttp.py | 10 |
6 files changed, 53 insertions, 10 deletions
diff --git a/testing/test.conf b/testing/test.conf index 7897999..46dee38 100644 --- a/testing/test.conf +++ b/testing/test.conf @@ -15,3 +15,4 @@ port = ASDFAF dataDir = ASDFAF appDataDir = ASDFAF browserPath = ASDFAF +configDir = /home/matthew
\ No newline at end of file diff --git a/testing/testconfig.py b/testing/testconfig.py index 04e1069..0f4c359 100644 --- a/testing/testconfig.py +++ b/testing/testconfig.py @@ -21,6 +21,8 @@ from exe.engine.config import Config import logging from logging import DEBUG, INFO, WARNING, ERROR, CRITICAL import unittest, sys +from exe.engine.configparser import ConfigParser +from exe.engine.path import Path # Choose which ConfigParser we'll use if sys.platform[:3] == "win": @@ -69,6 +71,34 @@ class TestConfig(unittest.TestCase): self.assertEqual(line[24:].strip(), results[i]) i += 1 + def testUpgradeAppDir(self): + """ + Tests that config files with + 'appDataDir' are upgraded to 'configDir' + """ + # Write the old style config file + configPath = Path('test.exe.conf') + configPath.remove() + oldParser = ConfigParser() + system = oldParser.addSection('system') + system.appDataDir = 'my old app data dir' + oldParser.write(configPath) + del system + del oldParser + # Make the config instance load it + Config._getConfigPathOptions = lambda self: ['test.exe.conf'] + myconfig = Config() + myconfig.loadSettings() + # Check if it reads the old value into the new variable + assert not hasattr(myconfig, 'appDataDir') + self.assertEquals(myconfig.configPath, 'test.exe.conf') + self.assertEquals(myconfig.configDir, 'my old app data dir') + # Check if it has upgraded the file and added in some nice default values + newParser = ConfigParser() + newParser.read(configPath) + self.assertEquals(newParser.system.configDir, 'my old app data dir') + + if __name__ == "__main__": suite = unittest.TestSuite() diff --git a/testing/testexport.py b/testing/testexport.py index 89f5339..9e1c9e1 100644 --- a/testing/testexport.py +++ b/testing/testexport.py @@ -22,7 +22,7 @@ Tests website and scorm exports. import unittest from exe.engine.package import Package -from exe.engine.path import path, TempDirPath +from exe.engine.path import Path, TempDirPath from exe.export.websiteexport import WebsiteExport from exe.export.scormexport import ScormExport from zipfile import ZipFile @@ -43,7 +43,7 @@ class TestWebsiteExport(unittest.TestCase): assert outdir.isdir() assert (outdir / 'index.html').isfile() # Check that the style sheets have been copied - for filename in path('../exe/webui/style/default').files(): + for filename in Path('../exe/webui/style/default').files(): assert ((outdir / filename.basename()).exists(), 'Style file "%s" not copied' % (outdir / filename.basename())) @@ -82,7 +82,7 @@ class BaseTestScormExport(unittest.TestCase): # Load our test package package = Package.load('testPackage.elp') # Do the export - outFilename = path('scormtest.zip') + outFilename = Path('scormtest.zip') class MyConfig: def __init__(self): self.exePath = "" diff --git a/testing/testidevicestore.py b/testing/testidevicestore.py index 2efd216..86ce710 100644 --- a/testing/testidevicestore.py +++ b/testing/testidevicestore.py @@ -19,6 +19,7 @@ from exe.engine.idevice import Idevice from exe.engine.idevicestore import IdeviceStore +from exe.engine.path import Path import unittest import os @@ -29,13 +30,16 @@ _ = gettext.gettext class MyConfig: def __init__(self): - self.appDataDir = "." + self.configDir = Path(".") class TestIdeviceStore(unittest.TestCase): def setUp(self): pass def testLoad(self): + """ + Tests that idevices can be loaded + """ store = IdeviceStore(MyConfig()) store.load() self.assert_(os.path.exists("idevices/generic.data")) diff --git a/testing/testpackage.py b/testing/testpackage.py index 32bd13a..35fec2a 100644 --- a/testing/testpackage.py +++ b/testing/testpackage.py @@ -42,9 +42,9 @@ class TestPackage(unittest.TestCase): package.author = "UoA" Config._getConfigPathOptions = lambda s: ['exe.conf'] config = Config() - package.save(config.dataDir + '/package1.elp') + package.save(config.dataDir/'package1.elp') - filePath = join(config.dataDir, "package1.elp") + filePath = config.dataDir/'package1.elp' package1 = self.packageStore.loadPackage(filePath) self.assert_(package1) self.assertEquals(package1.author, "UoA") @@ -99,7 +99,13 @@ class TestPackage(unittest.TestCase): assert val2.has_key(nodeName) elif isinstance(val, Node) or isinstance(val, TitleIdevice): if isinstance(val, TitleIdevice): checkInst(val, val2) + elif key in Package.nonpersistant: + # Non persistent should exist after load + # but not be the same + assert d2.has_key(key) else: + # Everything else must match + self.assertEquals(val, val2) assert val == val2, '%s.%s: %s/%s' % (inst1.__class__.__name__, key, val2, val) checkInst(package, package2) diff --git a/testing/testxmlhttp.py b/testing/testxmlhttp.py index 3408f23..1819341 100644 --- a/testing/testxmlhttp.py +++ b/testing/testxmlhttp.py @@ -23,6 +23,8 @@ from exe.engine.package import Package from exe.webui.webserver import WebServer from exe.webui.packageredirectpage import PackageRedirectPage from exe.application import Application +from exe.engine.path import Path + class FakeClient(object): """Pretends to be a webnow client object""" @@ -44,10 +46,10 @@ class TestOutline(unittest.TestCase): class MyConfig: def __init__(self): self.port = 8081 - self.dataDir = "." - self.webDir = "." - self.exeDir = "." - self.appDataDir = "." + self.dataDir = Path(".") + self.webDir = Path(".") + self.exeDir = Path(".") + self.configDir = Path(".") self.styles = ["default"] app = Application() app.config = MyConfig() |