Commit 90e73d79 authored by abarth@webkit.org's avatar abarth@webkit.org

2010-07-09 Ojan Vafai <ojan@chromium.org>

        Reviewed by Adam Barth.

        r63004 broke some python tests
        https://bugs.webkit.org/show_bug.cgi?id=42007

        AbstractStep now checks options.no_squash and options.squash, so
        they needed to have real values. Mock would return an object for those,
        which would then act as if the values were True.

        * Scripts/webkitpy/tool/commands/commandtest.py:
        * Scripts/webkitpy/tool/commands/download_unittest.py:
        * Scripts/webkitpy/tool/commands/stepsequence.py:
        * Scripts/webkitpy/tool/commands/upload_unittest.py:
        * Scripts/webkitpy/tool/mocktool.py:
        * Scripts/webkitpy/tool/steps/closebugforlanddiff_unittest.py:
        * Scripts/webkitpy/tool/steps/preparechangelog_unittest.py:
        * Scripts/webkitpy/tool/steps/steps_unittest.py:
        * Scripts/webkitpy/tool/steps/updatechangelogswithreview_unittest.py:
        * Scripts/webkitpy/tool/steps/validatereviewer_unittest.py:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@63020 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent b35cbfdf
2010-07-09 Ojan Vafai <ojan@chromium.org>
Reviewed by Adam Barth.
r63004 broke some python tests
https://bugs.webkit.org/show_bug.cgi?id=42007
AbstractStep now checks options.no_squash and options.squash, so
they needed to have real values. Mock would return an object for those,
which would then act as if the values were True.
* Scripts/webkitpy/tool/commands/commandtest.py:
* Scripts/webkitpy/tool/commands/download_unittest.py:
* Scripts/webkitpy/tool/commands/stepsequence.py:
* Scripts/webkitpy/tool/commands/upload_unittest.py:
* Scripts/webkitpy/tool/mocktool.py:
* Scripts/webkitpy/tool/steps/closebugforlanddiff_unittest.py:
* Scripts/webkitpy/tool/steps/preparechangelog_unittest.py:
* Scripts/webkitpy/tool/steps/steps_unittest.py:
* Scripts/webkitpy/tool/steps/updatechangelogswithreview_unittest.py:
* Scripts/webkitpy/tool/steps/validatereviewer_unittest.py:
2010-07-09 Ojan Vafai <ojan@chromium.org>
Reviewed by Adam Barth.
......
......@@ -29,10 +29,9 @@
import unittest
from webkitpy.common.system.outputcapture import OutputCapture
from webkitpy.tool.mocktool import MockTool
from webkitpy.thirdparty.mock import Mock
from webkitpy.tool.mocktool import MockOptions, MockTool
class CommandsTest(unittest.TestCase):
def assert_execute_outputs(self, command, args, expected_stdout="", expected_stderr="", options=Mock(), tool=MockTool()):
def assert_execute_outputs(self, command, args, expected_stdout="", expected_stderr="", options=MockOptions(), tool=MockTool()):
command.bind_to_tool(tool)
OutputCapture().assert_outputs(self, command.execute, [options, args, tool], expected_stdout=expected_stdout, expected_stderr=expected_stderr)
......@@ -32,7 +32,7 @@ from webkitpy.common.system.outputcapture import OutputCapture
from webkitpy.thirdparty.mock import Mock
from webkitpy.tool.commands.commandtest import CommandsTest
from webkitpy.tool.commands.download import *
from webkitpy.tool.mocktool import MockTool
from webkitpy.tool.mocktool import MockOptions, MockTool
class AbstractRolloutPrepCommandTest(unittest.TestCase):
......@@ -56,7 +56,7 @@ class AbstractRolloutPrepCommandTest(unittest.TestCase):
class DownloadCommandsTest(CommandsTest):
def _default_options(self):
options = Mock()
options = MockOptions()
options.force_clean = False
options.clean = True
options.check_builders = True
......
......@@ -77,6 +77,7 @@ class StepSequence(object):
except ScriptError, e:
if not options.quiet:
log(e.message_with_output())
raise e
if options.parent_command:
command = tool.command_by_name(options.parent_command)
command.handle_script_error(tool, state, e)
......
......@@ -29,7 +29,7 @@
from webkitpy.thirdparty.mock import Mock
from webkitpy.tool.commands.commandtest import CommandsTest
from webkitpy.tool.commands.upload import *
from webkitpy.tool.mocktool import MockTool
from webkitpy.tool.mocktool import MockOptions, MockTool
class UploadCommandsTest(CommandsTest):
def test_commit_message_for_current_diff(self):
......@@ -51,7 +51,7 @@ class UploadCommandsTest(CommandsTest):
self.assert_execute_outputs(ObsoleteAttachments(), [42], expected_stderr=expected_stderr)
def test_post(self):
options = Mock()
options = MockOptions()
options.description = "MOCK description"
options.request_commit = False
options.review = True
......@@ -80,7 +80,7 @@ MOCK: user.open_url: http://example.com/42
self.assert_execute_outputs(Prepare(), [], expected_stderr=expected_stderr)
def test_upload(self):
options = Mock()
options = MockOptions()
options.description = "MOCK description"
options.request_commit = False
options.review = True
......
......@@ -515,6 +515,7 @@ class MockStatusServer(object):
def results_url_for_status(self, status_id):
return "http://dummy_url"
class MockExecute(Mock):
def __init__(self, should_log):
self._should_log = should_log
......@@ -537,6 +538,11 @@ class MockExecute(Mock):
return "MOCK output of child process"
class MockOptions(Mock):
no_squash = False
squash = False
class MockRietveld():
def __init__(self, executive, dryrun=False):
......
......@@ -29,13 +29,12 @@
import unittest
from webkitpy.common.system.outputcapture import OutputCapture
from webkitpy.thirdparty.mock import Mock
from webkitpy.tool.mocktool import MockTool
from webkitpy.tool.mocktool import MockOptions, MockTool
from webkitpy.tool.steps.closebugforlanddiff import CloseBugForLandDiff
class CloseBugForLandDiffTest(unittest.TestCase):
def test_empty_state(self):
capture = OutputCapture()
step = CloseBugForLandDiff(MockTool(), Mock())
step = CloseBugForLandDiff(MockTool(), MockOptions())
expected_stderr = "Committed r49824: <http://trac.webkit.org/changeset/49824>\nNo bug id provided.\n"
capture.assert_outputs(self, step.run, [{"commit_text" : "Mock commit text"}], expected_stderr=expected_stderr)
......@@ -31,15 +31,14 @@ import unittest
from webkitpy.common.checkout.changelog_unittest import ChangeLogTest
from webkitpy.common.system.outputcapture import OutputCapture
from webkitpy.thirdparty.mock import Mock
from webkitpy.tool.mocktool import MockTool
from webkitpy.tool.mocktool import MockOptions, MockTool
from webkitpy.tool.steps.preparechangelog import PrepareChangeLog
class PrepareChangeLogTest(ChangeLogTest):
def test_ensure_bug_url(self):
capture = OutputCapture()
step = PrepareChangeLog(MockTool(), Mock())
step = PrepareChangeLog(MockTool(), MockOptions())
changelog_contents = u"%s\n%s" % (self._new_entry_boilerplate, self._example_changelog)
changelog_path = self._write_tmp_file_with_contents(changelog_contents.encode("utf-8"))
state = {
......
......@@ -30,8 +30,7 @@ import unittest
from webkitpy.common.system.outputcapture import OutputCapture
from webkitpy.common.config.ports import WebKitPort
from webkitpy.thirdparty.mock import Mock
from webkitpy.tool.mocktool import MockTool
from webkitpy.tool.mocktool import MockOptions, MockTool
from webkitpy.tool.steps.update import Update
from webkitpy.tool.steps.runtests import RunTests
from webkitpy.tool.steps.promptforbugortitle import PromptForBugOrTitle
......@@ -42,13 +41,13 @@ class StepsTest(unittest.TestCase):
if not tool:
tool = MockTool()
if not options:
options = Mock()
options = MockOptions()
if not state:
state = {}
step(tool, options).run(state)
def test_update_step(self):
options = Mock()
options = MockOptions()
options.update = True
expected_stderr = "Updating working directory\n"
OutputCapture().assert_outputs(self, self._run_step, [Update, options], expected_stderr=expected_stderr)
......@@ -63,7 +62,7 @@ class StepsTest(unittest.TestCase):
OutputCapture().assert_outputs(self, self._run_step, [RunTests], expected_stderr=expected_stderr)
def test_runtests_leopard_commit_queue_hack(self):
mock_options = Mock()
mock_options = MockOptions()
mock_options.non_interactive = True
step = RunTests(MockTool(log_executive=True), mock_options)
# FIXME: We shouldn't use a real port-object here, but there is too much to mock at the moment.
......
......@@ -29,18 +29,17 @@
import unittest
from webkitpy.common.system.outputcapture import OutputCapture
from webkitpy.thirdparty.mock import Mock
from webkitpy.tool.mocktool import MockTool
from webkitpy.tool.mocktool import MockOptions, MockTool
from webkitpy.tool.steps.updatechangelogswithreviewer import UpdateChangeLogsWithReviewer
class UpdateChangeLogsWithReviewerTest(unittest.TestCase):
def test_guess_reviewer_from_bug(self):
capture = OutputCapture()
step = UpdateChangeLogsWithReviewer(MockTool(), Mock())
step = UpdateChangeLogsWithReviewer(MockTool(), MockOptions())
expected_stderr = "0 reviewed patches on bug 75, cannot infer reviewer.\n"
capture.assert_outputs(self, step._guess_reviewer_from_bug, [75], expected_stderr=expected_stderr)
def test_empty_state(self):
capture = OutputCapture()
step = UpdateChangeLogsWithReviewer(MockTool(), Mock())
step = UpdateChangeLogsWithReviewer(MockTool(), MockOptions())
capture.assert_outputs(self, step.run, [{}])
......@@ -30,8 +30,7 @@ import unittest
from webkitpy.common.checkout.changelog import ChangeLogEntry
from webkitpy.common.system.outputcapture import OutputCapture
from webkitpy.thirdparty.mock import Mock
from webkitpy.tool.mocktool import MockTool
from webkitpy.tool.mocktool import MockOptions, MockTool
from webkitpy.tool.steps.validatereviewer import ValidateReviewer
class ValidateReviewerTest(unittest.TestCase):
......@@ -48,7 +47,7 @@ class ValidateReviewerTest(unittest.TestCase):
self.assertEqual(step._has_valid_reviewer(entry), expected)
def test_has_valid_reviewer(self):
step = ValidateReviewer(MockTool(), Mock())
step = ValidateReviewer(MockTool(), MockOptions())
self._test_review_text(step, "Reviewed by Eric Seidel.", True)
self._test_review_text(step, "Reviewed by Eric Seidel", True) # Not picky about the '.'
self._test_review_text(step, "Reviewed by Eric.", False)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment