2 from basetest
import BaseTest
6 sys
.path
.insert(0, '..')
7 from zeroinstall
.injector
import model
8 from zeroinstall
.injector
.policy
import Policy
12 logger
= logging
.getLogger()
13 #logger.setLevel(logging.DEBUG)
15 class TestPolicy(BaseTest
):
17 iface_cache
= self
.config
.iface_cache
18 warnings
.filterwarnings("ignore", category
= DeprecationWarning)
20 foo
= iface_cache
.get_interface('http://foo/Binary.xml')
21 self
.import_feed(foo
.uri
, 'Binary.xml')
22 foo_src
= iface_cache
.get_interface('http://foo/Source.xml')
23 self
.import_feed(foo_src
.uri
, 'Source.xml')
24 compiler
= iface_cache
.get_interface('http://foo/Compiler.xml')
25 self
.import_feed(compiler
.uri
, 'Compiler.xml')
27 p
= Policy('http://foo/Binary.xml', config
= self
.config
)
29 p
.network_use
= model
.network_full
30 p
.recalculate() # Deprecated
31 assert p
.implementation
[foo
].id == 'sha1=123'
33 # Now ask for source instead
34 p
.requirements
.source
= True
35 p
.requirements
.command
= 'compile'
37 assert p
.solver
.ready
, p
.solver
.get_failure_reason()
38 assert p
.implementation
[foo
].id == 'sha1=234' # The source
39 assert p
.implementation
[compiler
].id == 'sha1=345' # A binary needed to compile it
41 if __name__
== '__main__':