| 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 from copy import deepcopy | 6 from copy import deepcopy |
| 7 from file_system import FileNotFoundError, StatInfo | 7 from file_system import FileNotFoundError, StatInfo |
| 8 from test_file_system import TestFileSystem | 8 from test_file_system import TestFileSystem |
| 9 import unittest | 9 import unittest |
| 10 | 10 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 'alarms.html': '2', | 105 'alarms.html': '2', |
| 106 }), fs.Stat('extensions/')) | 106 }), fs.Stat('extensions/')) |
| 107 | 107 |
| 108 fs.IncrementStat(path='extensions/alarms.html') | 108 fs.IncrementStat(path='extensions/alarms.html') |
| 109 self.assertEquals(StatInfo('3'), fs.Stat('404.html')) | 109 self.assertEquals(StatInfo('3'), fs.Stat('404.html')) |
| 110 self.assertEquals(StatInfo('3', child_versions={ | 110 self.assertEquals(StatInfo('3', child_versions={ |
| 111 'activeTab.html': '2', | 111 'activeTab.html': '2', |
| 112 'alarms.html': '3', | 112 'alarms.html': '3', |
| 113 }), fs.Stat('extensions/')) | 113 }), fs.Stat('extensions/')) |
| 114 | 114 |
| 115 def testCheckAndReset(self): | |
| 116 fs = TestFileSystem(deepcopy(_TEST_DATA)) | |
| 117 | |
| 118 self.assertTrue(*fs.CheckAndReset()) | |
| 119 self.assertFalse(*fs.CheckAndReset(read_count=1)) | |
| 120 self.assertFalse(*fs.CheckAndReset(stat_count=1)) | |
| 121 | |
| 122 fs.ReadSingle('apps/') | |
| 123 self.assertTrue(*fs.CheckAndReset(read_count=1)) | |
| 124 self.assertFalse(*fs.CheckAndReset(read_count=1)) | |
| 125 self.assertTrue(*fs.CheckAndReset()) | |
| 126 | |
| 127 fs.ReadSingle('apps/') | |
| 128 self.assertFalse(*fs.CheckAndReset(read_count=2)) | |
| 129 | |
| 130 fs.ReadSingle('extensions/') | |
| 131 fs.ReadSingle('extensions/') | |
| 132 self.assertTrue(*fs.CheckAndReset(read_count=2)) | |
| 133 self.assertFalse(*fs.CheckAndReset(read_count=2)) | |
| 134 self.assertTrue(*fs.CheckAndReset()) | |
| 135 | |
| 136 fs.ReadSingle('404.html') | |
| 137 fs.Read(['notfound.html', 'apps/']) | |
| 138 self.assertTrue(*fs.CheckAndReset(read_count=2)) | |
| 139 | |
| 140 fs.Stat('404.html') | |
| 141 fs.Stat('404.html') | |
| 142 fs.Stat('apps/') | |
| 143 self.assertFalse(*fs.CheckAndReset(stat_count=42)) | |
| 144 self.assertFalse(*fs.CheckAndReset(stat_count=42)) | |
| 145 self.assertTrue(*fs.CheckAndReset()) | |
| 146 | |
| 147 fs.ReadSingle('404.html') | |
| 148 fs.Stat('404.html') | |
| 149 fs.Stat('apps/') | |
| 150 self.assertTrue(*fs.CheckAndReset(read_count=1, stat_count=2)) | |
| 151 self.assertTrue(*fs.CheckAndReset()) | |
| 152 | |
| 153 def testMoveTo(self): | 115 def testMoveTo(self): |
| 154 self.assertEqual({'foo': {'a': 'b', 'c': 'd'}}, | 116 self.assertEqual({'foo': {'a': 'b', 'c': 'd'}}, |
| 155 TestFileSystem.MoveTo('foo', {'a': 'b', 'c': 'd'})) | 117 TestFileSystem.MoveTo('foo', {'a': 'b', 'c': 'd'})) |
| 156 self.assertEqual({'foo': {'bar': {'a': 'b', 'c': 'd'}}}, | 118 self.assertEqual({'foo': {'bar': {'a': 'b', 'c': 'd'}}}, |
| 157 TestFileSystem.MoveTo('foo/bar', {'a': 'b', 'c': 'd'})) | 119 TestFileSystem.MoveTo('foo/bar', {'a': 'b', 'c': 'd'})) |
| 158 self.assertEqual({'foo': {'bar': {'baz': {'a': 'b'}}}}, | 120 self.assertEqual({'foo': {'bar': {'baz': {'a': 'b'}}}}, |
| 159 TestFileSystem.MoveTo('foo/bar/baz', {'a': 'b'})) | 121 TestFileSystem.MoveTo('foo/bar/baz', {'a': 'b'})) |
| 160 | 122 |
| 161 if __name__ == '__main__': | 123 if __name__ == '__main__': |
| 162 unittest.main() | 124 unittest.main() |
| OLD | NEW |