def test_vanilla(self): patch = PatchHelper( io.BytesIO(""" # HG changeset patch # User byron jones <*****@*****.**> # Date 1523427125 -28800 # Wed Apr 11 14:12:05 2018 +0800 # Node ID 3379ea3cea34ecebdcb2cf7fb9f7845861ea8f07 # Parent 46c36c18528fe2cc780d5206ed80ae8e37d3545d WIP transplant and diff-start-line diff --git a/autoland/autoland/transplant.py b/autoland/autoland/transplant.py --- a/autoland/autoland/transplant.py +++ b/autoland/autoland/transplant.py @@ -318,24 +318,58 @@ class PatchTransplant(Transplant): # instead of passing the url to 'hg import' to make ... """.strip())) self.assertEqual(patch.header('Date'), '1523427125 -28800') self.assertEqual(patch.header('Node ID'), '3379ea3cea34ecebdcb2cf7fb9f7845861ea8f07') self.assertEqual(patch.header('User'), 'byron jones <*****@*****.**>') self.assertEqual(patch.header('Parent'), '46c36c18528fe2cc780d5206ed80ae8e37d3545d') self.assertEqual(patch.commit_description(), 'WIP transplant and diff-start-line')
def test_diff_inject_start_line(self): patch = PatchHelper( io.BytesIO(""" # HG changeset patch # User byron jones <*****@*****.**> # Date 1523427125 -28800 # Wed Apr 11 14:12:05 2018 +0800 # Node ID 3379ea3cea34ecebdcb2cf7fb9f7845861ea8f07 # Parent 46c36c18528fe2cc780d5206ed80ae8e37d3545d # Diff Start Line 14 WIP transplant and diff-start-line diff --git a/bad b/bad @@ -0,0 +0,0 @@ blah diff --git a/autoland/autoland/transplant.py b/autoland/autoland/transplant.py --- a/autoland/autoland/transplant.py +++ b/autoland/autoland/transplant.py @@ -318,24 +318,58 @@ class PatchTransplant(Transplant): # instead of passing the url to 'hg import' to make ... """.strip())) self.assertEqual( patch.commit_description(), 'WIP transplant and diff-start-line\n' '\n' 'diff --git a/bad b/bad\n' '@@ -0,0 +0,0 @@\n' 'blah')
def test_no_header(self): patch = PatchHelper( io.BytesIO(""" WIP transplant and diff-start-line diff --git a/autoland/autoland/transplant.py b/autoland/autoland/transplant.py --- a/autoland/autoland/transplant.py +++ b/autoland/autoland/transplant.py @@ -318,24 +318,58 @@ class PatchTransplant(Transplant): # instead of passing the url to 'hg import' to make ... """.strip())) self.assertIsNone(patch.header('User')) self.assertEqual(patch.commit_description(), 'WIP transplant and diff-start-line')