• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (C) 2011 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
29import logging
30
31from webkitpy.common.net.layouttestresults import LayoutTestResults
32from webkitpy.common.net import layouttestresults_unittest
33
34_log = logging.getLogger(__name__)
35
36
37class MockBuild(object):
38    def __init__(self, build_number, revision, is_green):
39        self._number = build_number
40        self._revision = revision
41        self._is_green = is_green
42
43class MockBuilder(object):
44    def __init__(self, name):
45        self._name = name
46
47    def name(self):
48        return self._name
49
50    def build(self, build_number):
51        return MockBuild(build_number=build_number, revision=1234, is_green=False)
52
53    def results_url(self):
54        return "http://example.com/builders/%s/results" % self.name()
55
56    def accumulated_results_url(self):
57        return "http://example.com/f/builders/%s/results/layout-test-results" % self.name()
58
59    def latest_layout_test_results_url(self):
60        return self.accumulated_results_url()
61
62    def latest_layout_test_results(self):
63        return LayoutTestResults.results_from_string(layouttestresults_unittest.LayoutTestResultsTest.example_full_results_json)
64
65class MockBuildBot(object):
66    def __init__(self):
67        self._mock_builder1_status = {
68            "name": "Builder1",
69            "is_green": True,
70            "activity": "building",
71        }
72        self._mock_builder2_status = {
73            "name": "Builder2",
74            "is_green": True,
75            "activity": "idle",
76        }
77
78    def builder_with_name(self, name):
79        return MockBuilder(name)
80
81    def builder_statuses(self):
82        return [
83            self._mock_builder1_status,
84            self._mock_builder2_status,
85        ]
86
87    def light_tree_on_fire(self):
88        self._mock_builder2_status["is_green"] = False
89