~ubuntu-branches/ubuntu/raring/qtwebkit-source/raring-proposed

« back to all changes in this revision

Viewing changes to Tools/Scripts/webkitpy/tool/commands/upload_unittest.py

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-02-18 14:24:18 UTC
  • Revision ID: package-import@ubuntu.com-20130218142418-eon0jmjg3nj438uy
Tags: upstream-2.3
ImportĀ upstreamĀ versionĀ 2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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.thirdparty.mock import Mock
 
30
from webkitpy.tool.commands.commandtest import CommandsTest
 
31
from webkitpy.tool.commands.upload import *
 
32
from webkitpy.tool.mocktool import MockOptions, MockTool
 
33
 
 
34
class UploadCommandsTest(CommandsTest):
 
35
    def test_commit_message_for_current_diff(self):
 
36
        tool = MockTool()
 
37
        expected_stdout = "This is a fake commit message that is at least 50 characters.\n"
 
38
        self.assert_execute_outputs(CommitMessageForCurrentDiff(), [], expected_stdout=expected_stdout, tool=tool)
 
39
 
 
40
    def test_clean_pending_commit(self):
 
41
        self.assert_execute_outputs(CleanPendingCommit(), [])
 
42
 
 
43
    def test_assign_to_committer(self):
 
44
        tool = MockTool()
 
45
        expected_logs = """Warning, attachment 10001 on bug 50000 has invalid committer (non-committer@example.com)
 
46
MOCK reassign_bug: bug_id=50000, assignee=eric@webkit.org
 
47
-- Begin comment --
 
48
Attachment 10001 was posted by a committer and has review+, assigning to Eric Seidel for commit.
 
49
-- End comment --
 
50
Bug 50003 is already assigned to foo@foo.com (None).
 
51
Bug 50002 has no non-obsolete patches, ignoring.
 
52
"""
 
53
        self.assert_execute_outputs(AssignToCommitter(), [], expected_logs=expected_logs, tool=tool)
 
54
 
 
55
    def test_obsolete_attachments(self):
 
56
        expected_logs = "Obsoleting 2 old patches on bug 50000\n"
 
57
        self.assert_execute_outputs(ObsoleteAttachments(), [50000], expected_logs=expected_logs)
 
58
 
 
59
    def test_post(self):
 
60
        options = MockOptions()
 
61
        options.cc = None
 
62
        options.check_style = True
 
63
        options.check_style_filter = None
 
64
        options.comment = None
 
65
        options.description = "MOCK description"
 
66
        options.request_commit = False
 
67
        options.review = True
 
68
        options.suggest_reviewers = False
 
69
        expected_logs = """MOCK: user.open_url: file://...
 
70
Was that diff correct?
 
71
Obsoleting 2 old patches on bug 50000
 
72
MOCK reassign_bug: bug_id=50000, assignee=None
 
73
MOCK add_patch_to_bug: bug_id=50000, description=MOCK description, mark_for_review=True, mark_for_commit_queue=False, mark_for_landing=False
 
74
MOCK: user.open_url: http://example.com/50000
 
75
"""
 
76
        self.assert_execute_outputs(Post(), [50000], options=options, expected_logs=expected_logs)
 
77
 
 
78
    def test_attach_to_bug(self):
 
79
        options = MockOptions()
 
80
        options.comment = "extra comment"
 
81
        options.description = "file description"
 
82
        expected_logs = """MOCK add_attachment_to_bug: bug_id=50000, description=file description filename=None mimetype=None
 
83
-- Begin comment --
 
84
extra comment
 
85
-- End comment --
 
86
"""
 
87
        self.assert_execute_outputs(AttachToBug(), [50000, "path/to/file.txt", "file description"], options=options, expected_logs=expected_logs)
 
88
 
 
89
    def test_attach_to_bug_no_description_or_comment(self):
 
90
        options = MockOptions()
 
91
        options.comment = None
 
92
        options.description = None
 
93
        expected_logs = "MOCK add_attachment_to_bug: bug_id=50000, description=file.txt filename=None mimetype=None\n"
 
94
        self.assert_execute_outputs(AttachToBug(), [50000, "path/to/file.txt"], options=options, expected_logs=expected_logs)
 
95
 
 
96
    def test_land_safely(self):
 
97
        expected_logs = """Obsoleting 2 old patches on bug 50000
 
98
MOCK reassign_bug: bug_id=50000, assignee=None
 
99
MOCK add_patch_to_bug: bug_id=50000, description=Patch for landing, mark_for_review=False, mark_for_commit_queue=False, mark_for_landing=True
 
100
"""
 
101
        self.assert_execute_outputs(LandSafely(), [50000], expected_logs=expected_logs)
 
102
 
 
103
    def test_prepare_diff_with_arg(self):
 
104
        self.assert_execute_outputs(Prepare(), [50000])
 
105
 
 
106
    def test_prepare(self):
 
107
        expected_logs = "MOCK create_bug\nbug_title: Mock user response\nbug_description: Mock user response\ncomponent: MOCK component\ncc: MOCK cc\n"
 
108
        self.assert_execute_outputs(Prepare(), [], expected_logs=expected_logs)
 
109
 
 
110
    def test_upload(self):
 
111
        options = MockOptions()
 
112
        options.cc = None
 
113
        options.check_style = True
 
114
        options.check_style_filter = None
 
115
        options.comment = None
 
116
        options.description = "MOCK description"
 
117
        options.request_commit = False
 
118
        options.review = True
 
119
        options.suggest_reviewers = False
 
120
        expected_logs = """MOCK: user.open_url: file://...
 
121
Was that diff correct?
 
122
Obsoleting 2 old patches on bug 50000
 
123
MOCK reassign_bug: bug_id=50000, assignee=None
 
124
MOCK add_patch_to_bug: bug_id=50000, description=MOCK description, mark_for_review=True, mark_for_commit_queue=False, mark_for_landing=False
 
125
MOCK: user.open_url: http://example.com/50000
 
126
"""
 
127
        self.assert_execute_outputs(Upload(), [50000], options=options, expected_logs=expected_logs)
 
128
 
 
129
    def test_mark_bug_fixed(self):
 
130
        tool = MockTool()
 
131
        tool._scm.last_svn_commit_log = lambda: "r9876 |"
 
132
        options = Mock()
 
133
        options.bug_id = 50000
 
134
        options.comment = "MOCK comment"
 
135
        expected_logs = """Bug: <http://example.com/50000> Bug with two r+'d and cq+'d patches, one of which has an invalid commit-queue setter.
 
136
Revision: 9876
 
137
MOCK: user.open_url: http://example.com/50000
 
138
Is this correct?
 
139
Adding comment to Bug 50000.
 
140
MOCK bug comment: bug_id=50000, cc=None
 
141
--- Begin comment ---
 
142
MOCK comment
 
143
 
 
144
Committed r9876: <http://trac.webkit.org/changeset/9876>
 
145
--- End comment ---
 
146
 
 
147
"""
 
148
        self.assert_execute_outputs(MarkBugFixed(), [], expected_logs=expected_logs, tool=tool, options=options)
 
149
 
 
150
    def test_edit_changelog(self):
 
151
        self.assert_execute_outputs(EditChangeLogs(), [])