OLD | NEW |
| (Empty) |
1 # Copyright (c) 2010 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 datetime import datetime | |
30 import unittest2 as unittest | |
31 | |
32 from webkitpy.common.system.outputcapture import OutputCapture | |
33 from webkitpy.thirdparty.mock import Mock | |
34 from webkitpy.tool.bot.feeders import * | |
35 from webkitpy.tool.mocktool import MockTool | |
36 | |
37 | |
38 class FeedersTest(unittest.TestCase): | |
39 def test_commit_queue_feeder(self): | |
40 feeder = CommitQueueFeeder(MockTool()) | |
41 expected_logs = """Warning, attachment 10001 on bug 50000 has invalid co
mmitter (non-committer@example.com) | |
42 Warning, attachment 10001 on bug 50000 has invalid committer (non-committer@exam
ple.com) | |
43 MOCK setting flag 'commit-queue' to '-' on attachment '10001' with comment 'Reje
cting attachment 10001 from commit-queue.\n\nnon-committer@example.com does not
have committer permissions according to http://trac.webkit.org/browser/trunk/Too
ls/Scripts/webkitpy/common/config/committers.py. | |
44 | |
45 - If you do not have committer rights please read http://webkit.org/coding/contr
ibuting.html for instructions on how to use bugzilla flags. | |
46 | |
47 - If you have committer rights please correct the error in Tools/Scripts/webkitp
y/common/config/committers.py by adding yourself to the file (no review needed).
The commit-queue restarts itself every 2 hours. After restart the commit-queu
e will correctly respect your committer rights.' | |
48 MOCK: update_work_items: commit-queue [10005, 10000] | |
49 Feeding commit-queue items [10005, 10000] | |
50 """ | |
51 OutputCapture().assert_outputs(self, feeder.feed, expected_logs=expected
_logs) | |
52 | |
53 def _mock_attachment(self, is_rollout, attach_date): | |
54 attachment = Mock() | |
55 attachment.is_rollout = lambda: is_rollout | |
56 attachment.attach_date = lambda: attach_date | |
57 return attachment | |
58 | |
59 def test_patch_cmp(self): | |
60 long_ago_date = datetime(1900, 1, 21) | |
61 recent_date = datetime(2010, 1, 21) | |
62 attachment1 = self._mock_attachment(is_rollout=False, attach_date=recent
_date) | |
63 attachment2 = self._mock_attachment(is_rollout=False, attach_date=long_a
go_date) | |
64 attachment3 = self._mock_attachment(is_rollout=True, attach_date=recent_
date) | |
65 attachment4 = self._mock_attachment(is_rollout=True, attach_date=long_ag
o_date) | |
66 attachments = [attachment1, attachment2, attachment3, attachment4] | |
67 expected_sort = [attachment4, attachment3, attachment2, attachment1] | |
68 queue = CommitQueueFeeder(MockTool()) | |
69 attachments.sort(queue._patch_cmp) | |
70 self.assertEqual(attachments, expected_sort) | |
71 | |
72 def test_patches_with_acceptable_review_flag(self): | |
73 class MockPatch(object): | |
74 def __init__(self, patch_id, review): | |
75 self.id = patch_id | |
76 self.review = lambda: review | |
77 | |
78 feeder = CommitQueueFeeder(MockTool()) | |
79 patches = [MockPatch(1, None), MockPatch(2, '-'), MockPatch(3, "+")] | |
80 self.assertEqual([patch.id for patch in feeder._patches_with_acceptable_
review_flag(patches)], [1, 3]) | |
OLD | NEW |