Merge lp:~jml/launchpad/more-tests-for-ec2 into lp:launchpad

Proposed by Jonathan Lange
Status: Merged
Approved by: Gavin Panella
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~jml/launchpad/more-tests-for-ec2
Merge into: lp:launchpad
Diff against target: 52 lines (+32/-3)
2 files modified
lib/devscripts/ec2test/testrunner.py (+3/-3)
lib/devscripts/ec2test/tests/test_remote.py (+29/-0)
To merge this branch: bzr merge lp:~jml/launchpad/more-tests-for-ec2
Reviewer Review Type Date Requested Status
Gavin Panella (community) Approve
Review via email: mp+24309@code.launchpad.net

Commit message

Add some unit tests for the script we run on ec2 instances.

Description of the change

What with all of the recent bugs and what-not with hangs and disappearing emails from ec2 test, I thought it would be a good idea to start getting some unit tests for the script that we run remotely on the foreign server.

This means renaming the script in the tree so we can import it and actually adding some unit tests.

I did this work when I was offline and didn't have anything strategic I could do without Internet. My net connection came back quicker than expected and I only got one unit test written.

Still, it's a start, and removes any excuse any further ec2 test tinkerers might have about not writing tests.

To post a comment you must log in.
Revision history for this message
Gavin Panella (allenap) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== renamed file 'lib/devscripts/ec2test/ec2test-remote.py' => 'lib/devscripts/ec2test/remote.py'
2=== modified file 'lib/devscripts/ec2test/testrunner.py'
3--- lib/devscripts/ec2test/testrunner.py 2010-04-19 14:59:03 +0000
4+++ lib/devscripts/ec2test/testrunner.py 2010-04-28 12:02:35 +0000
5@@ -336,10 +336,10 @@
6 'smtp_password = %s\n' % (self._smtp_password,))
7 bazaar_conf_file.close()
8 # Copy remote ec2-remote over
9- self.log('Copying ec2test-remote.py to remote machine.\n')
10+ self.log('Copying remote.py to remote machine.\n')
11 user_connection.sftp.put(
12- os.path.join(os.path.dirname(os.path.realpath(__file__)),
13- 'ec2test-remote.py'),
14+ os.path.join(
15+ os.path.dirname(os.path.realpath(__file__)), 'remote.py'),
16 '/var/launchpad/ec2test-remote.py')
17 # Set up launchpad login and email
18 as_user('bzr launchpad-login %s' % (self._launchpad_login,))
19
20=== added file 'lib/devscripts/ec2test/tests/test_remote.py'
21--- lib/devscripts/ec2test/tests/test_remote.py 1970-01-01 00:00:00 +0000
22+++ lib/devscripts/ec2test/tests/test_remote.py 2010-04-28 12:02:35 +0000
23@@ -0,0 +1,29 @@
24+# Copyright 2010 Canonical Ltd. This software is licensed under the
25+# GNU Affero General Public License version 3 (see the file LICENSE).
26+
27+"""Tests for the script run on the remote server."""
28+
29+__metaclass__ = type
30+
31+from StringIO import StringIO
32+import unittest
33+
34+from devscripts.ec2test.remote import SummaryResult
35+
36+
37+class TestSummaryResult(unittest.TestCase):
38+ """Tests for `SummaryResult`."""
39+
40+ def test_printError(self):
41+ # SummaryResult.printError() prints out the name of the test, the kind
42+ # of error and the details of the error in a nicely-formatted way.
43+ stream = StringIO()
44+ result = SummaryResult(stream)
45+ result.printError('FOO', 'test', 'error')
46+ expected = '%sFOO: test\n%serror\n' % (
47+ result.double_line, result.single_line)
48+ self.assertEqual(expected, stream.getvalue())
49+
50+
51+def test_suite():
52+ return unittest.TestLoader().loadTestsFromName(__name__)