22_test_gbp_buildpackage.py 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. # vim: set fileencoding=utf-8 :
  2. """Test L{gbp.command_wrappers.Command}'s tarball unpack"""
  3. from gbp.scripts.buildpackage import (get_pbuilder_dist,
  4. setup_pbuilder,
  5. GbpError)
  6. from . testutils import DebianGitTestRepo
  7. from mock import patch
  8. class TestGbpBuildpackageDep14(DebianGitTestRepo):
  9. class Options(object):
  10. pass
  11. def setUp(self):
  12. DebianGitTestRepo.setUp(self)
  13. self.add_file('doesnotmatter')
  14. self.options = self.Options()
  15. self.options.pbuilder_dist = 'DEP14'
  16. @patch('gbp.deb.get_vendor', return_value='Debian')
  17. def test_get_pbuilder_dist_no_dep14(self, patch):
  18. self.options.pbuilder_dist = 'notdep14'
  19. self.assertEqual(get_pbuilder_dist(self.options, self.repo),
  20. self.options.pbuilder_dist)
  21. @patch('gbp.deb.get_vendor', return_value='Debian')
  22. def test_get_pbuilder_dist_dep14_debian_sid(self, patch):
  23. branch = 'debian/sid'
  24. self.repo.create_branch(branch)
  25. self.repo.set_branch(branch)
  26. self.assertEqual(get_pbuilder_dist(self.options, self.repo), '')
  27. patch.assert_called_once_with()
  28. @patch('gbp.deb.get_vendor', return_value='Debian')
  29. def test_get_pbuilder_dist_dep14_debian_suite(self, patch):
  30. branch = 'debian/squeeze-lts'
  31. self.repo.create_branch(branch)
  32. self.repo.set_branch(branch)
  33. self.assertEqual(get_pbuilder_dist(self.options, self.repo), 'squeeze-lts')
  34. patch.assert_called_once_with()
  35. @patch('gbp.deb.get_vendor', return_value='Debian')
  36. def test_get_pbuilder_dist_dep14_debian_native(self, patch):
  37. self.assertEqual(get_pbuilder_dist(self.options, self.repo, True), '')
  38. @patch('gbp.deb.get_vendor', return_value='Debian')
  39. def test_get_pbuilder_dist_dep14_vendor_sid(self, patch):
  40. branch = 'downstream/sid'
  41. self.repo.create_branch(branch)
  42. self.repo.set_branch(branch)
  43. self.assertEqual(get_pbuilder_dist(self.options, self.repo), 'downstream_sid')
  44. patch.assert_called_once_with()
  45. @patch('gbp.deb.get_vendor', return_value='Debian')
  46. def test_get_pbuilder_dist_dep14_vendor_suite(self, patch):
  47. branch = 'downstream/mies-lts'
  48. self.repo.create_branch(branch)
  49. self.repo.set_branch(branch)
  50. self.assertEqual(get_pbuilder_dist(self.options, self.repo), 'downstream_mies-lts')
  51. @patch('gbp.deb.get_vendor', return_value='Debian')
  52. def test_get_pbuilder_dist_dep14_no_vendor(self, patch):
  53. branch = 'sid'
  54. self.repo.create_branch(branch)
  55. self.repo.set_branch(branch)
  56. with self.assertRaisesRegexp(GbpError,
  57. 'DEP14 DIST setup needs branch name to be vendor/suite'):
  58. get_pbuilder_dist(self.options, self.repo)
  59. def test_get_pbuilder_dist_dep14_too_many_slashes(self):
  60. branch = 'too/many/slashed'
  61. self.repo.create_branch(branch)
  62. self.repo.set_branch(branch)
  63. with self.assertRaisesRegexp(GbpError,
  64. 'DEP14 DIST setup needs branch name to be vendor/suite'):
  65. get_pbuilder_dist(self.options, self.repo)
  66. class TestGbpBuildpackageSetupPbuilder(DebianGitTestRepo):
  67. class Options(object):
  68. use_pbuilder = True
  69. pbuilder_dist = 'sid'
  70. pbuilder_arch = ''
  71. use_qemubuilder = False
  72. pbuilder_autoconf = True
  73. pbuilder_options = ''
  74. def setUp(self):
  75. DebianGitTestRepo.setUp(self)
  76. self.options = self.Options()
  77. def test_setup_pbuilder(self):
  78. self.assertEqual(setup_pbuilder(self.options,
  79. self.repo,
  80. True),
  81. ({'GBP_PBUILDER_DIST': 'sid', 'DIST': 'sid'},
  82. {'GBP_PBUILDER_DIST': 'sid'}))
  83. def test_setup_pbuilder_arch(self):
  84. self.options.pbuilder_arch = 'arm64'
  85. self.assertEqual(setup_pbuilder(self.options,
  86. self.repo,
  87. True),
  88. ({'ARCH': 'arm64',
  89. 'DIST': 'sid',
  90. 'GBP_PBUILDER_ARCH': 'arm64',
  91. 'GBP_PBUILDER_DIST': 'sid'},
  92. {'GBP_PBUILDER_ARCH': 'arm64',
  93. 'GBP_PBUILDER_DIST': 'sid'}))