| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 pending_manager.py.""" | 6 """Unit tests for pending_manager.py.""" |
| 7 | 7 |
| 8 import logging | 8 import logging |
| 9 import os | 9 import os |
| 10 import re | 10 import re |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 super(TestPendingManager, self).setUp() | 60 super(TestPendingManager, self).setUp() |
| 61 self.root_dir = ROOT_DIR | 61 self.root_dir = ROOT_DIR |
| 62 | 62 |
| 63 def testLoadSave(self): | 63 def testLoadSave(self): |
| 64 pc = pending_manager.PendingManager( | 64 pc = pending_manager.PendingManager( |
| 65 context.Context(None, None, mocks.AsyncPushMock(self)), | 65 context.Context(None, None, mocks.AsyncPushMock(self)), |
| 66 [fake.FakeVerifier(base.SUCCEEDED)], | 66 [fake.FakeVerifier(base.SUCCEEDED)], |
| 67 []) | 67 []) |
| 68 filename = os.path.join(self.root_dir, 'foo.json') | 68 filename = os.path.join(self.root_dir, 'foo.json') |
| 69 empty = """{ | 69 empty = """{ |
| 70 "__persistent_module__": "pending_manager", | |
| 71 "__persistent_type__": "PendingQueue", | 70 "__persistent_type__": "PendingQueue", |
| 72 "pending_commits": [] | 71 "pending_commits": [] |
| 73 } | 72 } |
| 74 """ | 73 """ |
| 75 write(filename, empty) | 74 write(filename, empty) |
| 76 try: | 75 try: |
| 77 pc.load(filename) | 76 pc.load(filename) |
| 78 self.assertEquals(pc.queue.pending_commits, []) | 77 self.assertEquals(pc.queue.pending_commits, []) |
| 79 pc.save(filename) | 78 pc.save(filename) |
| 80 self.assertEquals(trim(empty), trim(read(filename))) | 79 self.assertEquals(trim(empty), trim(read(filename))) |
| (...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 "commit(u'foo\\n\\nReview URL: http://nowhere/31337', " | 625 "commit(u'foo\\n\\nReview URL: http://nowhere/31337', " |
| 627 "'author@example.com')"]) | 626 "'author@example.com')"]) |
| 628 | 627 |
| 629 | 628 |
| 630 if __name__ == '__main__': | 629 if __name__ == '__main__': |
| 631 logging.basicConfig( | 630 logging.basicConfig( |
| 632 level=[logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG][ | 631 level=[logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG][ |
| 633 min(sys.argv.count('-v'), 3)], | 632 min(sys.argv.count('-v'), 3)], |
| 634 format='%(levelname)5s %(module)15s(%(lineno)3d): %(message)s') | 633 format='%(levelname)5s %(module)15s(%(lineno)3d): %(message)s') |
| 635 unittest.main() | 634 unittest.main() |
| OLD | NEW |