test_copy_installer.py 2.16 KB
Newer Older
1 2 3 4 5 6 7 8
#!/usr/bin/env python

from base_test import DakTestCase

from dak.copy_installer import InstallerCopier

import unittest

9

10 11 12 13 14 15
class ImportTestCase(DakTestCase):
    def test_arguments(self):
        '''test constructor arguments'''
        # version argument is required
        self.assertRaises(KeyError, InstallerCopier)

16
        copier = InstallerCopier(version='20110106')
17 18 19 20
        self.assertEqual('20110106', copier.version)
        self.assertEqual('unstable', copier.source)
        self.assertEqual('testing', copier.dest)

21
        copier = InstallerCopier(version='20110106', source='proposed-updates')
22 23
        self.assertEqual('proposed-updates', copier.source)

24
        copier = InstallerCopier(version='20110106', dest='stable')
25 26 27
        self.assertEqual('stable', copier.dest)

    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 33 34
                copier.dest_dir)

    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 41 42 43 44

    def test_suites(self):
        self.assertRaises(IOError, self.missing_source)
        self.assertRaises(IOError, self.missing_dest)

    def test_copy(self):
45
        copier = InstallerCopier(version='20110106')
46 47
        self.assertEqual(['amd64'], copier.architectures)
        self.assertEqual(['i386'], copier.skip_architectures)
48 49
        self.assertEqual(
            [('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 53
        self.assertEqual([('20110106',
            'tests/fixtures/ftp/dists/testing/main/installer-amd64/current')],
54 55 56 57 58 59 60
            copier.symlinks_to_create)
        self.assertEqual('''
Will copy installer version 20110106 from suite unstable to
testing.
Architectures to copy: amd64
Architectures to skip: i386''', copier.get_message())

61

62 63
if __name__ == '__main__':
    unittest.main()