Moved some helper code into new support.py.
[0release.git] / tests / testrelease.py
blobfe6daecaf7e362b61af2bcb70a68570a93048404
1 #!/usr/bin/env python2.5
2 # Copyright (C) 2007, Thomas Leonard
3 # See the README file for details, or visit http://0install.net.
4 import sys, os, shutil, tempfile, subprocess
5 import unittest
7 sys.path.insert(0, '..')
9 import support
11 mydir = os.path.realpath(os.path.dirname(__file__))
12 release_feed = mydir + '/../0release.xml'
13 test_repo = mydir + '/test-repo.tgz'
14 test_gpg = mydir + '/gpg.tgz'
16 class TestRelease(unittest.TestCase):
17 def setUp(self):
18 self.tmp = tempfile.mkdtemp(prefix = '0release-')
19 os.chdir(self.tmp)
20 support.check_call(['tar', 'xzf', test_repo])
21 support.check_call(['tar', 'xzf', test_gpg])
22 os.mkdir('releases')
23 os.environ['GNUPGHOME'] = self.tmp + '/gpg'
25 def tearDown(self):
26 os.chdir(mydir)
27 shutil.rmtree(self.tmp)
29 def testSimple(self):
30 os.chdir('releases')
31 support.check_call(['0launch', release_feed, '../hello/HelloWorld.xml'])
32 assert os.path.isfile('make-release')
34 child = subprocess.Popen(['./make-release', '-k', 'Testing'], stdin = subprocess.PIPE)
35 unused, unused = child.communicate('\nP\n')
36 assert child.returncode == 0
38 child = subprocess.Popen(['./make-release', '-k', 'Testing'], stdin = subprocess.PIPE)
39 unused, unused = child.communicate('\nP\n')
40 assert child.returncode == 0
42 assert 'Prints "Hello World"' in file('changelog-0.1').read()
43 assert 'Prints "Hello World"' not in file('changelog-0.2').read()
45 suite = unittest.makeSuite(TestRelease)
46 if __name__ == '__main__':
47 sys.argv.append('-v')
48 unittest.main()