1 #!/usr/bin/env python2.4
7 sys
.path
.insert(0, '..')
9 from basetest
import BaseTest
10 from zeroinstall
.injector
import autopolicy
11 from zeroinstall
.injector
import run
12 from zeroinstall
.injector
.iface_cache
import iface_cache
15 def write_file(filename
, data
):
16 fh
= open(filename
, "w")
23 class TestEndToEnd(BaseTest
):
25 tempdir
= self
.make_temp_dir()
26 feed_file
= os
.path
.join(tempdir
, "foo.xml")
27 write_file(feed_file
, """
28 <interface xmlns="http://zero-install.sourceforge.net/2004/injector/interface">
30 <summary>Placeholder</summary>
31 <group main="HelloWorld/main">
32 <implementation id="sha1=3ce644dc725f1d21cfcf02562c76f375944b266a"
34 <archive href="%(dir)s/HelloWorld.tgz" size="176"/>
38 """ % {"dir": os
.path
.abspath(os
.path
.dirname(__file__
))})
39 policy
= autopolicy
.AutoPolicy(
40 feed_file
, download_only
=True, dry_run
=False)
41 policy
.download_and_execute([])
42 root_impl
= policy
.get_implementation(
43 iface_cache
.get_interface(policy
.root
))
44 cmd_path
= os
.path
.join(run
._get
_implementation
_path
(root_impl
.id),
46 proc
= subprocess
.Popen([cmd_path
], stdout
=subprocess
.PIPE
)
47 stdout
, stderr
= proc
.communicate()
48 self
.assertEquals(proc
.wait(), 0)
49 self
.assertEquals(stdout
, "Hello World\n")
52 suite
= unittest
.makeSuite(TestEndToEnd
)
53 if __name__
== '__main__':