| OLD | NEW |
| (Empty) |
| 1 # Copyright (C) 2013 Google Inc. All rights reserved. | |
| 2 # | |
| 3 # Redistribution and use in source and binary forms, with or without | |
| 4 # modification, are permitted provided that the following conditions are | |
| 5 # met: | |
| 6 # | |
| 7 # * Redistributions of source code must retain the above copyright | |
| 8 # notice, this list of conditions and the following disclaimer. | |
| 9 # * Redistributions in binary form must reproduce the above | |
| 10 # copyright notice, this list of conditions and the following disclaimer | |
| 11 # in the documentation and/or other materials provided with the | |
| 12 # distribution. | |
| 13 # | |
| 14 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 15 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 16 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 17 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| 18 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 19 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| 20 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 21 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 22 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 23 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 24 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 25 | |
| 26 import unittest | |
| 27 | |
| 28 from webkitpy.tool.bot.commit_announcer import CommitAnnouncer | |
| 29 from webkitpy.tool.mock_tool import MockWebKitPatch | |
| 30 | |
| 31 | |
| 32 class CommitAnnouncerTest(unittest.TestCase): | |
| 33 | |
| 34 def test_format_commit(self): | |
| 35 tool = MockWebKitPatch() | |
| 36 bot = CommitAnnouncer(tool, 'test/directory', 'test_password') | |
| 37 self.assertEqual( | |
| 38 'https://crrev.com/456789 authorABC@chromium.org committed "Commit t
est subject line"', | |
| 39 bot._format_commit_detail("""\ | |
| 40 1234commit1234 | |
| 41 authorABC@chromium.org | |
| 42 Commit test subject line | |
| 43 Multiple | |
| 44 lines | |
| 45 of | |
| 46 description. | |
| 47 | |
| 48 BUG=654321 | |
| 49 | |
| 50 Review URL: https://codereview.chromium.org/123456 | |
| 51 | |
| 52 Cr-Commit-Position: refs/heads/master@{#456789} | |
| 53 """)) | |
| 54 | |
| 55 self.assertEqual( | |
| 56 'https://crrev.com/456789 ' | |
| 57 'authorABC@chromium.org committed "Commit test subject line"', | |
| 58 bot._format_commit_detail("""\ | |
| 59 1234commit1234 | |
| 60 authorABC@chromium.org | |
| 61 Commit test subject line | |
| 62 Multiple | |
| 63 lines | |
| 64 of | |
| 65 description. | |
| 66 | |
| 67 BUG=654321 | |
| 68 | |
| 69 Cr-Commit-Position: refs/heads/master@{#456789} | |
| 70 """)) | |
| 71 | |
| 72 self.assertEqual( | |
| 73 'https://crrev.com/1234comm authorABC@chromium.org committed "Commit
test subject line"', | |
| 74 bot._format_commit_detail("""\ | |
| 75 1234commit1234 | |
| 76 authorABC@chromium.org | |
| 77 Commit test subject line | |
| 78 Multiple | |
| 79 lines | |
| 80 of | |
| 81 description. | |
| 82 | |
| 83 BUG=654321 | |
| 84 | |
| 85 Review URL: https://codereview.chromium.org/123456 | |
| 86 """)) | |
| 87 | |
| 88 self.assertEqual( | |
| 89 'https://crrev.com/1234comm authorABC@chromium.org committed "Commit
test subject line"', | |
| 90 bot._format_commit_detail("""\ | |
| 91 1234commit1234 | |
| 92 authorABC@chromium.org | |
| 93 Commit test subject line | |
| 94 Multiple | |
| 95 lines | |
| 96 of | |
| 97 description. | |
| 98 """)) | |
| 99 | |
| 100 self.assertEqual( | |
| 101 'https://crrev.com/456789 authorABC@chromium.org committed "Commit t
est subject line"', | |
| 102 bot._format_commit_detail("""\ | |
| 103 1234commit1234 | |
| 104 authorABC@chromium.org | |
| 105 Commit test subject line | |
| 106 Multiple | |
| 107 lines | |
| 108 of | |
| 109 description. | |
| 110 Review URL: http://fake.review.url | |
| 111 Cr-Commit-Position: refs/heads/master@{#000000} | |
| 112 | |
| 113 BUG=654321 | |
| 114 | |
| 115 Review URL: https://codereview.chromium.org/123456 | |
| 116 | |
| 117 Cr-Commit-Position: refs/heads/master@{#456789} | |
| 118 """)) | |
| 119 | |
| 120 self.assertEqual( | |
| 121 'https://crrev.com/456789 authorABC@chromium.org committed "Commit t
est subject line" ' | |
| 122 '\x037TBR=reviewerDEF@chromium.org\x03', | |
| 123 bot._format_commit_detail("""\ | |
| 124 1234commit1234 | |
| 125 authorABC@chromium.org | |
| 126 Commit test subject line | |
| 127 Multiple | |
| 128 lines | |
| 129 of | |
| 130 description. | |
| 131 | |
| 132 BUG=654321 | |
| 133 TBR=reviewerDEF@chromium.org | |
| 134 | |
| 135 Review URL: https://codereview.chromium.org/123456 | |
| 136 | |
| 137 Cr-Commit-Position: refs/heads/master@{#456789} | |
| 138 """)) | |
| 139 | |
| 140 self.assertEqual( | |
| 141 'https://crrev.com/456789 authorABC@chromium.org committed "Commit t
est subject line" ' | |
| 142 '\x037NOTRY=true\x03', | |
| 143 bot._format_commit_detail("""\ | |
| 144 1234commit1234 | |
| 145 authorABC@chromium.org | |
| 146 Commit test subject line | |
| 147 Multiple | |
| 148 lines | |
| 149 of | |
| 150 description. | |
| 151 | |
| 152 BUG=654321 | |
| 153 NOTRY=true | |
| 154 | |
| 155 Review URL: https://codereview.chromium.org/123456 | |
| 156 | |
| 157 Cr-Commit-Position: refs/heads/master@{#456789} | |
| 158 """)) | |
| 159 | |
| 160 self.assertEqual( | |
| 161 'https://crrev.com/456789 authorABC@chromium.org committed "Commit t
est subject line" ' | |
| 162 '\x037NOTRY=true TBR=reviewerDEF@chromium.org\x03', | |
| 163 bot._format_commit_detail("""\ | |
| 164 1234commit1234 | |
| 165 authorABC@chromium.org | |
| 166 Commit test subject line | |
| 167 Multiple | |
| 168 lines | |
| 169 of | |
| 170 description. | |
| 171 | |
| 172 NOTRY=true | |
| 173 BUG=654321 | |
| 174 TBR=reviewerDEF@chromium.org | |
| 175 | |
| 176 Review URL: https://codereview.chromium.org/123456 | |
| 177 | |
| 178 Cr-Commit-Position: refs/heads/master@{#456789} | |
| 179 """)) | |
| 180 | |
| 181 self.assertEqual( | |
| 182 'https://crrev.com/456789 authorABC@chromium.org committed "Commit t
est subject line" ' | |
| 183 '\x037tbr=reviewerDEF@chromium.org, reviewerGHI@chromium.org, review
erJKL@chromium.org notry=TRUE\x03', | |
| 184 bot._format_commit_detail("""\ | |
| 185 1234commit1234 | |
| 186 authorABC@chromium.org | |
| 187 Commit test subject line | |
| 188 Multiple | |
| 189 lines | |
| 190 of | |
| 191 description. | |
| 192 | |
| 193 BUG=654321 | |
| 194 tbr=reviewerDEF@chromium.org, reviewerGHI@chromium.org, reviewerJKL@chromium.org | |
| 195 notry=TRUE | |
| 196 | |
| 197 Review URL: https://codereview.chromium.org/123456 | |
| 198 | |
| 199 Cr-Commit-Position: refs/heads/master@{#456789} | |
| 200 """)) | |
| 201 | |
| 202 def test_sanitize_string(self): | |
| 203 bot = CommitAnnouncer(MockWebKitPatch(), 'test/directory', 'test_passwor
d') | |
| 204 self.assertEqual('normal ascii', bot._sanitize_string('normal ascii')) | |
| 205 self.assertEqual('uni\\u0441ode!', bot._sanitize_string(u'uni\u0441ode!'
)) | |
| OLD | NEW |