Rev 202: Added test for valid patch input. in http://bzr.daniel-watkins.co.uk/pqm/abstract-patch

Daniel Watkins daniel at daniel-watkins.co.uk
Sun Jul 20 16:32:34 BST 2008


At http://bzr.daniel-watkins.co.uk/pqm/abstract-patch

------------------------------------------------------------
revno: 202
revision-id: daniel at daniel-watkins.co.uk-20080720153107-cstlnsfbvuey2opo
parent: daniel at daniel-watkins.co.uk-20080720151321-6rw3owxyorfqqe89
committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
branch nick: abstract-patch
timestamp: Sun 2008-07-20 16:31:07 +0100
message:
  Added test for valid patch input.
-------------- next part --------------
=== modified file 'pqm/tests/test_pqm.py'
--- a/pqm/tests/test_pqm.py	2008-07-20 14:50:15 +0000
+++ b/pqm/tests/test_pqm.py	2008-07-20 15:31:07 +0000
@@ -346,25 +346,43 @@
 
 class TestPatchCommand(TestCaseWithQueue):
 
-    def get_config(self):
+    def set_up(self):
         # Create branch to be patched
-        self.make_branch_and_tree('foo')
+        tree = self.make_branch_and_tree('foo')
         configp = ConfigParser()
         configp.add_section('foo')
         self.getQueue(empty=True)
         # Create PQM working directory
         self.build_tree(['bar/'])
         pqm.workdir = 'bar'
-        return configp
+        pqm.precommit_hook = []
+        return configp, tree
 
     def test_PatchCommand_empty_patch(self):
-        configp = self.get_config()
+        configp, tree = self.set_up()
         script = MockScript()
         handler = pqm.BranchSpecOptionHandler(configp, queuedir='queue')
         command = PatchCommand(script, handler, configp, [], 'foo')
         e = self.assertRaises(PQMException, command.run)
         self.assertEqual("'Empty patch content'", str(e))
 
+    def test_PatchCommand_valid_patch(self):
+        configp, tree = self.set_up()
+        self.build_tree_contents([('foo/bar', '')])
+        tree.smart_add(['foo/bar'])
+        tree.commit("Add bar.")
+
+        patch = ["=== modified file 'bar'",
+            "--- old/bar 2008-07-20 16:06:44.000000000 +0100",
+            "+++ new/bar 2008-07-20 16:06:48.000000000 +0100",
+            "@@ -0,0 +1 @@",
+            "+foo"]
+
+        script = MockScript()
+        handler = pqm.BranchSpecOptionHandler(configp, queuedir='queue')
+        command = PatchCommand(script, handler, configp, patch, 'foo')
+        command.run()
+        self.assertFileEqual('foo\n', 'bar/foo/foo/bar')
 
 class FunctionalTestCommandRunner(unittest.TestCase):
 



More information about the bazaar-commits mailing list