| OLD | NEW |
| 1 # Copyright (C) 2011 Google Inc. All rights reserved. | 1 # Copyright (C) 2011 Google Inc. All rights reserved. |
| 2 # | 2 # |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
| 5 # met: | 5 # met: |
| 6 # | 6 # |
| 7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
| 9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
| 10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 | 53 |
| 54 | 54 |
| 55 class MockServer(object): | 55 class MockServer(object): |
| 56 def __init__(self): | 56 def __init__(self): |
| 57 self.tool = MockTool() | 57 self.tool = MockTool() |
| 58 self.tool.executive = MockExecutive(should_log=True) | 58 self.tool.executive = MockExecutive(should_log=True) |
| 59 self.tool.filesystem.files[TestPortFactory.path_to_generic_test_expectat
ions_file()] = "" | 59 self.tool.filesystem.files[TestPortFactory.path_to_generic_test_expectat
ions_file()] = "" |
| 60 | 60 |
| 61 | 61 |
| 62 # The real GardeningHTTPRequestHandler has a constructor that's too hard to | 62 # The real GardeningHTTPRequestHandler has a constructor that's too hard to |
| 63 # call in a unit test, so we create a subclass that's easier to constrcut. | 63 # call in a unit test, so we create a subclass that's easier to construct. |
| 64 class TestGardeningHTTPRequestHandler(GardeningHTTPRequestHandler): | 64 class TestGardeningHTTPRequestHandler(GardeningHTTPRequestHandler): |
| 65 def __init__(self, server): | 65 def __init__(self, server): |
| 66 self.server = server | 66 self.server = server |
| 67 self.body = None | 67 self.body = None |
| 68 | 68 |
| 69 def _expectations_updater(self): | 69 def _expectations_updater(self): |
| 70 return GardeningExpectationsUpdater(self.server.tool, TestPortFactory.cr
eate()) | 70 return GardeningExpectationsUpdater(self.server.tool, TestPortFactory.cr
eate()) |
| 71 | 71 |
| 72 def read_entity_body(self): | 72 def read_entity_body(self): |
| 73 return self.body if self.body else '' | 73 return self.body if self.body else '' |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 self._post_to_path('/lastroll', expected_stderr=expected_stderr, expecte
d_stdout='== Begin Response ==\n3\n== End Response ==\n', server=server) | 114 self._post_to_path('/lastroll', expected_stderr=expected_stderr, expecte
d_stdout='== Begin Response ==\n3\n== End Response ==\n', server=server) |
| 115 self._post_to_path('/lastroll', expected_stderr=expected_stderr, expecte
d_stdout='== Begin Response ==\n0\n== End Response ==\n', server=server) | 115 self._post_to_path('/lastroll', expected_stderr=expected_stderr, expecte
d_stdout='== Begin Response ==\n0\n== End Response ==\n', server=server) |
| 116 | 116 |
| 117 def disabled_test_rollout(self): | 117 def disabled_test_rollout(self): |
| 118 expected_stderr = "MOCK run_command: ['echo', 'rollout', '--force-clean'
, '--non-interactive', '2314', 'MOCK rollout reason'], cwd=/mock-checkout\n" | 118 expected_stderr = "MOCK run_command: ['echo', 'rollout', '--force-clean'
, '--non-interactive', '2314', 'MOCK rollout reason'], cwd=/mock-checkout\n" |
| 119 expected_stdout = "== Begin Response ==\nsuccess\n== End Response ==\n" | 119 expected_stdout = "== Begin Response ==\nsuccess\n== End Response ==\n" |
| 120 self._post_to_path("/rollout?revision=2314&reason=MOCK+rollout+reason",
expected_stderr=expected_stderr, expected_stdout=expected_stdout) | 120 self._post_to_path("/rollout?revision=2314&reason=MOCK+rollout+reason",
expected_stderr=expected_stderr, expected_stdout=expected_stdout) |
| 121 | 121 |
| 122 def disabled_test_rebaselineall(self): | 122 def disabled_test_rebaselineall(self): |
| 123 expected_stderr = "MOCK run_command: ['echo', 'rebaseline-json'], cwd=/m
ock-checkout, input={\"user-scripts/another-test.html\":{\"%s\": [%s]}}\n" | 123 expected_stderr = "MOCK run_command: ['echo', 'rebaseline-json'], cwd=/m
ock-checkout, input={\"user-scripts/another-test.html\":{\"%s\": [%s]}}\n" |
| 124 expected_stdout = "== Begin Response ==\nsuccess\n== End Response ==\n" | 124 expected_stdout = "== Begin Response ==\n{result_code: 0}\n== End Respon
se ==\n" |
| 125 server = MockServer() | 125 server = MockServer() |
| 126 | 126 |
| 127 self.output = ['{"add": [], "delete": []}', ''] | 127 self.output = ['{"add": [], "delete": []}', ''] |
| 128 | 128 |
| 129 def run_command(args, cwd=None, input=None, **kwargs): | 129 def run_command(args, cwd=None, input=None, **kwargs): |
| 130 print >> sys.stderr, "MOCK run_command: %s, cwd=%s, input=%s" % (arg
s, cwd, input) | 130 print >> sys.stderr, "MOCK run_command: %s, cwd=%s, input=%s" % (arg
s, cwd, input) |
| 131 return self.output.pop(0) | 131 return self.output.pop(0) |
| 132 | 132 |
| 133 server.tool.executive.run_command = run_command | 133 server.tool.executive.run_command = run_command |
| 134 self._post_to_path("/rebaselineall", body='{"user-scripts/another-test.h
tml":{"MOCK builder": ["txt","png"]}}', expected_stderr=expected_stderr % ('MOCK
builder', '"txt","png"'), expected_stdout=expected_stdout, server=server) | 134 self._post_to_path("/rebaselineall", body='{"user-scripts/another-test.h
tml":{"MOCK builder": ["txt","png"]}}', expected_stderr=expected_stderr % ('MOCK
builder', '"txt","png"'), expected_stdout=expected_stdout, server=server) |
| 135 | 135 |
| 136 self._post_to_path("/rebaselineall", body='{"user-scripts/another-test.h
tml":{"MOCK builder (Debug)": ["txt","png"]}}', expected_stderr=expected_stderr
% ('MOCK builder (Debug)', '"txt","png"'), expected_stdout=expected_stdout) | 136 self._post_to_path("/rebaselineall", body='{"user-scripts/another-test.h
tml":{"MOCK builder (Debug)": ["txt","png"]}}', expected_stderr=expected_stderr
% ('MOCK builder (Debug)', '"txt","png"'), expected_stdout=expected_stdout) |
| OLD | NEW |