12_test_deb.py 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. # vim: set fileencoding=utf-8 :
  2. """Test L{gbp.deb}"""
  3. from . import context
  4. import os, tempfile, unittest
  5. import gbp.deb
  6. from gbp.deb.dscfile import DscFile
  7. from gbp.command_wrappers import CommandExecFailed
  8. class TestDscFile(unittest.TestCase):
  9. """Test L{gbp.deb.DscFile}"""
  10. content = """Format: 3.0 (quilt)
  11. Source: libvirt
  12. Binary: libvirt-bin, libvirt0, libvirt0-dbg, libvirt-doc, libvirt-dev, python-libvirt
  13. Architecture: any all
  14. Version: 0.9.12-4
  15. Maintainer: Debian Libvirt Maintainers <pkg-libvirt-maintainers@lists.alioth.debian.org>
  16. Uploaders: Guido Günther <agx@sigxcpu.org>, Laurent Léonard <laurent@open-minds.org>
  17. Dm-Upload-Allowed: yes
  18. Homepage: http://libvirt.org
  19. Standards-Version: 3.9.3
  20. Vcs-Browser: http://git.debian.org/?p=pkg-libvirt/libvirt.git
  21. Vcs-Git: git://git.debian.org/git/pkg-libvirt/libvirt.git
  22. Build-Depends: cdbs (>= 0.4.90~), debhelper (>= 7), libxml2-dev, libncurses5-dev, libreadline-dev, zlib1g-dev, libgcrypt11-dev, libgnutls-dev, python-all-dev (>= 2.6.6-3~), libavahi-client-dev, libsasl2-dev, libxen-dev [i386 amd64], lvm2 [linux-any], open-iscsi [linux-any], libparted0-dev (>= 2.2), parted (>= 2.2), libdevmapper-dev [linux-any], uuid-dev, libudev-dev [linux-any], libhal-dev [!linux-any], libpciaccess-dev, module-init-tools [linux-any], policykit-1, libcap-ng-dev [linux-any], libnl-dev [linux-any], libyajl-dev, libpcap0.8-dev, libnuma-dev [amd64 i386 ia64 mips mipsel powerpc], radvd [linux-any], libnetcf-dev [linux-any], dwarves, libxml2-utils, dnsmasq-base, openssh-client, netcat-openbsd
  23. Build-Conflicts: dpkg-dev (= 1.15.3)
  24. Package-List:
  25. libvirt-bin deb admin optional
  26. libvirt-dev deb libdevel optional
  27. libvirt-doc deb doc optional
  28. libvirt0 deb libs optional
  29. libvirt0-dbg deb debug extra
  30. python-libvirt deb python optional
  31. Checksums-Sha1:
  32. 3743dc4f3e58d5912a98f568c3e854d97d81f216 20054618 libvirt_0.9.12.orig.tar.gz
  33. a7ffa64c18a5ee448c98b1dc894a0a27e1670357 35935 libvirt_0.9.12-4.debian.tar.gz
  34. Checksums-Sha256:
  35. 298ffc7f2a6d6e78aae46f11a0980f4bc17fa2928f5de6cd9e8abaf5990336e7 20054618 libvirt_0.9.12.orig.tar.gz
  36. e75110c493995ba5366e751f20f3842f30674c3918357fa6eb83175d0afbec31 35935 libvirt_0.9.12-4.debian.tar.gz
  37. Files:
  38. 5e842bc55733ceba60c64767580ff3e4 20054618 libvirt_0.9.12.orig.tar.gz
  39. f328960d25e7c843f3ac5f9ba5064251 35935 libvirt_0.9.12-4.debian.tar.gz
  40. """
  41. def setUp(self):
  42. with tempfile.NamedTemporaryFile(delete=False) as self.dscfile:
  43. self.dscfile.write(self.content)
  44. def tearDown(self):
  45. os.unlink(self.dscfile.name)
  46. def test_dscfile_parse(self):
  47. """Test parsing a valid dsc file"""
  48. dsc = DscFile.parse(self.dscfile.name)
  49. self.assertEqual(dsc.version, '0.9.12-4')
  50. @unittest.skipIf(not os.path.exists('/usr/bin/dpkg'), 'Dpkg not found')
  51. class TestDpkgCompareVersions(unittest.TestCase):
  52. """Test L{gbp.deb.DpkgCompareVersions}"""
  53. def setUp(self):
  54. self.cmp = gbp.deb.DpkgCompareVersions()
  55. def testLessThen(self):
  56. ret = self.cmp('1', '2')
  57. self.assertEqual(ret, -1)
  58. def testGreaterThen(self):
  59. ret = self.cmp('2', '1')
  60. self.assertEqual(ret, 1)
  61. def testSameVersion(self):
  62. ret = self.cmp('2', '2')
  63. self.assertEqual(ret, 0)
  64. def testBadVersion(self):
  65. self.assertRaises(CommandExecFailed, self.cmp, '_', '_ _')