test_copy_installer.py 2.2 KB

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