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 import os 30 import unittest 31 32 from webkitpy.common.checkout.changelog_unittest import ChangeLogTest 33 from webkitpy.common.system.outputcapture import OutputCapture 34 from webkitpy.tool.mocktool import MockOptions, MockTool 35 from webkitpy.tool.steps.preparechangelog import PrepareChangeLog 36 37 38 class PrepareChangeLogTest(ChangeLogTest): 39 def test_ensure_bug_url(self): 40 capture = OutputCapture() 41 step = PrepareChangeLog(MockTool(), MockOptions()) 42 changelog_contents = u"%s\n%s" % (self._new_entry_boilerplate, self._example_changelog) 43 changelog_path = self._write_tmp_file_with_contents(changelog_contents.encode("utf-8")) 44 state = { 45 "bug_title": "Example title", 46 "bug_id": 1234, 47 "changelogs": [changelog_path], 48 } 49 capture.assert_outputs(self, step.run, [state]) 50 actual_contents = self._read_file_contents(changelog_path, "utf-8") 51 expected_message = "Example title\n http://example.com/1234" 52 expected_contents = changelog_contents.replace("Need a short description and bug URL (OOPS!)", expected_message) 53 os.remove(changelog_path) 54 self.assertEquals(actual_contents, expected_contents) 55