def test_format_commit(self): tool = MockTool() bot = CommitAnnouncer(tool, "test_password") self.assertEqual( 'r456789 http://crrev.com/123456 [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 git-svn-id: svn://svn.chromium.org/blink/trunk@456789 bbb929c8-8fbe-4397-9dbb-9b2b20218538 """)) self.assertEqual( 'r456789 https://chromium.googlesource.com/chromium/blink/+/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 git-svn-id: svn://svn.chromium.org/blink/trunk@456789 bbb929c8-8fbe-4397-9dbb-9b2b20218538 """)) self.assertEqual( 'http://crrev.com/123456 [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://chromium.googlesource.com/chromium/blink/+/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( 'r456789 http://crrev.com/123456 [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 git-svn-id: svn://svn.chromium.org/blink/trunk@000000 Fake-SVN-number BUG=654321 Review URL: https://codereview.chromium.org/123456 git-svn-id: svn://svn.chromium.org/blink/trunk@456789 bbb929c8-8fbe-4397-9dbb-9b2b20218538 """)) self.assertEqual( 'r456789 http://crrev.com/123456 [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 git-svn-id: svn://svn.chromium.org/blink/trunk@456789 bbb929c8-8fbe-4397-9dbb-9b2b20218538 """)) self.assertEqual( 'r456789 http://crrev.com/123456 [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 git-svn-id: svn://svn.chromium.org/blink/trunk@456789 bbb929c8-8fbe-4397-9dbb-9b2b20218538 """)) self.assertEqual( 'r456789 http://crrev.com/123456 [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 git-svn-id: svn://svn.chromium.org/blink/trunk@456789 bbb929c8-8fbe-4397-9dbb-9b2b20218538 """)) self.assertEqual( 'r456789 http://crrev.com/123456 [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 git-svn-id: svn://svn.chromium.org/blink/trunk@456789 bbb929c8-8fbe-4397-9dbb-9b2b20218538 """))
def test_sanitize_string(self): bot = CommitAnnouncer(MockTool(), "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 = 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_format_commit(self): tool = MockTool() bot = CommitAnnouncer(tool, "test_password") self.assertEqual( '[email protected] committed "Commit test subject line" http://crrev.com/123456 https://src.chromium.org/viewvc/blink?view=revision&revision=456789', 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 git-svn-id: svn://svn.chromium.org/blink/trunk@456789 bbb929c8-8fbe-4397-9dbb-9b2b20218538 """)) self.assertEqual( '[email protected] committed "Commit test subject line" https://chromium.googlesource.com/chromium/blink/+/1234comm https://src.chromium.org/viewvc/blink?view=revision&revision=456789', bot._format_commit_detail("""\ 1234commit1234 [email protected] Commit test subject line Multiple lines of description. BUG=654321 [email protected] git-svn-id: svn://svn.chromium.org/blink/trunk@456789 bbb929c8-8fbe-4397-9dbb-9b2b20218538 """)) self.assertEqual( '[email protected] committed "Commit test subject line" http://crrev.com/123456 ', 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 """)) self.assertEqual( '[email protected] committed "Commit test subject line" https://chromium.googlesource.com/chromium/blink/+/1234comm ', bot._format_commit_detail("""\ 1234commit1234 [email protected] Commit test subject line Multiple lines of description. """)) self.assertEqual( '[email protected] committed "Commit test subject line" http://crrev.com/123456 https://src.chromium.org/viewvc/blink?view=revision&revision=456789', bot._format_commit_detail("""\ 1234commit1234 [email protected] Commit test subject line Multiple lines of description. Review URL: http://fake.review.url git-svn-id: svn://svn.chromium.org/blink/trunk@000000 Fake-SVN-number BUG=654321 [email protected] Review URL: https://codereview.chromium.org/123456 git-svn-id: svn://svn.chromium.org/blink/trunk@456789 bbb929c8-8fbe-4397-9dbb-9b2b20218538 """))
def test_sanitize_string(self): bot = CommitAnnouncer(MockTool(), "test_password") self.assertEqual("normal ascii", bot._sanitize_string("normal ascii")) self.assertEqual("uni\\u0441ode!", bot._sanitize_string(u"uni\u0441ode!"))