OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Unit tests for rietveld.py.""" | 6 """Unit tests for rietveld.py.""" |
7 | 7 |
8 import logging | 8 import logging |
9 import os | 9 import os |
10 import sys | 10 import sys |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 | 274 |
275 def test_bad_svn_properties(self): | 275 def test_bad_svn_properties(self): |
276 try: | 276 try: |
277 rietveld.Rietveld.parse_svn_properties(u'\n', 'foo') | 277 rietveld.Rietveld.parse_svn_properties(u'\n', 'foo') |
278 self.fail() | 278 self.fail() |
279 except rietveld.patch.UnsupportedPatchFormat, e: | 279 except rietveld.patch.UnsupportedPatchFormat, e: |
280 self.assertEquals('foo', e.filename) | 280 self.assertEquals('foo', e.filename) |
281 # TODO(maruel): Change with no diff, only svn property change: | 281 # TODO(maruel): Change with no diff, only svn property change: |
282 # http://codereview.chromium.org/6462019/ | 282 # http://codereview.chromium.org/6462019/ |
283 | 283 |
| 284 def test_search_all_empty(self): |
| 285 url = ( |
| 286 '/search?format=json' |
| 287 '&base=base' |
| 288 '&created_after=2010-01-02' |
| 289 '&created_before=2010-01-01' |
| 290 '&modified_after=2010-02-02' |
| 291 '&modified_before=2010-02-01' |
| 292 '&owner=owner%40example.com' |
| 293 '&reviewer=reviewer%40example.com' |
| 294 '&closed=2' |
| 295 '&commit=2' |
| 296 '&private=2' |
| 297 '&keys_only=True' |
| 298 '&with_messages=True' |
| 299 '&limit=23') |
| 300 self.requests = [ |
| 301 (url, '{}'), |
| 302 ] |
| 303 results = list(self.rietveld.search( |
| 304 'owner@example.com', |
| 305 'reviewer@example.com', |
| 306 'base', |
| 307 True, |
| 308 True, |
| 309 True, |
| 310 '2010-01-01', |
| 311 '2010-01-02', |
| 312 '2010-02-01', |
| 313 '2010-02-02', |
| 314 23, |
| 315 True, |
| 316 True, |
| 317 )) |
| 318 self.assertEquals([], results) |
| 319 |
| 320 def test_results_cursor(self): |
| 321 # Verify cursor iteration is transparent. |
| 322 self.requests = [ |
| 323 ('/search?format=json&base=base', |
| 324 rietveld.json.dumps({ |
| 325 'cursor': 'MY_CURSOR', |
| 326 'results': [{'foo': 'bar'}, {'foo': 'baz'}], |
| 327 })), |
| 328 ('/search?format=json&base=base&cursor=MY_CURSOR', |
| 329 rietveld.json.dumps({ |
| 330 'cursor': 'NEXT', |
| 331 'results': [{'foo': 'prout'}], |
| 332 })), |
| 333 ('/search?format=json&base=base&cursor=NEXT', |
| 334 rietveld.json.dumps({ |
| 335 'cursor': 'VOID', |
| 336 'results': [], |
| 337 })), |
| 338 ] |
| 339 expected = [ |
| 340 {'foo': 'bar'}, |
| 341 {'foo': 'baz'}, |
| 342 {'foo': 'prout'}, |
| 343 ] |
| 344 for i in self.rietveld.search(base='base'): |
| 345 self.assertEquals(expected.pop(0), i) |
| 346 self.assertEquals([], expected) |
| 347 |
284 | 348 |
285 if __name__ == '__main__': | 349 if __name__ == '__main__': |
286 logging.basicConfig(level=logging.ERROR) | 350 logging.basicConfig(level=logging.ERROR) |
287 unittest.main() | 351 unittest.main() |
OLD | NEW |