]> git.decadent.org.uk Git - dak.git/blob - tests/test_copy_installer.py
Refactor functions getSource() and getBinaries().
[dak.git] / tests / test_copy_installer.py
1 #!/usr/bin/env python
2
3 from base_test import DakTestCase
4
5 from dak.copy_installer import InstallerCopier
6
7 import unittest
8
9 class ImportTestCase(DakTestCase):
10     def test_arguments(self):
11         '''test constructor arguments'''
12         # version argument is required
13         self.assertRaises(KeyError, InstallerCopier)
14
15         copier = InstallerCopier(version = '20110106')
16         self.assertEqual('20110106', copier.version)
17         self.assertEqual('unstable', copier.source)
18         self.assertEqual('testing', copier.dest)
19
20         copier = InstallerCopier(version = '20110106', source = \
21                 'proposed-updates')
22         self.assertEqual('proposed-updates', copier.source)
23
24         copier = InstallerCopier(version = '20110106', dest = 'stable')
25         self.assertEqual('stable', copier.dest)
26
27     def test_dir_names(self):
28         copier = InstallerCopier(version = '20110106')
29         self.assertEqual('tests/fixtures/ftp/dists/unstable/main',
30                 copier.source_dir)
31         self.assertEqual('tests/fixtures/ftp/dists/testing/main',
32                 copier.dest_dir)
33
34     def missing_source(self):
35         copier = InstallerCopier(version = '20110106', source = 'foo')
36
37     def missing_dest(self):
38         copier = InstallerCopier(version = '20110106', dest = 'bar')
39
40     def test_suites(self):
41         self.assertRaises(IOError, self.missing_source)
42         self.assertRaises(IOError, self.missing_dest)
43
44     def test_copy(self):
45         copier = InstallerCopier(version = '20110106')
46         self.assertEqual(['amd64'], copier.architectures)
47         self.assertEqual(['i386'], copier.skip_architectures)
48         self.assertEqual( \
49             [('tests/fixtures/ftp/dists/unstable/main/installer-amd64/20110106', \
50               'tests/fixtures/ftp/dists/testing/main/installer-amd64/20110106'),], \
51             copier.trees_to_copy)
52         self.assertEqual([('20110106', \
53             'tests/fixtures/ftp/dists/testing/main/installer-amd64/current')], \
54             copier.symlinks_to_create)
55         self.assertEqual('''
56 Will copy installer version 20110106 from suite unstable to
57 testing.
58 Architectures to copy: amd64
59 Architectures to skip: i386''', copier.get_message())
60
61 if __name__ == '__main__':
62     unittest.main()