Changeset 51436 in webkit
- Timestamp:
- Nov 27, 2009 12:02:05 AM (14 years ago)
- Location:
- trunk/WebKitTools
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKitTools/ChangeLog
r51435 r51436 1 2009-11-27 Adam Barth <abarth@webkit.org> 2 3 Reviewed by Eric Seidel. 4 5 [bzt] Unit test upload commands 6 https://bugs.webkit.org/show_bug.cgi?id=31903 7 8 Adds unit tests for all but two of the upload commands. The two 9 remaining ones are more difficult. I'll return to them later. The 10 goal of these tests is just to run the commands. We can test more 11 detailed behavior later. 12 13 * Scripts/modules/commands/commandtest.py: 14 * Scripts/modules/commands/upload.py: 15 * Scripts/modules/commands/upload_unittest.py: 16 * Scripts/modules/mock.py: Added. 17 * Scripts/modules/mock_bugzillatool.py: 18 1 19 2009-11-26 Adam Barth <abarth@webkit.org> 2 20 -
trunk/WebKitTools/Scripts/modules/commands/commandtest.py
r51405 r51436 29 29 import unittest 30 30 31 from modules.mock import Mock 31 32 from modules.mock_bugzillatool import MockBugzillaTool 32 33 from modules.outputcapture import OutputCapture 33 34 34 35 class CommandsTest(unittest.TestCase): 35 def assert_execute_outputs(self, command, command_args, expected_stdout, expected_stderr=""):36 def assert_execute_outputs(self, command, args, expected_stdout="", expected_stderr="", options=Mock(), tool=MockBugzillaTool()): 36 37 capture = OutputCapture() 37 38 capture.capture_output() 38 command.execute( None, command_args, MockBugzillaTool())39 command.execute(options, args, tool) 39 40 (stdout_string, stderr_string) = capture.restore_output() 40 41 self.assertEqual(stdout_string, expected_stdout) -
trunk/WebKitTools/Scripts/modules/commands/upload.py
r51404 r51436 55 55 from modules.workqueue import WorkQueue, WorkQueueDelegate 56 56 57 # FIXME: Requires unit test. Blocking issue: commit_message_for_this_commit. 57 58 class CommitMessageForCurrentDiff(Command): 58 59 name = "commit-message" … … 181 182 182 183 184 # FIXME: Requires unit test. Blocking issue: too complex for now. 183 185 class CreateBug(Command): 184 186 name = "create-bug" -
trunk/WebKitTools/Scripts/modules/commands/upload_unittest.py
r51405 r51436 34 34 class UploadCommandsTest(CommandsTest): 35 35 def test_mark_fixed(self): 36 self.assert_execute_outputs(MarkFixed(), [43, "Test comment"], "", "") 36 self.assert_execute_outputs(MarkFixed(), [43, "Test comment"]) 37 38 def test_obsolete_attachments(self): 39 self.assert_execute_outputs(ObsoleteAttachments(), [42]) 40 41 def test_post_diff(self): 42 self.assert_execute_outputs(PostDiff(), [42]) -
trunk/WebKitTools/Scripts/modules/mock_bugzillatool.py
r51405 r51436 27 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 28 29 from modules.scm import CommitMessage 30 29 31 class MockBugzilla(): 30 patch1 = { "id": 197, "bug_id": 42, "url": "http://example.com/197" }31 patch2 = { "id": 128, "bug_id": 42, "url": "http://example.com/128" }32 patch1 = { "id": 197, "bug_id": 42, "url": "http://example.com/197", "is_obsolete": False } 33 patch2 = { "id": 128, "bug_id": 42, "url": "http://example.com/128", "is_obsolete": False } 32 34 33 35 def fetch_bug_ids_from_commit_queue(self): … … 42 44 return None 43 45 46 def fetch_attachments_from_bug(self, bug_id): 47 if bug_id == 42: 48 return [self.patch1, self.patch2] 49 return None 50 51 def fetch_patches_from_bug(self, bug_id): 52 if bug_id == 42: 53 return [self.patch1, self.patch2] 54 return None 55 44 56 def close_bug_as_fixed(self, bug_id, comment_text=None): 57 pass 58 59 def obsolete_attachment(self, attachment_id, comment_text=None): 60 pass 61 62 def add_patch_to_bug(self, bug_id, patch_file_object, description, comment_text=None, mark_for_review=False, mark_for_commit_queue=False): 45 63 pass 46 64 … … 57 75 58 76 77 class MockSCM(): 78 def create_patch(self): 79 return "Patch1" 80 81 def commit_ids_from_commitish_arguments(self, args): 82 return ["Commitish1", "Commitish2"] 83 84 def commit_message_for_local_commit(self, commit_id): 85 if commit_id == "Commitish1": 86 return CommitMessage("CommitMessage1\nhttps://bugs.example.org/show_bug.cgi?id=42\n") 87 if commit_id == "Commitish2": 88 return CommitMessage("CommitMessage2\nhttps://bugs.example.org/show_bug.cgi?id=75\n") 89 raise Exception("Bogus commit_id in commit_message_for_local_commit.") 90 91 def create_patch_from_local_commit(self, commit_id): 92 if commit_id == "Commitish1": 93 return "Patch1" 94 if commit_id == "Commitish2": 95 return "Patch2" 96 raise Exception("Bogus commit_id in commit_message_for_local_commit.") 97 98 59 99 class MockBugzillaTool(): 60 100 bugs = MockBugzilla() 61 101 buildbot = MockBuildBot() 102 103 _scm = MockSCM() 104 def scm(self): 105 return self._scm
Note: See TracChangeset
for help on using the changeset viewer.