test_copy_installer.py 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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='proposed-updates')
  15. self.assertEqual('proposed-updates', copier.source)
  16. copier = InstallerCopier(version='20110106', dest='stable')
  17. self.assertEqual('stable', copier.dest)
  18. def test_dir_names(self):
  19. copier = InstallerCopier(version='20110106')
  20. self.assertEqual('tests/fixtures/ftp/dists/unstable/main',
  21. copier.source_dir)
  22. self.assertEqual('tests/fixtures/ftp/dists/testing/main',
  23. copier.dest_dir)
  24. def missing_source(self):
  25. copier = InstallerCopier(version='20110106', source='foo')
  26. def missing_dest(self):
  27. copier = InstallerCopier(version='20110106', dest='bar')
  28. def test_suites(self):
  29. self.assertRaises(IOError, self.missing_source)
  30. self.assertRaises(IOError, self.missing_dest)
  31. def test_copy(self):
  32. copier = InstallerCopier(version='20110106')
  33. self.assertEqual(['amd64'], copier.architectures)
  34. self.assertEqual(['i386'], copier.skip_architectures)
  35. self.assertEqual(
  36. [('tests/fixtures/ftp/dists/unstable/main/installer-amd64/20110106',
  37. 'tests/fixtures/ftp/dists/testing/main/installer-amd64/20110106'), ],
  38. copier.trees_to_copy)
  39. self.assertEqual([('20110106',
  40. 'tests/fixtures/ftp/dists/testing/main/installer-amd64/current')],
  41. copier.symlinks_to_create)
  42. self.assertEqual('''
  43. Will copy installer version 20110106 from suite unstable to
  44. testing.
  45. Architectures to copy: amd64
  46. Architectures to skip: i386''', copier.get_message())
  47. if __name__ == '__main__':
  48. unittest.main()