OLD | NEW |
| (Empty) |
1 # Copyright (c) 2012 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.tool.commands.chromechannels import ChromeChannels | |
30 from webkitpy.tool.commands.commandtest import CommandsTest | |
31 from webkitpy.tool.mocktool import MockTool | |
32 from webkitpy.common.net.omahaproxy import OmahaProxy | |
33 | |
34 | |
35 class MockOmahaProxy(OmahaProxy): | |
36 revisions = [{"commit": 20, "channel": "canary", "platform": "Mac", "date":
"07/04/76"}, | |
37 {"commit": 20, "channel": "canary", "platform": "Windows", "dat
e": "07/04/76"}, | |
38 {"commit": 25, "channel": "dev", "platform": "Mac", "date": "07
/01/76"}, | |
39 {"commit": 30, "channel": "dev", "platform": "Windows", "date":
"03/29/82"}, | |
40 {"commit": 30, "channel": "dev", "platform": "Linux", "date": "
03/29/82"}, | |
41 {"commit": 15, "channel": "beta", "platform": "Windows", "date"
: "07/04/67"}, | |
42 {"commit": 15, "channel": "beta", "platform": "Linux", "date":
"07/04/67"}, | |
43 {"commit": 10, "channel": "stable", "platform": "Windows", "dat
e": "07/01/67"}, | |
44 {"commit": 20, "channel": "stable", "platform": "Linux", "date"
: "09/16/10"}, | |
45 ] | |
46 | |
47 def get_revisions(self): | |
48 return self.revisions | |
49 | |
50 | |
51 class TestableChromeChannels(ChromeChannels): | |
52 def __init__(self): | |
53 ChromeChannels.__init__(self) | |
54 self._omahaproxy = MockOmahaProxy() | |
55 | |
56 | |
57 class ChromeChannelsTest(CommandsTest): | |
58 | |
59 single_bug_expectations = { | |
60 50001: """50001 Bug with a patch needing review. (r35) | |
61 ... not yet released in any Chrome channels. | |
62 """, | |
63 50002: """50002 The third bug | |
64 ... has too confusing a commit history to parse, skipping | |
65 """, | |
66 50003: """50003 The fourth bug | |
67 ... does not appear to have an associated commit. | |
68 """, | |
69 50004: """50004 The fifth bug (r15) | |
70 canary: Mac, Windows | |
71 dev: Mac, Windows, Linux | |
72 beta: Windows, Linux | |
73 stable: Linux | |
74 """} | |
75 | |
76 def test_single_bug(self): | |
77 testable_chrome_channels = TestableChromeChannels() | |
78 tool = MockTool() | |
79 testable_chrome_channels.bind_to_tool(tool) | |
80 revisions = testable_chrome_channels._omahaproxy.get_revisions() | |
81 for bug_id, expectation in self.single_bug_expectations.items(): | |
82 self.assertEqual(testable_chrome_channels._channels_for_bug(revision
s, testable_chrome_channels._tool.bugs.fetch_bug(bug_id)), | |
83 expectation) | |
84 | |
85 def test_with_query(self): | |
86 expected_stdout = \ | |
87 """50001 Bug with a patch needing review. (r35) | |
88 ... not yet released in any Chrome channels. | |
89 50002 The third bug | |
90 ... has too confusing a commit history to parse, skipping | |
91 50003 The fourth bug | |
92 ... does not appear to have an associated commit. | |
93 50004 The fifth bug (r15) | |
94 canary: Mac, Windows | |
95 dev: Mac, Windows, Linux | |
96 beta: Windows, Linux | |
97 stable: Linux | |
98 """ | |
99 self.assert_execute_outputs(TestableChromeChannels(), ["foo"], expected_
stdout=expected_stdout) | |
OLD | NEW |