Apply a patch and check that the message-id is reflected in the headers
and matched in the database.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
tests/patchewtest.py | 16 ++++++++--------
tests/test_import.py | 9 ++++++++-
2 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/tests/patchewtest.py b/tests/patchewtest.py
index ca1975a..4c30768 100644
--- a/tests/patchewtest.py
+++ b/tests/patchewtest.py
@@ -73,25 +73,25 @@ class PatchewTestCase(dj_test.LiveServerTestCase):
user.save()
return user
- def cli(self, argv):
- return self.do_cli(False, argv)
+ def cli(self, argv, cwd=None):
+ return self.do_cli(False, argv, cwd=cwd)
- def cli_debug(self, argv):
- return self.do_cli(True, argv)
+ def cli_debug(self, argv, cwd=None):
+ return self.do_cli(True, argv, cwd=cwd)
- def do_cli(self, debug, argv):
+ def do_cli(self, debug, argv, cwd=None):
"""Run patchew-cli command and return (retcode, stdout, stderr)"""
dbgopt = "-d" if debug else "-D"
cmd = [PATCHEW_CLI, dbgopt, "-s", self.live_server_url] + argv
- p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=cwd)
a, b = p.communicate()
a = a.decode("utf-8")
b = b.decode("utf-8")
return p.returncode, a.strip(), b.strip()
- def check_cli(self, args, rc=0, stdout=None, stderr=None):
+ def check_cli(self, args, rc=0, stdout=None, stderr=None, cwd=None):
assert isinstance(args, list)
- r, a, b = self.cli(args)
+ r, a, b = self.cli(args, cwd=cwd)
self.assertEqual(
r,
rc,
diff --git a/tests/test_import.py b/tests/test_import.py
index 1dbf16e..d6c57e4 100755
--- a/tests/test_import.py
+++ b/tests/test_import.py
@@ -134,7 +134,14 @@ class UnprivilegedImportTest(ImportTest):
repo = self.create_git_repo()
p.git = repo
p.save()
- self.check_cli(["project", "update"])
+
+ self.cli_import("0013-foo-patch.mbox.gz")
+ self.check_cli(["apply", "id:20160628014747.20971-1-famz@redhat.com"], cwd=repo)
+ s = Message.objects.series_heads()[0]
+ self.assertEqual(s.is_merged, False)
+ self.check_cli(["project", "update"], cwd=repo)
+ s = Message.objects.series_heads()[0]
+ self.assertEqual(s.is_merged, True)
if __name__ == "__main__":
--
2.34.1
_______________________________________________
Patchew-devel mailing list
Patchew-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/patchew-devel