The background checker failed to report errors correctly.
[zeroinstall.git] / tests / testdistro.py
bloba5deb2c5b8971eb12494d8da69b4c1956c7c6fea
1 #!/usr/bin/env python2.4
2 from basetest import BaseTest, empty_feed
3 import sys, tempfile, os, shutil, StringIO
4 import unittest, logging
6 sys.path.insert(0, '..')
7 from zeroinstall.injector import distro, model, qdom
9 class TestDistro(BaseTest):
10 def setUp(self):
11 BaseTest.setUp(self)
12 self.feed = model.ZeroInstallFeed(empty_feed, local_path = '/empty.xml')
14 def tearDown(self):
15 BaseTest.tearDown(self)
17 def factory(self, id):
18 return self.feed._get_impl(id)
20 def testDefault(self):
21 host = distro.Distribution()
23 host.get_package_info('gimp', self.factory)
24 self.assertEquals(self.feed.implementations, {})
26 def testDebian(self):
27 host = distro._host_distribution
29 self.assertEquals(2, len(host.versions))
31 host.get_package_info('gimp', self.factory)
32 self.assertEquals({}, self.feed.implementations)
34 host.get_package_info('python-bittorrent', self.factory)
35 self.assertEquals(1, len(self.feed.implementations))
36 bittorrent = self.feed.implementations['package:deb:python-bittorrent:3.4.2-10']
37 self.assertEquals('3.4.2-10', bittorrent.get_version())
39 host.get_package_info('libxcomposite-dev', self.factory)
40 self.assertEquals(2, len(self.feed.implementations))
41 libxcomposite = self.feed.implementations['package:deb:libxcomposite-dev:0.3.1-1']
42 self.assertEquals('0.3.1-1', libxcomposite.get_version())
44 def testCleanVersion(self):
45 self.assertEquals('1', distro.try_cleanup_distro_version('1:0.3.1-1'))
46 self.assertEquals('0.3.1-1', distro.try_cleanup_distro_version('0.3.1-1ubuntu0'))
48 suite = unittest.makeSuite(TestDistro)
49 if __name__ == '__main__':
50 sys.argv.append('-v')
51 unittest.main()