1
# tools/pywine -O tests/test_backend.py
4
sys.path.insert(0, 'build\\wubi\\lib')
5
from wubi.backends.win32 import backend
6
from version import application_name, version, revision
7
from wubi import application
10
from wubi.backends.win32 import registry
11
class BackendTests(unittest.TestCase):
13
w = application.Wubi(application_name, version,
14
revision, 'build\\wubi')
15
# To get things like info.locale set.
16
w.parse_commandline_arguments()
17
self.back = backend.WindowsBackend(w)
18
w.info.original_exe = os.path.join(os.getcwd(), 'build', 'wubi.exe')
21
self.uninstall_keys = [
22
('HKEY_LOCAL_MACHINE', 'registry-key', 'UninstallString',
23
'Z:\\tmp\\uninstall-wubi.exe'),
24
('HKEY_LOCAL_MACHINE', 'registry-key', 'InstallationDir', '/tmp'),
25
('HKEY_LOCAL_MACHINE', 'registry-key', 'DisplayName', 'Ubuntu'),
26
('HKEY_LOCAL_MACHINE', 'registry-key', 'DisplayIcon',
27
os.path.join(os.getcwd(), 'build\\wubi\\data\\images\\Wubi.ico')),
28
('HKEY_LOCAL_MACHINE', 'registry-key', 'DisplayVersion',
29
self.back.info.version_revision),
30
('HKEY_LOCAL_MACHINE', 'registry-key', 'Publisher', 'Ubuntu'),
31
('HKEY_LOCAL_MACHINE', 'registry-key', 'URLInfoAbout',
32
'http://www.ubuntu.com'),
33
('HKEY_LOCAL_MACHINE', 'registry-key', 'HelpLink',
34
'http://www.ubuntu.com/support')]
36
self.save_registry = registry.set_value
37
registry.set_value = mock.Mock()
40
registry.set_value = self.save_registry
42
def test_create_uninstaller(self):
43
# We don't have decorators in Python 2.3
44
self.back.info.target_dir = '/tmp'
45
self.back.info.registry_key = 'registry-key'
46
self.back.info.distro = self.back.parse_isolist(
47
'build/wubi/data/isolist.ini')[0]
48
self.back.create_uninstaller(None)
49
calls = registry.set_value.call_args_list
52
if c[0] in self.uninstall_keys:
55
self.fail('Did not expect key to be set: %s' % str(c[0]))
58
self.assert_(len(calls) == 0,
59
'Did not set required registry keys:\n%s' % str(calls))
61
self.assert_(os.path.exists('/tmp/uninstall-wubi.exe'),
62
'Did not install uninstaller binary.')
63
os.remove('/tmp/uninstall-wubi.exe')
65
if __name__ == '__main__':