1 # Copyright (C) 2009 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 # * Neither the name of Google Inc. nor the names of its 14 # contributors may be used to endorse or promote products derived from 15 # this software without specific prior written permission. 16 # 17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 29 from webkitpy.commands.commandtest import CommandsTest 30 from webkitpy.commands.upload import * 31 from webkitpy.mock import Mock 32 from webkitpy.mock_bugzillatool import MockBugzillaTool 33 34 class UploadCommandsTest(CommandsTest): 35 def test_commit_message_for_current_diff(self): 36 tool = MockBugzillaTool() 37 mock_commit_message_for_this_commit = Mock() 38 mock_commit_message_for_this_commit.message = lambda: "Mock message" 39 tool._scm.commit_message_for_this_commit = lambda: mock_commit_message_for_this_commit 40 expected_stdout = "Mock message\n" 41 self.assert_execute_outputs(CommitMessageForCurrentDiff(), [], expected_stdout=expected_stdout, tool=tool) 42 43 def test_clean_pending_commit(self): 44 self.assert_execute_outputs(CleanPendingCommit(), []) 45 46 def test_assign_to_committer(self): 47 tool = MockBugzillaTool() 48 expected_stderr = "Warning, attachment 128 on bug 42 has invalid committer (non-committer (at] example.com)\nBug 77 is already assigned to foo (at] foo.com (None).\nBug 76 has no non-obsolete patches, ignoring.\n" 49 self.assert_execute_outputs(AssignToCommitter(), [], expected_stderr=expected_stderr, tool=tool) 50 tool.bugs.reassign_bug.assert_called_with(42, "eric (at] webkit.org", "Attachment 128 was posted by a committer and has review+, assigning to Eric Seidel for commit.") 51 52 def test_obsolete_attachments(self): 53 expected_stderr = "Obsoleting 2 old patches on bug 42\n" 54 self.assert_execute_outputs(ObsoleteAttachments(), [42], expected_stderr=expected_stderr) 55 56 def test_post(self): 57 expected_stderr = "Running check-webkit-style\nObsoleting 2 old patches on bug 42\n" 58 self.assert_execute_outputs(Post(), [42], expected_stderr=expected_stderr) 59 60 def test_post(self): 61 expected_stderr = "Obsoleting 2 old patches on bug 42\n" 62 self.assert_execute_outputs(LandSafely(), [42], expected_stderr=expected_stderr) 63 64 def test_prepare_diff_with_arg(self): 65 self.assert_execute_outputs(Prepare(), [42]) 66 67 def test_prepare(self): 68 self.assert_execute_outputs(Prepare(), []) 69 70 def test_upload(self): 71 expected_stderr = "Running check-webkit-style\nObsoleting 2 old patches on bug 42\nMOCK: user.open_url: http://example.com/42\n" 72 self.assert_execute_outputs(Upload(), [42], expected_stderr=expected_stderr) 73 74 def test_mark_bug_fixed(self): 75 tool = MockBugzillaTool() 76 tool._scm.last_svn_commit_log = lambda: "r9876 |" 77 options = Mock() 78 options.bug_id = 42 79 expected_stderr = """Bug: <http://example.com/42> Bug with two r+'d and cq+'d patches, one of which has an invalid commit-queue setter. 80 Revision: 9876 81 MOCK: user.open_url: http://example.com/42 82 Adding comment to Bug 42. 83 """ 84 self.assert_execute_outputs(MarkBugFixed(), [], expected_stderr=expected_stderr, tool=tool, options=options) 85 86 def test_edit_changelog(self): 87 self.assert_execute_outputs(EditChangeLogs(), []) 88