From 62a5429093ab190a843d5fa7243227c1d799ca3e Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Sun, 8 Feb 2015 15:15:03 +0100 Subject: parse_gbp_commands: support command filtering When we write out patches to subdirs using a topic we want to filter out this topic from the commit message. Support for this was lost in 7ce15d2434ee42aa5a1afce3d03069c5efb2db1b add it back. Also fix parsing of the deprecated commands. --- tests/13_test_gbp_pq.py | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'tests/13_test_gbp_pq.py') diff --git a/tests/13_test_gbp_pq.py b/tests/13_test_gbp_pq.py index c17b7151..46110b1c 100644 --- a/tests/13_test_gbp_pq.py +++ b/tests/13_test_gbp_pq.py @@ -1,5 +1,5 @@ # vim: set fileencoding=utf-8 : -# (C) 2012 Guido Günther +# (C) 2012,2015 Guido Günther # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or @@ -153,5 +153,30 @@ class TestExport(testutils.DebianGitTestRepo): self.assertFalse(repo.has_branch(pq_branch)) +class TestParseGbpCommand(unittest.TestCase): + def test_empty_body(self): + """Test command filtering with an empty body""" + info = { 'body': '' } + (cmds, body) = pq.parse_gbp_commands(info, ['tag'], ['cmd1'], ['cmd2']) + self.assertEquals(cmds, {}) + self.assertEquals(body, '') + + def test_noarg_cmd(self): + orig_body = '\n'.join(["Foo", + "tag: cmd1"]) + info = { 'body': orig_body } + (cmds, body) = pq.parse_gbp_commands(info, 'tag', ['cmd'], ['argcmd']) + self.assertEquals(cmds, {'cmd': None}) + self.assertEquals(body, orig_body) + + def test_filter_cmd(self): + orig_body = '\n'.join(["Foo", + "tag: cmd1"]) + info = { 'body': orig_body } + (cmds, body) = pq.parse_gbp_commands(info, 'tag', ['cmd'], ['argcmd'], ['cmd']) + self.assertEquals(cmds, {'cmd': None}) + self.assertEquals(body, 'Foo') + + def _patch_path(name): return os.path.join(context.projectdir, 'tests/data', name) -- cgit v1.2.3