Rev 203: Merged other UI changes. in http://bzr.daniel-watkins.co.uk/pqm/125888
Daniel Watkins
daniel at daniel-watkins.co.uk
Tue Jul 15 14:05:21 BST 2008
At http://bzr.daniel-watkins.co.uk/pqm/125888
------------------------------------------------------------
revno: 203
revision-id: daniel at daniel-watkins.co.uk-20080715130401-18yufu76ivbdmfbd
parent: daniel at daniel-watkins.co.uk-20080715125120-zabo9ps4x5sl6ii8
parent: daniel at daniel-watkins.co.uk-20080714142503-r6645pwg1s73s9i2
committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
branch nick: 125888
timestamp: Tue 2008-07-15 14:04:01 +0100
message:
Merged other UI changes.
modified:
pqm/tests/__init__.py i_74708178-eda5-4993-8549-5eddd090ce8e
pqm/tests/test_pqm.py x_Robert_Collins_<robert.collins at canonical.com>_Thu_Aug__4_22:52:41_2005_804.0
pqm/ui/tests/test_twisted.py x_Robert_Collins_<robert.collins at canonical.com>_Sat_Jul__9_22:36:13_2005_7873.0
pqm/ui/twistd.py x_Robert_Collins_<robert.collins at canonical.com>_Sun_Jul_10_02:00:08_2005_15556.0
------------------------------------------------------------
revno: 201.1.6
revision-id: daniel at daniel-watkins.co.uk-20080714142503-r6645pwg1s73s9i2
parent: daniel at daniel-watkins.co.uk-20080713152609-bnpnxkb25vajz1bn
parent: daniel at daniel-watkins.co.uk-20080714142122-dsms44g11q4b4mjl
committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
branch nick: ui
timestamp: Mon 2008-07-14 15:25:03 +0100
message:
Removed unnecessary passing of requests.
modified:
pqm/ui/twistd.py x_Robert_Collins_<robert.collins at canonical.com>_Sun_Jul_10_02:00:08_2005_15556.0
------------------------------------------------------------
revno: 174.3.6
revision-id: daniel at daniel-watkins.co.uk-20080714142122-dsms44g11q4b4mjl
parent: daniel at daniel-watkins.co.uk-20080713150600-mvvadrr27afyhjwq
committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
branch nick: remove-request
timestamp: Mon 2008-07-14 15:21:22 +0100
message:
Removed unnecessary passing of requests.
modified:
pqm/ui/twistd.py x_Robert_Collins_<robert.collins at canonical.com>_Sun_Jul_10_02:00:08_2005_15556.0
------------------------------------------------------------
revno: 201.1.5
revision-id: daniel at daniel-watkins.co.uk-20080713152609-bnpnxkb25vajz1bn
parent: daniel at daniel-watkins.co.uk-20080713152251-jmb2iq8dha1yrxf0
committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
branch nick: ui
timestamp: Sun 2008-07-13 16:26:09 +0100
message:
Updated pqm.ui.tests.test_twisted.TestTwistedUI.testNotProcessingWithQueue to test template.
modified:
pqm/ui/tests/test_twisted.py x_Robert_Collins_<robert.collins at canonical.com>_Sat_Jul__9_22:36:13_2005_7873.0
------------------------------------------------------------
revno: 201.1.4
revision-id: daniel at daniel-watkins.co.uk-20080713152251-jmb2iq8dha1yrxf0
parent: daniel at daniel-watkins.co.uk-20080713152046-0kw3wxka37vz0cqv
committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
branch nick: ui
timestamp: Sun 2008-07-13 16:22:51 +0100
message:
Updated pqm.ui.tests.test_twisted.TestTwistedUI.testNotProcessingEmptyQueue to test template.
modified:
pqm/ui/tests/test_twisted.py x_Robert_Collins_<robert.collins at canonical.com>_Sat_Jul__9_22:36:13_2005_7873.0
------------------------------------------------------------
revno: 201.1.3
revision-id: daniel at daniel-watkins.co.uk-20080713152046-0kw3wxka37vz0cqv
parent: daniel at daniel-watkins.co.uk-20080713151758-j3qpzursaiwfn885
committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
branch nick: ui
timestamp: Sun 2008-07-13 16:20:46 +0100
message:
Updated pqm.ui.tests.test_twisted.TestTwistedUI.testEmptyQueue to test template.
modified:
pqm/ui/tests/test_twisted.py x_Robert_Collins_<robert.collins at canonical.com>_Sat_Jul__9_22:36:13_2005_7873.0
------------------------------------------------------------
revno: 201.1.2
revision-id: daniel at daniel-watkins.co.uk-20080713151758-j3qpzursaiwfn885
parent: daniel at daniel-watkins.co.uk-20080713151610-l1mjhvct4udzefev
parent: daniel at daniel-watkins.co.uk-20080713150600-mvvadrr27afyhjwq
committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
branch nick: ui
timestamp: Sun 2008-07-13 16:17:58 +0100
message:
Merged new UI tests.
modified:
pqm/ui/tests/test_twisted.py x_Robert_Collins_<robert.collins at canonical.com>_Sat_Jul__9_22:36:13_2005_7873.0
------------------------------------------------------------
revno: 174.3.5
revision-id: daniel at daniel-watkins.co.uk-20080713150600-mvvadrr27afyhjwq
parent: daniel at daniel-watkins.co.uk-20080713150031-9j72zmgyazw989w4
committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
branch nick: new-ui-tests
timestamp: Sun 2008-07-13 16:06:00 +0100
message:
Added test for a non-empty queue when PQM is not processing further requests.
modified:
pqm/ui/tests/test_twisted.py x_Robert_Collins_<robert.collins at canonical.com>_Sat_Jul__9_22:36:13_2005_7873.0
------------------------------------------------------------
revno: 174.3.4
revision-id: daniel at daniel-watkins.co.uk-20080713150031-9j72zmgyazw989w4
parent: daniel at daniel-watkins.co.uk-20080713145700-5o5emxpilxftzqu8
committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
branch nick: new-ui-tests
timestamp: Sun 2008-07-13 16:00:31 +0100
message:
Added test for an empty queue when PQM is not processing further requests.
modified:
pqm/ui/tests/test_twisted.py x_Robert_Collins_<robert.collins at canonical.com>_Sat_Jul__9_22:36:13_2005_7873.0
------------------------------------------------------------
revno: 174.3.3
revision-id: daniel at daniel-watkins.co.uk-20080713145700-5o5emxpilxftzqu8
parent: daniel at daniel-watkins.co.uk-20080713145410-2xmtuk9u7cvs1fwt
committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
branch nick: new-ui-tests
timestamp: Sun 2008-07-13 15:57:00 +0100
message:
Added UI test for empty queue.
modified:
pqm/ui/tests/test_twisted.py x_Robert_Collins_<robert.collins at canonical.com>_Sat_Jul__9_22:36:13_2005_7873.0
------------------------------------------------------------
revno: 174.3.2
revision-id: daniel at daniel-watkins.co.uk-20080713145410-2xmtuk9u7cvs1fwt
parent: daniel at daniel-watkins.co.uk-20080713145055-gn4k25s58z6o4wk2
committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
branch nick: new-ui-tests
timestamp: Sun 2008-07-13 15:54:10 +0100
message:
Updated pqm.ui.tests.test_twisted.TestTwistedUI.getResource to accept empty and processing parameters.
modified:
pqm/ui/tests/test_twisted.py x_Robert_Collins_<robert.collins at canonical.com>_Sat_Jul__9_22:36:13_2005_7873.0
------------------------------------------------------------
revno: 174.3.1
revision-id: daniel at daniel-watkins.co.uk-20080713145055-gn4k25s58z6o4wk2
parent: robertc at robertcollins.net-20080710074340-dl0w25nbutl88sz2
parent: daniel at daniel-watkins.co.uk-20080710164650-dd3c037m6wah8yuq
committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
branch nick: new-ui-tests
timestamp: Sun 2008-07-13 15:50:55 +0100
message:
Merged TestCaseWithQueue work.
modified:
pqm/tests/__init__.py i_74708178-eda5-4993-8549-5eddd090ce8e
pqm/tests/test_pqm.py x_Robert_Collins_<robert.collins at canonical.com>_Thu_Aug__4_22:52:41_2005_804.0
pqm/ui/tests/test_twisted.py x_Robert_Collins_<robert.collins at canonical.com>_Sat_Jul__9_22:36:13_2005_7873.0
------------------------------------------------------------
revno: 201.1.1
revision-id: daniel at daniel-watkins.co.uk-20080713151610-l1mjhvct4udzefev
parent: daniel at daniel-watkins.co.uk-20080710132248-spgomd25jctavk50
parent: daniel at daniel-watkins.co.uk-20080710164650-dd3c037m6wah8yuq
committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
branch nick: ui
timestamp: Sun 2008-07-13 16:16:10 +0100
message:
Merged TestCaseWithQueue work.
modified:
pqm/tests/__init__.py i_74708178-eda5-4993-8549-5eddd090ce8e
pqm/tests/test_pqm.py x_Robert_Collins_<robert.collins at canonical.com>_Thu_Aug__4_22:52:41_2005_804.0
pqm/ui/tests/test_twisted.py x_Robert_Collins_<robert.collins at canonical.com>_Sat_Jul__9_22:36:13_2005_7873.0
------------------------------------------------------------
revno: 174.2.10
revision-id: daniel at daniel-watkins.co.uk-20080710164650-dd3c037m6wah8yuq
parent: daniel at daniel-watkins.co.uk-20080710164337-y4962o5sczz0tqv7
committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
branch nick: TestCaseWithQueue
timestamp: Thu 2008-07-10 17:46:50 +0100
message:
Converted TestTwistedUI to subclass TestCaseWithQueue.
modified:
pqm/ui/tests/test_twisted.py x_Robert_Collins_<robert.collins at canonical.com>_Sat_Jul__9_22:36:13_2005_7873.0
------------------------------------------------------------
revno: 174.2.9
revision-id: daniel at daniel-watkins.co.uk-20080710164337-y4962o5sczz0tqv7
parent: daniel at daniel-watkins.co.uk-20080710164201-zmw1dgimft79nd1f
committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
branch nick: TestCaseWithQueue
timestamp: Thu 2008-07-10 17:43:37 +0100
message:
Import cleanup.
modified:
pqm/tests/test_pqm.py x_Robert_Collins_<robert.collins at canonical.com>_Thu_Aug__4_22:52:41_2005_804.0
pqm/ui/tests/test_twisted.py x_Robert_Collins_<robert.collins at canonical.com>_Sat_Jul__9_22:36:13_2005_7873.0
------------------------------------------------------------
revno: 174.2.8
revision-id: daniel at daniel-watkins.co.uk-20080710164201-zmw1dgimft79nd1f
parent: daniel at daniel-watkins.co.uk-20080710163552-maaev5jnyg7iyp3h
committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
branch nick: TestCaseWithQueue
timestamp: Thu 2008-07-10 17:42:01 +0100
message:
Converted TestWithQueueDirectory to subclass TestCaseWithQueue.
modified:
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.7
revision-id: daniel at daniel-watkins.co.uk-20080710163552-maaev5jnyg7iyp3h
parent: daniel at daniel-watkins.co.uk-20080710162506-tpi33egh01pu79tg
committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
branch nick: TestCaseWithQueue
timestamp: Thu 2008-07-10 17:35:52 +0100
message:
Removed need for scriptname to be a instance variable.
modified:
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.6
revision-id: daniel at daniel-watkins.co.uk-20080710162506-tpi33egh01pu79tg
parent: daniel at daniel-watkins.co.uk-20080710161953-ohx24ca1c88s9m0j
committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
branch nick: TestCaseWithQueue
timestamp: Thu 2008-07-10 17:25:06 +0100
message:
Added pqm.tests.TestCaseWithQueue.
modified:
pqm/tests/__init__.py i_74708178-eda5-4993-8549-5eddd090ce8e
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.5
revision-id: daniel at daniel-watkins.co.uk-20080710161953-ohx24ca1c88s9m0j
parent: daniel at daniel-watkins.co.uk-20080710160216-hazgu51bbkw9fums
committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
branch nick: TestCaseWithQueue
timestamp: Thu 2008-07-10 17:19:53 +0100
message:
Moved QueueSetup to pqm.tests.QueueSetup.
modified:
pqm/tests/__init__.py i_74708178-eda5-4993-8549-5eddd090ce8e
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.4
revision-id: daniel at daniel-watkins.co.uk-20080710160216-hazgu51bbkw9fums
parent: daniel at daniel-watkins.co.uk-20080710155822-i9toa3rw19sp0pt2
committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
branch nick: empty-queue
timestamp: Thu 2008-07-10 17:02:16 +0100
message:
Added 'empty' parameter to QueueSetup, to define whether there should be anything in the queue.
modified:
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.3
revision-id: daniel at daniel-watkins.co.uk-20080710155822-i9toa3rw19sp0pt2
parent: robertc at robertcollins.net-20080710074340-dl0w25nbutl88sz2
committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
branch nick: empty-queue
timestamp: Thu 2008-07-10 16:58:22 +0100
message:
Added processing option on QueueSetup, to define whether any further queue requests are being processed.
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/__init__.py'
--- a/pqm/tests/__init__.py 2006-01-11 03:58:41 +0000
+++ b/pqm/tests/__init__.py 2008-07-10 16:25:06 +0000
@@ -0,0 +1,92 @@
+import os
+import shutil
+from textwrap import dedent
+
+from twisted.trial import unittest
+
+
+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
+ """)
+
+
+class QueueSetup(object):
+ """Setup a queue with mock messages in it."""
+
+ def __init__(self, processing=True, empty=False):
+ self.configFileName = "Foo"
+ self.cwd = os.path.abspath(os.path.curdir)
+ self.processing = processing
+ self.empty = empty
+ if not empty:
+ self.message = sample_message
+ self.message_bad = sample_message_bad
+ self.message3 = sample_message_2
+
+ def setUp(self):
+ myFile=open(self.configFileName, "w")
+ 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:
+ os.mkdir(self.queuedir)
+ os.mkdir(self.queuedir + '/pqm')
+ except OSError:
+ pass
+ if not self.processing:
+ open("%s/stop.patch" % (self.queuedir,), "w").close()
+ if not self.empty:
+ self.messageFileName = os.path.join(self.queuedir,
+ "patch.00000001")
+ messageFile = open(self.messageFileName, "w")
+ messageFile.write(self.message)
+ messageFile.close()
+ self.messageFileNameBad = os.path.join(self.queuedir,
+ "patch.00000002")
+ messageFile = open(self.messageFileNameBad, "w")
+ messageFile.write(self.message_bad)
+ messageFile.close()
+ self.messageFileName3 = os.path.join(self.queuedir,
+ "patch.00000003")
+ messageFile = open(self.messageFileName3, "w")
+ messageFile.write(self.message3)
+ messageFile.close()
+
+ def tearDown(self):
+ os.unlink(self.configFileName)
+ shutil.rmtree(self.queuedir, ignore_errors=True)
+
+
+class TestCaseWithQueue(unittest.TestCase):
+
+ def setUp(self):
+ super(TestCaseWithQueue, self).setUp()
+
+ def tearDown(self):
+ super(TestCaseWithQueue, self).tearDown()
+
+ def getQueue(self, processing=True, empty=False):
+ queue = QueueSetup(processing, empty)
+ queue.setUp()
+ self.addCleanup(queue.tearDown)
+ return queue
=== modified file 'pqm/tests/test_pqm.py'
--- a/pqm/tests/test_pqm.py 2008-07-10 07:43:40 +0000
+++ b/pqm/tests/test_pqm.py 2008-07-10 16:43:37 +0000
@@ -4,32 +4,16 @@
from StringIO import StringIO
from textwrap import dedent
-import config_manager
-from twisted.trial import unittest
-
from bzrlib.tests import TestCaseWithTransport
import config_manager
from twisted.trial import unittest
import pqm
-
-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
- """)
+from pqm.tests import (sample_message,
+ sample_message_2,
+ sample_message_bad,
+ TestCaseWithQueue,
+ )
sample_signed_message = dedent("""\
From: whee at bar.com (Matthew Thomas)
@@ -118,83 +102,30 @@
""")
-class QueueSetup(object):
- """Setup a queue with mock messages in it."""
-
- def __init__(self):
- self.configFileName = "Foo"
- self.cwd = os.path.abspath(os.path.curdir)
- self.message = sample_message
- self.message_bad = sample_message_bad
- self.message3 = sample_message_2
-
- def setUp(self):
- myFile=open(self.configFileName, "w")
- 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:
- os.mkdir(self.queuedir)
- os.mkdir(self.queuedir + '/pqm')
- except OSError:
- pass
- self.messageFileName = os.path.join(self.queuedir, "patch.00000001")
- messageFile = open(self.messageFileName, "w")
- messageFile.write(self.message)
- messageFile.close()
- self.messageFileNameBad = os.path.join(self.queuedir, "patch.00000002")
- messageFile = open(self.messageFileNameBad, "w")
- messageFile.write(self.message_bad)
- messageFile.close()
- self.messageFileName3 = os.path.join(self.queuedir, "patch.00000003")
- messageFile = open(self.messageFileName3, "w")
- messageFile.write(self.message3)
- messageFile.close()
-
- def tearDown(self):
- os.unlink(self.configFileName)
- shutil.rmtree(self.queuedir, ignore_errors=True)
-
-
-class TestWithQueueDirectory(unittest.TestCase):
-
- def setUp(self):
- unittest.TestCase.setUp(self)
- self.queue = QueueSetup()
- self.queue.setUp()
+class TestWithQueueDirectory(TestCaseWithQueue):
def testName(self):
patch = pqm.Script('foo.script', logging, False, 0, None, None)
self.assertEqual(patch.filename, 'foo.script')
- self.scriptname = 'fpp'
-
- def tearDown(self):
- try:
- os.unlink(self.scriptname)
- except OSError:
- pass
- self.queue.tearDown()
-
- def getScript(self, content):
+
+ def getScript(self, queue, content):
"""Get a script for testing with."""
- self.scriptname = 'foo.script'
- scriptFile = open(self.scriptname, "w")
+ scriptname = 'foo.script'
+ scriptFile = open(scriptname, "w")
scriptFile.write(content)
scriptFile.close()
+ def cleanupScript():
+ os.unlink(scriptname)
+ self.addCleanup(cleanupScript)
pqm.pqm_subdir = os.path.abspath('queue/pqm')
configp = pqm.ConfigParser()
- configp.read([self.queue.configFileName])
+ configp.read([queue.configFileName])
handler = pqm.BranchSpecOptionHandler(configp)
- return pqm.Script(self.scriptname, logging, False, 54, handler, configp)
+ return pqm.Script(scriptname, logging, False, 54, handler, configp)
def testFields(self):
- script = self.getScript(sample_message)
+ queue = self.getQueue()
+ script = self.getScript(queue, sample_message)
self.assertEqual(script.getSender(), "John.Citizen at example.com")
self.assertEqual(script.getSubject(), "A new action")
self.assertEqual(script.getContent(),
@@ -211,7 +142,8 @@
script.getCommands())
def testGPGFields(self):
- script = self.getScript(sample_signed_message)
+ queue = self.getQueue()
+ script = self.getScript(queue, sample_signed_message)
self.assertEqual(script.getSender(), "whee at bar.com (Matthew Thomas)")
self.assertEqual(script.getSubject(),
"[trivial] fix various actions portlet icons")
@@ -241,27 +173,30 @@
def testDate(self):
"""Can we access a submission time for scripts."""
- script = self.getScript(sample_message)
+ queue = self.getQueue()
+ script = self.getScript(queue, sample_message)
self.assertEqual(script.getSubmissionTime(), 54)
def testProjects(self):
# A script may affect multiple branches, so we can ask the script
# for its projects, and then for the commands for a project.
- script = self.getScript(sample_message)
+ queue = self.getQueue()
+ script = self.getScript(queue, sample_message)
self.assertEqual(set(['project']), script.getProjects())
def test_log_status(self):
# make an initial status file
- status = file(self.queue.queuedir + '/pqm/status', 'wt')
+ queue = self.getQueue()
+ status = file(queue.queuedir + '/pqm/status', 'wt')
status.write('bar\n')
status.close()
- script = self.getScript(sample_message)
+ script = self.getScript(queue, sample_message)
command = pqm.Command(script,
script._branch_spec_handler,
script._configp)
logger = MockLogger()
command.log_with_status(logger, 'foo')
- content = file(self.queue.queuedir + '/pqm/status').read()
+ content = file(queue.queuedir + '/pqm/status').read()
self.assertEqual('bar\nfoo\n', content)
=== modified file 'pqm/ui/tests/test_twisted.py'
--- a/pqm/ui/tests/test_twisted.py 2008-07-10 12:27:51 +0000
+++ b/pqm/ui/tests/test_twisted.py 2008-07-13 15:26:09 +0000
@@ -1,4 +1,3 @@
-
from twisted.trial import unittest
from twisted.web.resource import getChildForRequest
from twisted.web.test.test_web import DummyRequest
@@ -9,30 +8,23 @@
from BeautifulSoup import BeautifulSoup
import pqm
-from pqm.tests.test_pqm import QueueSetup
-
-class TestTwistedUI(unittest.TestCase):
+from pqm.tests import TestCaseWithQueue
+
+
+class TestTwistedUI(TestCaseWithQueue):
def testImports(self):
import pqm.ui.twistd
- def setUp(self):
- unittest.TestCase.setUp(self)
- self.queueSetup = QueueSetup()
- self.queueSetup.setUp()
-
- def tearDown(self):
- unittest.TestCase.tearDown(self)
- self.queueSetup.tearDown()
-
def testQueue(self):
+ queue = self.getQueue()
configp = pqm.ConfigParser()
- configp.read([self.queueSetup.configFileName])
+ configp.read([queue.configFileName])
handler = pqm.BranchSpecOptionHandler(configp)
queuedir = pqm.get_queuedir(configp, logging, [])
patches = pqm.find_patches(queuedir, logging, None, handler, configp)
self.assertEqual(3, len(patches))
- self.assertEqual(patches[0].filename, self.queueSetup.messageFileName)
+ self.assertEqual(patches[0].filename, queue.messageFileName)
self.assertEqual(set(['project']),
patches[0].getCommands()[0].getProjects())
self.assertRaises(KeyError,
@@ -40,12 +32,13 @@
self.assertEqual(set([]),
patches[2].getCommands()[0].getProjects())
- def getResource(self):
+ def getResource(self, empty=False, processing=True):
from pqm.ui.twistd import PQMInfo, QueueResource
- statusfile = file(self.queueSetup.queuedir + '/pqm/status', 'wt')
+ queue = self.getQueue(empty=empty, processing=processing)
+ statusfile = file(queue.queuedir + '/pqm/status', 'wt')
statusfile.write("<foo\nbar\nbaz\nquux\ntheta\n")
statusfile.close()
- pqminfo = PQMInfo([self.queueSetup.configFileName])
+ pqminfo = PQMInfo([queue.configFileName])
resource = QueueResource(pqminfo)
pqminfo.refresh()
return resource
@@ -192,3 +185,107 @@
" </body>\n"
"</html>")
self.assertDocTest(expected, html)
+
+ def testEmptyQueue(self):
+ queue = self.getResource(empty=True)
+ request = DummyRequest([''])
+ result_resource = getChildForRequest(queue, request)
+ html = BeautifulSoup(result_resource.render(request)).prettify()
+ expected = ("<html>\n"
+ " <head>\n"
+ " <title>\n"
+ " Patch Queue Manager\n"
+ " </title>\n"
+ " </head>\n"
+ " <body>\n"
+ " <h1>\n"
+ " PQM Queue: 0 scripts\n"
+ " </h1>\n"
+ " <p>\n"
+ " Current time: ...\n"
+ " </p>\n"
+ " </body>\n"
+ "</html>")
+ self.assertDocTest(expected, html)
+
+ def testNotProcessingEmptyQueue(self):
+ queue = self.getResource(empty=True, processing=False)
+ request = DummyRequest([''])
+ result_resource = getChildForRequest(queue, request)
+ html = BeautifulSoup(result_resource.render(request)).prettify()
+ expected = ("<html>\n"
+ " <head>\n"
+ " <title>\n"
+ " Patch Queue Manager\n"
+ " </title>\n"
+ " </head>\n"
+ " <body>\n"
+ " <h1>\n"
+ " PQM Queue: 0 scripts\n"
+ " </h1>\n"
+ " <h2>\n"
+ " PQM is not currently processing additional requests\n"
+ " </h2>\n"
+ " <p>\n"
+ " Current time: ...\n"
+ " </p>\n"
+ " </body>\n"
+ "</html>")
+ self.assertDocTest(expected, html)
+
+ def testNotProcessingWithQueue(self):
+ queue = self.getResource(processing=False)
+ request = DummyRequest([''])
+ result_resource = getChildForRequest(queue, request)
+ html = BeautifulSoup(result_resource.render(request)).prettify()
+ expected = ("<html>\n"
+ " <head>\n"
+ " <title>\n"
+ " Patch Queue Manager\n"
+ " </title>\n"
+ " </head>\n"
+ " <body>\n"
+ " <h1>\n"
+ " PQM Queue: 3 scripts\n"
+ " </h1>\n"
+ " <h2>\n"
+ " PQM is not currently processing additional requests\n"
+ " </h2>\n"
+ " <p>\n"
+ " Current time: ...\n"
+ " </p>\n"
+ " <h2>\n"
+ " Now playing...\n"
+ " </h2>\n"
+ " <ul>\n"
+ " <li>\n"
+ " <p>\n"
+ " A request for another project.\n"
+ " </p>\n"
+ " </li>\n"
+ " </ul>\n"
+ " <h2>\n"
+ " Coming up\n"
+ " </h2>\n"
+ " <ol>\n"
+ " <li>\n"
+ " <p>\n"
+ " ...: John.Citizen at example.com, Request for"
+ " non-PQM managed branch.\n"
+ " </p>\n"
+ " </li>\n"
+ " <li>\n"
+ " <p>\n"
+ " ...: John.Citizen at example.com, 'A new action'\n"
+ " <ol>\n"
+ " <li>\n"
+ " Merge archive at example.com/foo--bar--0"
+ " archive2 at example.com/bar--foo--2\n"
+ " </li>\n"
+ " </ol>\n"
+ " </p>\n"
+ " </li>\n"
+ " </ol>\n"
+ " </body>\n"
+ "</html>")
+ self.assertDocTest(expected, html)
=== modified file 'pqm/ui/twistd.py'
--- a/pqm/ui/twistd.py 2008-07-15 12:51:20 +0000
+++ b/pqm/ui/twistd.py 2008-07-15 13:04:01 +0000
@@ -48,11 +48,11 @@
"specific page.</h1>", 'text/html').render(request)
if len(request.postpath) > 1:
project = request.postpath[0]
- return self.getProjectPage(project, request).render(request)
+ return self.getProjectPage(project).render(request)
else:
- return self.getProjectPage(None, request).render(request)
+ return self.getProjectPage(None).render(request)
- def getProjectPage(self, selected_project, request):
+ def getProjectPage(self, selected_project):
template = compileHTMLTemplate(html_template)
c = Context(allowPythonPath=True)
c.addGlobal('processing', self.currentlyProcessing())
More information about the bazaar-commits
mailing list