Rev 200: Merged pqm.dev. in http://bzr.daniel-watkins.co.uk/pqm/ui
Daniel Watkins
daniel at daniel-watkins.co.uk
Thu Jul 10 13:50:00 BST 2008
At http://bzr.daniel-watkins.co.uk/pqm/ui
------------------------------------------------------------
revno: 200
revision-id: daniel at daniel-watkins.co.uk-20080710124846-dbcyynb0g4viumrk
parent: daniel at daniel-watkins.co.uk-20080710124814-2cna51dcmttk0tj0
parent: robertc at robertcollins.net-20080710074340-dl0w25nbutl88sz2
committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
branch nick: ui
timestamp: Thu 2008-07-10 13:48:46 +0100
message:
Merged pqm.dev.
modified:
pqm/tests/test_lockfile.py test_lockfile.py-20060111035725-07e8b573302c8fef
pqm/tests/test_pqm.py x_Robert_Collins_<robert.collins at canonical.com>_Thu_Aug__4_22:52:41_2005_804.0
------------------------------------------------------------
revno: 174.2.2
revision-id: robertc at robertcollins.net-20080710074340-dl0w25nbutl88sz2
parent: robertc at robertcollins.net-20080710073541-uagrp1q9ga624pdf
parent: tim.penhey at canonical.com-20080516082243-i5exdlo2ms2j8zo4
committer: Robert Collins <robertc at robertcollins.net>
branch nick: public
timestamp: Thu 2008-07-10 17:43:40 +1000
message:
Merge dedent branch for tests.
modified:
pqm/tests/test_lockfile.py test_lockfile.py-20060111035725-07e8b573302c8fef
pqm/tests/test_pqm.py x_Robert_Collins_<robert.collins at canonical.com>_Thu_Aug__4_22:52:41_2005_804.0
------------------------------------------------------------
revno: 173.2.4
revision-id: tim.penhey at canonical.com-20080516082243-i5exdlo2ms2j8zo4
parent: tim.penhey at canonical.com-20080416001405-7958wwldpudruw1a
committer: Tim Penhey <tim.penhey at canonical.com>
branch nick: test-dedent
timestamp: Fri 2008-05-16 20:22:43 +1200
message:
Reorder imports to be PEP-8.
modified:
pqm/tests/test_pqm.py x_Robert_Collins_<robert.collins at canonical.com>_Thu_Aug__4_22:52:41_2005_804.0
------------------------------------------------------------
revno: 173.2.3
revision-id: tim.penhey at canonical.com-20080416001405-7958wwldpudruw1a
parent: tim.penhey at canonical.com-20080416001350-hxhl3h1nnrg77sjs
parent: robertc at robertcollins.net-20080415014518-qugji1mpm5g11gir
committer: Tim Penhey <tim.penhey at canonical.com>
branch nick: test-dedent
timestamp: Wed 2008-04-16 12:14:05 +1200
message:
Merge trunk.
modified:
pqm/ui/twistd.py x_Robert_Collins_<robert.collins at canonical.com>_Sun_Jul_10_02:00:08_2005_15556.0
------------------------------------------------------------
revno: 173.2.2
revision-id: tim.penhey at canonical.com-20080416001350-hxhl3h1nnrg77sjs
parent: tim.penhey at canonical.com-20080414014536-pzsatjc4jugnk34j
committer: Tim Penhey <tim.penhey at canonical.com>
branch nick: test-dedent
timestamp: Wed 2008-04-16 12:13:50 +1200
message:
Added dedent to the tests to make multiline text more readable.
modified:
pqm/tests/test_pqm.py x_Robert_Collins_<robert.collins at canonical.com>_Thu_Aug__4_22:52:41_2005_804.0
------------------------------------------------------------
revno: 173.2.1
revision-id: tim.penhey at canonical.com-20080414014536-pzsatjc4jugnk34j
parent: robertc at robertcollins.net-20071129214054-ug81smra1d7tgmcj
committer: Tim Penhey <tim.penhey at canonical.com>
branch nick: test-dedent
timestamp: Mon 2008-04-14 13:45:36 +1200
message:
Clean up test_lockfile.py a little.
modified:
pqm/tests/test_lockfile.py test_lockfile.py-20060111035725-07e8b573302c8fef
------------------------------------------------------------
revno: 174.2.1
revision-id: robertc at robertcollins.net-20080710073541-uagrp1q9ga624pdf
parent: robertc at robertcollins.net-20080415014518-qugji1mpm5g11gir
parent: d.m.watkins at warwick.ac.uk-20080702013313-tpow1un410t1ihlr
committer: Robert Collins <robertc at robertcollins.net>
branch nick: public
timestamp: Thu 2008-07-10 17:35:41 +1000
message:
Merge test fixes patch.
modified:
pqm/tests/test_pqm.py x_Robert_Collins_<robert.collins at canonical.com>_Thu_Aug__4_22:52:41_2005_804.0
-------------- next part --------------
=== modified file 'pqm/tests/test_lockfile.py'
--- a/pqm/tests/test_lockfile.py 2006-01-11 04:29:20 +0000
+++ b/pqm/tests/test_lockfile.py 2008-07-10 07:43:40 +0000
@@ -18,17 +18,16 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+import logging
+import os
+
from twisted.trial import unittest
-import os
-import logging
-import shutil
-from StringIO import StringIO
import pqm.lockfile as lockfile
class TestStaleLock(unittest.TestCase):
-
+
def tearDown(self):
try:
os.unlink(self.lockname)
=== modified file 'pqm/tests/test_pqm.py'
--- a/pqm/tests/test_pqm.py 2008-07-02 01:33:13 +0000
+++ b/pqm/tests/test_pqm.py 2008-07-10 07:43:40 +0000
@@ -2,6 +2,10 @@
import os
import shutil
from StringIO import StringIO
+from textwrap import dedent
+
+import config_manager
+from twisted.trial import unittest
from bzrlib.tests import TestCaseWithTransport
import config_manager
@@ -9,91 +13,109 @@
import pqm
-sample_message = ("From: John.Citizen at example.com\n"
- "Subject: A new action\n"
- "star-merge archive at example.com/foo--bar--0 "
- "archive2 at example.com/bar--foo--1")
-sample_message_2 = ("From: John.Citizen at example.com\n"
- "Subject: A new action\n"
- "star-merge archive at example.com/foo--bar--0 "
- "archive2 at example.com/bar--foo--2")
-sample_message_bad = ("From: John.Citizen at example.com\n"
- "Subject: A new action\n"
- "star-merge archive at example.com/foo--bar--0 "
- "unregistered at example.com/bar--foo--1")
-sample_signed_message = ("From: whee at bar.com (Matthew Thomas)\n"
- "Subject: [trivial] fix various actions portlet icons\n"
- "-----BEGIN PGP SIGNED MESSAGE-----\n"
- "Hash: SHA1\n"
- "\n"
- "star-merge mpt at canonical.com/launchpad--devel--0 rocketfuel at canonical.com/launchpad--devel--0\n"
- "-----BEGIN PGP SIGNATURE-----\n"
- "Version: GnuPG v1.2.5 (GNU/Linux)\n"
- "\n"
- "iD8DBQFC8guw6PUxNfU6ecoRAt5OAKDPyd1Ac0H7QO4DIEiZ2wvscqrg0ACeNL0h\n"
- "ksM1dJeD/aX54NnE/uqps/M=\n"
- "=X7Ib\n"
- "-----END PGP SIGNATURE-----\n"
- "\n")
-
-sample_config_with_overrides = ("[DEFAULT]\n"
- "queuedir=/tmp\n"
- "[location overrides]\n"
- "/local/path=sftp://host/otherpath\n"
- "scheme://something=righthandside\n")
-
-sample_config_default_project = ("[DEFAULT]\n"
- "queuedir=/tmp\n"
- "project=default-project\n"
- "[/dummy/]\n"
- )
-
-sample_config_two_project_specs = ("[DEFAULT]\n"
- "queuedir=/tmp\n"
- "[/one/]\n"
- "project=project-one\n"
- "[/two/]\n"
- "project=project-two\n"
- "[/three/]\n"
- "project=project-two\n")
-
-sample_config_default_and_spec_projects = (
- "[DEFAULT]\n"
- "queuedir=/tmp\n"
- "project=default-project\n"
- "[/one/]\n"
- "project=project-one\n"
- "[/two/]\n"
- "project=project-two\n"
- "[/three/]\n"
- "project=project-two\n")
-
-sample_config_unpublished = ("[DEFAULT]\n"
- "queuedir=/tmp\n"
- "[foo at bar/gam--foo--0]\n")
-
-sample_config_published = ("[DEFAULT]\n"
- "queuedir=/tmp\n"
- "[foo at bar/gam--foo--0]\n"
- "published_at=file:///a\n"
- "[file:///tmp/foo]\n"
- "published_at=file:///b\n"
- "publish_to=sftp://host/b\n"
- "[file:///tmp/bar/]\n"
- "published_at=file:///c/\n"
- )
-
-sample_config_with_groups = ("[DEFAULT]\n"
- "queuedir=/tmp\n"
- "groups=agroup\n"
- "[agroup]\n"
- "members=foo at bar.com\n"
- )
-
-sample_config_with_workdir = ("[DEFAULT]\n"
- "queuedir=queue\n"
- "workdir=test-workdir\n"
- )
+sample_message = dedent("""\
+ From: John.Citizen at example.com
+ Subject: A new action
+ star-merge archive at example.com/foo--bar--0 archive2 at example.com/bar--foo--1
+ """)
+
+sample_message_2 = dedent("""\
+ From: John.Citizen at example.com
+ Subject: A new action
+ star-merge archive at example.com/foo--bar--0 archive2 at example.com/bar--foo--2
+ """)
+
+sample_message_bad = dedent("""\
+ From: John.Citizen at example.com
+ Subject: A new action
+ star-merge archive at example.com/foo--bar--0 unregistered at example.com/bar--foo--1
+ """)
+
+sample_signed_message = dedent("""\
+ From: whee at bar.com (Matthew Thomas)
+ Subject: [trivial] fix various actions portlet icons
+ -----BEGIN PGP SIGNED MESSAGE-----
+ Hash: SHA1
+
+ star-merge mpt at canonical.com/launchpad--devel--0 rocketfuel at canonical.com/launchpad--devel--0
+ -----BEGIN PGP SIGNATURE-----
+ Version: GnuPG v1.2.5 (GNU/Linux)
+
+ iD8DBQFC8guw6PUxNfU6ecoRAt5OAKDPyd1Ac0H7QO4DIEiZ2wvscqrg0ACeNL0h
+ ksM1dJeD/aX54NnE/uqps/M=
+ =X7Ib
+ -----END PGP SIGNATURE-----
+ """)
+
+sample_config_with_overrides = dedent("""\
+ [DEFAULT]
+ queuedir=/tmp
+ [location overrides]
+ /local/path=sftp://host/otherpath
+ scheme://something=righthandside
+ """)
+
+sample_config_default_project = dedent("""\
+ [DEFAULT]
+ queuedir=/tmp
+ project=default-project
+ [/dummy/]
+ """)
+
+sample_config_two_project_specs = dedent("""\
+ [DEFAULT]
+ queuedir=/tmp
+ [/one/]
+ project=project-one
+ [/two/]
+ project=project-two
+ [/three/]
+ project=project-two
+ """)
+
+sample_config_default_and_spec_projects = dedent("""\
+ [DEFAULT]
+ queuedir=/tmp
+ project=default-project
+ [/one/]
+ project=project-one
+ [/two/]
+ project=project-two
+ [/three/]
+ project=project-two
+ """)
+
+sample_config_unpublished = dedent("""\
+ [DEFAULT]
+ queuedir=/tmp
+ [foo at bar/gam--foo--0]
+ """)
+
+sample_config_published = dedent("""\
+ [DEFAULT]
+ queuedir=/tmp
+ [foo at bar/gam--foo--0]
+ published_at=file:///a
+ [file:///tmp/foo]
+ published_at=file:///b
+ publish_to=sftp://host/b
+ [file:///tmp/bar/]
+ published_at=file:///c/
+ """)
+
+sample_config_with_groups = dedent("""\
+ [DEFAULT]
+ queuedir=/tmp
+ groups=agroup
+ [agroup]
+ members=foo at bar.com
+ """)
+
+sample_config_with_workdir = dedent("""\
+ [DEFAULT]
+ queuedir=queue
+ workdir=test-workdir
+ """)
class QueueSetup(object):
@@ -108,12 +130,13 @@
def setUp(self):
myFile=open(self.configFileName, "w")
- myFile.write("[DEFAULT]\n"
- "queuedir=%s/queue\n"
- "[archive2 at example.com/bar--foo--1]\n"
- "project=project\n"
- "[archive2 at example.com/bar--foo--2]\n"
- % self.cwd)
+ myFile.write(dedent("""\
+ [DEFAULT]
+ queuedir=%s/queue
+ [archive2 at example.com/bar--foo--1]
+ project=project
+ [archive2 at example.com/bar--foo--2]
+ """ % self.cwd))
myFile.close()
self.queuedir = os.path.join(self.cwd, "queue")
try:
@@ -140,12 +163,12 @@
class TestWithQueueDirectory(unittest.TestCase):
-
+
def setUp(self):
unittest.TestCase.setUp(self)
self.queue = QueueSetup()
self.queue.setUp()
-
+
def testName(self):
patch = pqm.Script('foo.script', logging, False, 0, None, None)
self.assertEqual(patch.filename, 'foo.script')
@@ -174,10 +197,10 @@
script = self.getScript(sample_message)
self.assertEqual(script.getSender(), "John.Citizen at example.com")
self.assertEqual(script.getSubject(), "A new action")
- self.assertEqual(script.getContent(),
+ self.assertEqual(script.getContent(),
("star-merge archive at example.com/foo--bar--0 "
- "archive2 at example.com/bar--foo--1"))
- self.assertEqual(script.getLines(),
+ "archive2 at example.com/bar--foo--1\n"))
+ self.assertEqual(script.getLines(),
[("star-merge archive at example.com/foo--bar--0 "
"archive2 at example.com/bar--foo--1")])
self.assertEqual([pqm.MergeCommand(None,
@@ -190,23 +213,22 @@
def testGPGFields(self):
script = self.getScript(sample_signed_message)
self.assertEqual(script.getSender(), "whee at bar.com (Matthew Thomas)")
- self.assertEqual(script.getSubject(),
+ self.assertEqual(script.getSubject(),
"[trivial] fix various actions portlet icons")
- self.assertEqual(script.getContent(),
- ('-----BEGIN PGP SIGNED MESSAGE-----\n'
- 'Hash: SHA1\n'
- '\n'
- 'star-merge mpt at canonical.com/launchpad--devel--0 '
- 'rocketfuel at canonical.com/launchpad--devel--0\n'
- '-----BEGIN PGP SIGNATURE-----\n'
- 'Version: GnuPG v1.2.5 (GNU/Linux)\n'
- '\n'
- 'iD8DBQFC8guw6PUxNfU6ecoRAt5OAKDPyd1Ac0H7QO4DIEiZ2wvscqrg0ACeNL0h\n'
- 'ksM1dJeD/aX54NnE/uqps/M=\n'
- '=X7Ib\n'
- '-----END PGP SIGNATURE-----\n'
- '\n'))
- self.assertEqual(script.getLines(),
+ self.assertEqual(script.getContent(), dedent("""\
+ -----BEGIN PGP SIGNED MESSAGE-----
+ Hash: SHA1
+
+ star-merge mpt at canonical.com/launchpad--devel--0 rocketfuel at canonical.com/launchpad--devel--0
+ -----BEGIN PGP SIGNATURE-----
+ Version: GnuPG v1.2.5 (GNU/Linux)
+
+ iD8DBQFC8guw6PUxNfU6ecoRAt5OAKDPyd1Ac0H7QO4DIEiZ2wvscqrg0ACeNL0h
+ ksM1dJeD/aX54NnE/uqps/M=
+ =X7Ib
+ -----END PGP SIGNATURE-----
+ """))
+ self.assertEqual(script.getLines(),
[("star-merge mpt at canonical.com/launchpad--devel--0 "
"rocketfuel at canonical.com/launchpad--devel--0")])
self.assertEqual(
@@ -282,7 +304,7 @@
star_match = Script.star_re.match("star-merge file:///url1 file:///url2")
self.assertEqual(star_match.group(1), 'file:///url1')
self.assertEqual(star_match.group(2), 'file:///url2')
-
+
def test_star_merge_names(self):
from pqm import Script
star_match = Script.star_re.match("star-merge foo at bar/foo--bar--0 foo at bar/gam--foo--0")
@@ -318,7 +340,7 @@
'file:///tmp/bar',
'blah')
runner.check_target('file:///tmp/bar/branch', 'blah')
-
+
def test__make_wd_path(self):
configp = pqm.ConfigParser()
handler = pqm.BranchSpecOptionHandler(configp)
@@ -326,7 +348,7 @@
self.assertEqual(runner._make_wd_path('/foo', 'foo at bar/gam--foo--0'),
'/foo/foo at bar')
self.assertEqual(runner._make_wd_path('/foo', '/foo/bar'), '/foo/foo')
- self.assertEqual(runner._make_wd_path('/foo', 'file:///foo/bar'),
+ self.assertEqual(runner._make_wd_path('/foo', 'file:///foo/bar'),
'/foo/file')
self.assertEqual(runner._make_wd_path('/foo', 'branch'), '/foo/branch')
@@ -361,7 +383,7 @@
runner.configp = pqm.ConfigParser()
expected_mapper = config_manager.URLMapper()
self.assertEqual(expected_mapper, runner._get_url_override_mapper())
-
+
def test__get_url_override_mapper(self):
configp = pqm.ConfigParser()
handler = pqm.BranchSpecOptionHandler(configp)
@@ -372,7 +394,7 @@
expected_mapper.add_map("sftp://host/otherpath", "/local/path")
expected_mapper.add_map("righthandside", "scheme://something")
self.assertEqual(expected_mapper, runner._get_url_override_mapper())
-
+
class TestCommand(unittest.TestCase):
@@ -404,17 +426,17 @@
shutil.rmtree("bzrbranch")
def test_get_branch_handler_arch(self):
- # I would test this, but I don't want to add a full dependency on
+ # I would test this, but I don't want to add a full dependency on
# pybaz at this point
#from pqm import CommandRunner
#runner = CommandRunner()
## TODO set a fake logger
pass
-
+
def branch_url(self):
branchurl = "file://%s" % os.path.abspath("bzrbranch")
return branchurl.replace('\\', '/')
-
+
def test_get_branch_handler_bzr_file(self):
configp = pqm.ConfigParser()
pqm.pqm_subdir = '/tmp' # ewww
@@ -423,7 +445,7 @@
runner.script = MockScript()
self.failUnless(isinstance(runner.get_branch_handler(self.branch_url()),
pqm.Bazaar2Handler))
-
+
def test_get_branch_handler_bzr_relative(self):
configp = pqm.ConfigParser()
pqm.pqm_subdir = '/tmp' # ewww
@@ -432,7 +454,7 @@
runner.script = MockScript()
self.failUnless(isinstance(runner.get_branch_handler("bzrbranch"),
pqm.Bazaar2Handler))
-
+
def test_set_current_vcs(self):
configp = pqm.ConfigParser()
pqm.pqm_subdir = '/tmp' # ewww
@@ -509,7 +531,7 @@
'start branch.')
finally:
shutil.rmtree("proof")
-
+
def test_merge(self):
from bzrlib.branch import Branch
branch = Branch.open("bzrbranch")
@@ -531,7 +553,7 @@
contrib_branch.last_revision()).message,
'add README')
self.failUnless(os.path.exists("bzrbranch/README"))
-
+
def test_merge_conflicts(self):
from bzrlib.workingtree import WorkingTree
from bzrlib.branch import Branch
@@ -550,7 +572,7 @@
file.write("Boo conflict!\n")
file.close()
tree.commit('add conflicting README')
-
+
file = open("branch-contributor/README", "wt")
file.write("Boo conflict YEAH!\n")
file.close()
@@ -595,7 +617,7 @@
branch_spec_handler.project_names())
self.assertEqual('default-project',
branch_spec_handler.get_target_config('/dummy/foo')[1]['project'])
-
+
def test_projects_branch_specs(self):
# branch specs have their projects aggregated and dont error with
# one or two specs mentionining a project.
@@ -611,7 +633,7 @@
branch_spec_handler.get_target_config('/two/foo')[1]['project'])
self.assertEqual('project-two',
branch_spec_handler.get_target_config('/two/foo')[1]['project'])
-
+
def test_projects_branch_specs_and_default(self):
# branch specs have their projects aggregated with the default spec.
configp = pqm.ConfigParser()
@@ -626,7 +648,7 @@
branch_spec_handler.get_target_config('/two/foo')[1]['project'])
self.assertEqual('project-two',
branch_spec_handler.get_target_config('/two/foo')[1]['project'])
-
+
def test_get_target_unpublished_config(self):
configp = pqm.ConfigParser()
configp.readfp(StringIO(sample_config_unpublished))
@@ -637,7 +659,7 @@
self.assertEqual(None, config['published_at'])
self.assertEqual(None, config['publish_to'])
self.assertRaises(KeyError, handler.get_target_config, 'foo at bar/gam--0')
-
+
def test_get_target_config(self):
configp = pqm.ConfigParser()
configp.readfp(StringIO(sample_config_published))
More information about the bazaar-commits
mailing list