Skip to content
Permalink
Browse files
2009-11-20 Adam Barth <abarth@webkit.org>
        Reviewed by Eric Seidel.

        Unit test query commands
        https://bugs.webkit.org/show_bug.cgi?id=31755

        These tests are pretty rough, but hopefully they'll grow.

        * Scripts/modules/commands/queries_unittest.py: Added.
        * Scripts/modules/mock_bugzillatool.py: Added.
        * Scripts/run-webkit-unittests:

Canonical link: https://commits.webkit.org/42707@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@51278 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Adam Barth committed Nov 21, 2009
1 parent c813598 commit 3fac6684bd34a9fd38737d88a411a7a1fae2a268
@@ -1,3 +1,16 @@
2009-11-20 Adam Barth <abarth@webkit.org>

Reviewed by Eric Seidel.

Unit test query commands
https://bugs.webkit.org/show_bug.cgi?id=31755

These tests are pretty rough, but hopefully they'll grow.

* Scripts/modules/commands/queries_unittest.py: Added.
* Scripts/modules/mock_bugzillatool.py: Added.
* Scripts/run-webkit-unittests:

2009-11-20 Eric Seidel <eric@webkit.org>

Reviewed by Adam Barth.
@@ -0,0 +1,46 @@
# Copyright (C) 2009 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import unittest

from modules.commands.queries import *
from modules.mock_bugzillatool import *

class QueryCommandsTest(unittest.TestCase):
def test_bugs_to_commit(self):
BugsToCommit().execute(None, None, MockBugzillaTool())

def test_patches_to_commit(self):
PatchesToCommit().execute(None, None, MockBugzillaTool())

def test_reviewed_patches(self):
args = [42]
ReviewedPatches().execute(None, args, MockBugzillaTool())

def test_tree_status(self):
TreeStatus().execute(None, None, MockBugzillaTool())
@@ -0,0 +1,58 @@
# Copyright (C) 2009 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

class MockBugzilla():
patch1 = { "id": 197, "bug_id": 42, "url": "http://example.com/197" }
patch2 = { "id": 128, "bug_id": 42, "url": "http://example.com/128" }

def fetch_bug_ids_from_commit_queue(self):
return [42, 75]

def fetch_patches_from_commit_queue(self):
return [self.patch1, self.patch2]

def fetch_reviewed_patches_from_bug(self, bug_id):
if bug_id == 42:
return [self.patch1, self.patch2]
return None


class MockBuildBot():
def builder_statuses(self):
return [{
"name": "Builder1",
"is_green": True
}, {
"name": "Builder2",
"is_green": True
}]


class MockBugzillaTool():
bugs = MockBugzilla()
buildbot = MockBuildBot()
@@ -32,6 +32,7 @@ import unittest
from modules.bugzilla_unittest import *
from modules.buildbot_unittest import *
from modules.changelogs_unittest import *
from modules.commands.queries_unittest import *
from modules.committers_unittest import *
from modules.cpp_style_unittest import *
from modules.diff_parser_unittest import *

0 comments on commit 3fac668

Please sign in to comment.