def test_format_commit(self): tool = MockTool() bot = CommitAnnouncer(tool, "test/directory", "test_password") self.assertEqual( 'https://crrev.com/456789 [email protected] committed "Commit test subject line"', bot._format_commit_detail("""\ 1234commit1234 [email protected] Commit test subject line Multiple lines of description. BUG=654321 Review URL: https://codereview.chromium.org/123456 Cr-Commit-Position: refs/heads/master@{#456789} """)) self.assertEqual( 'https://crrev.com/456789 ' '[email protected] committed "Commit test subject line"', bot._format_commit_detail("""\ 1234commit1234 [email protected] Commit test subject line Multiple lines of description. BUG=654321 Cr-Commit-Position: refs/heads/master@{#456789} """)) self.assertEqual( 'https://crrev.com/1234comm [email protected] committed "Commit test subject line"', bot._format_commit_detail("""\ 1234commit1234 [email protected] Commit test subject line Multiple lines of description. BUG=654321 Review URL: https://codereview.chromium.org/123456 """)) self.assertEqual( 'https://crrev.com/1234comm [email protected] committed "Commit test subject line"', bot._format_commit_detail("""\ 1234commit1234 [email protected] Commit test subject line Multiple lines of description. """)) self.assertEqual( 'https://crrev.com/456789 [email protected] committed "Commit test subject line"', bot._format_commit_detail("""\ 1234commit1234 [email protected] Commit test subject line Multiple lines of description. Review URL: http://fake.review.url Cr-Commit-Position: refs/heads/master@{#000000} BUG=654321 Review URL: https://codereview.chromium.org/123456 Cr-Commit-Position: refs/heads/master@{#456789} """)) self.assertEqual( 'https://crrev.com/456789 [email protected] committed "Commit test subject line" ' '\[email protected]\x03', bot._format_commit_detail("""\ 1234commit1234 [email protected] Commit test subject line Multiple lines of description. BUG=654321 [email protected] Review URL: https://codereview.chromium.org/123456 Cr-Commit-Position: refs/heads/master@{#456789} """)) self.assertEqual( 'https://crrev.com/456789 [email protected] committed "Commit test subject line" ' '\x037NOTRY=true\x03', bot._format_commit_detail("""\ 1234commit1234 [email protected] Commit test subject line Multiple lines of description. BUG=654321 NOTRY=true Review URL: https://codereview.chromium.org/123456 Cr-Commit-Position: refs/heads/master@{#456789} """)) self.assertEqual( 'https://crrev.com/456789 [email protected] committed "Commit test subject line" ' '\x037NOTRY=true [email protected]\x03', bot._format_commit_detail("""\ 1234commit1234 [email protected] Commit test subject line Multiple lines of description. NOTRY=true BUG=654321 [email protected] Review URL: https://codereview.chromium.org/123456 Cr-Commit-Position: refs/heads/master@{#456789} """)) self.assertEqual( 'https://crrev.com/456789 [email protected] committed "Commit test subject line" ' '\[email protected], [email protected], [email protected] notry=TRUE\x03', bot._format_commit_detail("""\ 1234commit1234 [email protected] Commit test subject line Multiple lines of description. BUG=654321 [email protected], [email protected], [email protected] notry=TRUE Review URL: https://codereview.chromium.org/123456 Cr-Commit-Position: refs/heads/master@{#456789} """))
def test_sanitize_string(self): bot = CommitAnnouncer(MockTool(), "test/directory", "test_password") self.assertEqual('normal ascii', bot._sanitize_string('normal ascii')) self.assertEqual('uni\\u0441ode!', bot._sanitize_string(u'uni\u0441ode!'))
def test_format_commit(self): tool = MockWebKitPatch() bot = CommitAnnouncer(tool, "test/directory", "test_password") self.assertEqual( 'https://crrev.com/456789 [email protected] committed "Commit test subject line"', bot._format_commit_detail("""\ 1234commit1234 [email protected] Commit test subject line Multiple lines of description. BUG=654321 Review URL: https://codereview.chromium.org/123456 Cr-Commit-Position: refs/heads/master@{#456789} """)) self.assertEqual( 'https://crrev.com/456789 ' '[email protected] committed "Commit test subject line"', bot._format_commit_detail("""\ 1234commit1234 [email protected] Commit test subject line Multiple lines of description. BUG=654321 Cr-Commit-Position: refs/heads/master@{#456789} """)) self.assertEqual( 'https://crrev.com/1234comm [email protected] committed "Commit test subject line"', bot._format_commit_detail("""\ 1234commit1234 [email protected] Commit test subject line Multiple lines of description. BUG=654321 Review URL: https://codereview.chromium.org/123456 """)) self.assertEqual( 'https://crrev.com/1234comm [email protected] committed "Commit test subject line"', bot._format_commit_detail("""\ 1234commit1234 [email protected] Commit test subject line Multiple lines of description. """)) self.assertEqual( 'https://crrev.com/456789 [email protected] committed "Commit test subject line"', bot._format_commit_detail("""\ 1234commit1234 [email protected] Commit test subject line Multiple lines of description. Review URL: http://fake.review.url Cr-Commit-Position: refs/heads/master@{#000000} BUG=654321 Review URL: https://codereview.chromium.org/123456 Cr-Commit-Position: refs/heads/master@{#456789} """)) self.assertEqual( 'https://crrev.com/456789 [email protected] committed "Commit test subject line" ' '\[email protected]\x03', bot._format_commit_detail("""\ 1234commit1234 [email protected] Commit test subject line Multiple lines of description. BUG=654321 [email protected] Review URL: https://codereview.chromium.org/123456 Cr-Commit-Position: refs/heads/master@{#456789} """)) self.assertEqual( 'https://crrev.com/456789 [email protected] committed "Commit test subject line" ' '\x037NOTRY=true\x03', bot._format_commit_detail("""\ 1234commit1234 [email protected] Commit test subject line Multiple lines of description. BUG=654321 NOTRY=true Review URL: https://codereview.chromium.org/123456 Cr-Commit-Position: refs/heads/master@{#456789} """)) self.assertEqual( 'https://crrev.com/456789 [email protected] committed "Commit test subject line" ' '\x037NOTRY=true [email protected]\x03', bot._format_commit_detail("""\ 1234commit1234 [email protected] Commit test subject line Multiple lines of description. NOTRY=true BUG=654321 [email protected] Review URL: https://codereview.chromium.org/123456 Cr-Commit-Position: refs/heads/master@{#456789} """)) self.assertEqual( 'https://crrev.com/456789 [email protected] committed "Commit test subject line" ' '\[email protected], [email protected], [email protected] notry=TRUE\x03', bot._format_commit_detail("""\ 1234commit1234 [email protected] Commit test subject line Multiple lines of description. BUG=654321 [email protected], [email protected], [email protected] notry=TRUE Review URL: https://codereview.chromium.org/123456 Cr-Commit-Position: refs/heads/master@{#456789} """))
def test_sanitize_string(self): bot = CommitAnnouncer(MockWebKitPatch(), 'test/directory', 'test_password') self.assertEqual('normal ascii', bot._sanitize_string('normal ascii')) self.assertEqual('uni\\u0441ode!', bot._sanitize_string(u'uni\u0441ode!'))
def test_sanitize_string(self): bot = CommitAnnouncer(MockWebKitPatch(), "test/directory", "test_password") self.assertEqual('normal ascii', bot._sanitize_string('normal ascii')) self.assertEqual('uni\\u0441ode!', bot._sanitize_string(u'uni\u0441ode!'))