1 #!/usr/bin/env python2.4
2 from basetest
import BaseTest
, empty_feed
6 sys
.path
.insert(0, '..')
7 from zeroinstall
.injector
import distro
, model
9 class TestDistro(BaseTest
):
12 self
.feed
= model
.ZeroInstallFeed(empty_feed
, local_path
= '/empty.xml')
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
, {})
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__':