1 #!/usr/bin/env python2.3
2 import sys
, tempfile
, os
, shutil
5 sys
.path
.insert(0, '..')
6 from zeroinstall
.injector
import writer
, model
, basedir
, reader
8 class TestTrust(unittest
.TestCase
):
10 self
.config_home
= tempfile
.mktemp()
11 os
.environ
['XDG_CONFIG_HOME'] = self
.config_home
14 assert basedir
.xdg_config_home
== self
.config_home
15 os
.mkdir(self
.config_home
, 0700)
18 shutil
.rmtree(self
.config_home
)
21 iface
= model
.Interface('http://test/test')
22 iface
.stability_policy
= model
.developer
23 iface
.last_checked
= 100
24 iface
.feeds
.append(model
.Feed('http://sys-feed', None, False))
25 iface
.feeds
.append(model
.Feed('http://user-feed', 'Linux-*', True))
26 writer
.save_interface(iface
)
28 iface
= model
.Interface('http://test/test')
29 self
.assertEquals(None, iface
.stability_policy
)
30 reader
.update_user_overrides(iface
)
31 self
.assertEquals(model
.developer
, iface
.stability_policy
)
32 self
.assertEquals(100, iface
.last_checked
)
33 self
.assertEquals(None, iface
.get_feed('http://sys-feed'))
34 feed
= iface
.get_feed('http://user-feed')
35 self
.assertEquals('http://user-feed', feed
.uri
)
36 self
.assertEquals('Linux', feed
.os
)
37 self
.assertEquals(None, feed
.machine
)
39 def testStoreNothing(self
):
40 iface
= model
.Interface('http://test/test')
41 impl
= iface
.get_impl('/some/path')
42 writer
.save_interface(iface
)
44 iface
= model
.Interface('http://test/test')
45 self
.assertEquals(None, iface
.stability_policy
)
46 reader
.update_user_overrides(iface
)
47 self
.assertEquals({}, iface
.implementations
)
49 def testStoreStability(self
):
50 iface
= model
.Interface('http://test/test')
51 impl
= iface
.get_impl('/some/path')
52 impl
.user_stability
= model
.developer
53 writer
.save_interface(iface
)
55 iface
= model
.Interface('http://test/test')
56 self
.assertEquals(None, iface
.stability_policy
)
57 reader
.update_user_overrides(iface
)
58 self
.assertEquals(1, len(iface
.implementations
))
59 impl
= iface
.implementations
['/some/path']
60 self
.assertEquals(model
.developer
, impl
.user_stability
)
62 suite
= unittest
.makeSuite(TestTrust
)
63 if __name__
== '__main__':