1 #!/usr/bin/env python2.5
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 dpkgdir
= os
.path
.join(os
.path
.dirname(__file__
), 'dpkg')
28 host
= distro
.DebianDistribution(os
.path
.join(dpkgdir
, 'status'))
30 self
.assertEquals(2, len(host
.versions
))
32 host
.get_package_info('gimp', self
.factory
)
33 self
.assertEquals({}, self
.feed
.implementations
)
35 host
.get_package_info('python-bittorrent', self
.factory
)
36 self
.assertEquals(1, len(self
.feed
.implementations
))
37 bittorrent
= self
.feed
.implementations
['package:deb:python-bittorrent:3.4.2-10']
38 self
.assertEquals('3.4.2-10', bittorrent
.get_version())
40 host
.get_package_info('libxcomposite-dev', self
.factory
)
41 self
.assertEquals(2, len(self
.feed
.implementations
))
42 libxcomposite
= self
.feed
.implementations
['package:deb:libxcomposite-dev:0.3.1-1']
43 self
.assertEquals('0.3.1-1', libxcomposite
.get_version())
46 rpmdir
= os
.path
.join(os
.path
.dirname(__file__
), 'rpm')
47 os
.environ
['PATH'] = rpmdir
+ ':' + self
.old_path
48 rpm
= distro
.RPMDistribution(os
.path
.join(rpmdir
, 'status'))
50 self
.assertEquals(2, len(rpm
.versions
))
52 rpm
.get_package_info('yast2-update', self
.factory
)
53 self
.assertEquals(1, len(self
.feed
.implementations
))
54 yast
= self
.feed
.implementations
['package:rpm:yast2-update:2.15.23-21:i586']
55 self
.assertEquals('2.15.23-21', yast
.get_version())
56 self
.assertEquals('*-i586', yast
.arch
)
58 def testCleanVersion(self
):
59 self
.assertEquals('1', distro
.try_cleanup_distro_version('1:0.3.1-1'))
60 self
.assertEquals('0.3.1-1', distro
.try_cleanup_distro_version('0.3.1-1ubuntu0'))
62 suite
= unittest
.makeSuite(TestDistro
)
63 if __name__
== '__main__':