Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4483)

Unified Diff: chrome/common/extensions/docs/server2/test_file_system_test.py

Issue 151883009: Docserver: Make MockFileSystem not iterate over the entire file system as part (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/docs/server2/test_file_system_test.py
diff --git a/chrome/common/extensions/docs/server2/test_file_system_test.py b/chrome/common/extensions/docs/server2/test_file_system_test.py
index f1a10d77cb7d21dd73f1fa5fd81407b2a7a1ffaa..de0c5325f89a450a876735083797bbed47b8e4b9 100755
--- a/chrome/common/extensions/docs/server2/test_file_system_test.py
+++ b/chrome/common/extensions/docs/server2/test_file_system_test.py
@@ -101,6 +101,11 @@ class TestFileSystemTest(unittest.TestCase):
fs = TestFileSystem(deepcopy(_TEST_DATA))
self.assertRaises(FileNotFoundError, fs.Stat, 'foo')
self.assertRaises(FileNotFoundError, fs.Stat, '404.html/')
+ self.assertEquals(StatInfo('0', child_versions={
+ '404.html': '0',
+ 'apps/': '0',
+ 'extensions/': '0',
+ }), fs.Stat(''))
self.assertEquals(StatInfo('0'), fs.Stat('404.html'))
self.assertEquals(StatInfo('0', child_versions={
'activeTab.html': '0',
@@ -108,6 +113,11 @@ class TestFileSystemTest(unittest.TestCase):
}), fs.Stat('extensions/'))
fs.IncrementStat()
+ self.assertEquals(StatInfo('1', child_versions={
+ '404.html': '1',
+ 'apps/': '1',
+ 'extensions/': '1',
+ }), fs.Stat(''))
self.assertEquals(StatInfo('1'), fs.Stat('404.html'))
self.assertEquals(StatInfo('1', child_versions={
'activeTab.html': '1',
@@ -115,6 +125,11 @@ class TestFileSystemTest(unittest.TestCase):
}), fs.Stat('extensions/'))
fs.IncrementStat(path='404.html')
+ self.assertEquals(StatInfo('2', child_versions={
+ '404.html': '2',
+ 'apps/': '1',
+ 'extensions/': '1',
+ }), fs.Stat(''))
self.assertEquals(StatInfo('2'), fs.Stat('404.html'))
self.assertEquals(StatInfo('1', child_versions={
'activeTab.html': '1',
@@ -122,26 +137,56 @@ class TestFileSystemTest(unittest.TestCase):
}), fs.Stat('extensions/'))
fs.IncrementStat()
+ self.assertEquals(StatInfo('3', child_versions={
+ '404.html': '3',
+ 'apps/': '2',
+ 'extensions/': '2',
+ }), fs.Stat(''))
self.assertEquals(StatInfo('3'), fs.Stat('404.html'))
self.assertEquals(StatInfo('2', child_versions={
'activeTab.html': '2',
'alarms.html': '2',
}), fs.Stat('extensions/'))
- fs.IncrementStat(path='extensions/')
- self.assertEquals(StatInfo('3'), fs.Stat('404.html'))
+ # It doesn't make sense to increment the version of directories. Directory
+ # versions are derived from the version of files within them.
+ self.assertRaises(ValueError, fs.IncrementStat, path='')
+ self.assertRaises(ValueError, fs.IncrementStat, path='extensions/')
self.assertEquals(StatInfo('3', child_versions={
+ '404.html': '3',
+ 'apps/': '2',
+ 'extensions/': '2',
+ }), fs.Stat(''))
+ self.assertEquals(StatInfo('3'), fs.Stat('404.html'))
+ self.assertEquals(StatInfo('2', child_versions={
'activeTab.html': '2',
'alarms.html': '2',
}), fs.Stat('extensions/'))
fs.IncrementStat(path='extensions/alarms.html')
+ self.assertEquals(StatInfo('3', child_versions={
+ '404.html': '3',
+ 'apps/': '2',
+ 'extensions/': '3',
+ }), fs.Stat(''))
self.assertEquals(StatInfo('3'), fs.Stat('404.html'))
self.assertEquals(StatInfo('3', child_versions={
'activeTab.html': '2',
'alarms.html': '3',
}), fs.Stat('extensions/'))
+ fs.IncrementStat(path='extensions/activeTab.html', by=3)
+ self.assertEquals(StatInfo('5', child_versions={
+ '404.html': '3',
+ 'apps/': '2',
+ 'extensions/': '5',
+ }), fs.Stat(''))
+ self.assertEquals(StatInfo('3'), fs.Stat('404.html'))
+ self.assertEquals(StatInfo('5', child_versions={
+ 'activeTab.html': '5',
+ 'alarms.html': '3',
+ }), fs.Stat('extensions/'))
+
def testMoveTo(self):
self.assertEqual({'foo': {'a': 'b', 'c': 'd'}},
MoveTo('foo', {'a': 'b', 'c': 'd'}))

Powered by Google App Engine
This is Rietveld 408576698