def create_file_system(revision=None): '''Creates a MockFileSystem at |revision| by applying that many |updates| to it. ''' mock_file_system = MockFileSystem(TestFileSystem(test_data)) for update in updates[:revision]: mock_file_system.Update(update) return mock_file_system
def create_file_system(revision=None): '''Creates a MockFileSystem at |revision| by applying that many |updates| to it. ''' mock_file_system = MockFileSystem(TestFileSystem(test_data)) updates_for_revision = (updates if revision is None else updates[:int(revision)]) for update in updates_for_revision: mock_file_system.Update(update) return mock_file_system
def create_file_system(commit=None): '''Creates a MockFileSystem at |commit| by applying that many |updates| to it. ''' mock_file_system = MockFileSystem(TestFileSystem(test_data)) updates_for_commit = (updates if commit is None else updates[:int(commit)]) for update in updates_for_commit: mock_file_system.Update(update) return mock_file_system
def testUpdates(self): fs = MockFileSystem(TestFileSystem(deepcopy(_TEST_DATA))) self.assertEqual(StatInfo('0', child_versions={ '404.html': '0', 'apps/': '0', 'extensions/': '0' }), fs.Stat('')) self.assertEqual(StatInfo('0'), fs.Stat('404.html')) self.assertEqual(StatInfo('0', child_versions={ 'a11y.html': '0', 'about_apps.html': '0', 'fakedir/': '0', }), fs.Stat('apps/')) self.assertEqual('404.html contents', fs.ReadSingle('404.html').Get()) fs.Update({ '404.html': 'New version!' }) self.assertEqual(StatInfo('1', child_versions={ '404.html': '1', 'apps/': '0', 'extensions/': '0' }), fs.Stat('')) self.assertEqual(StatInfo('1'), fs.Stat('404.html')) self.assertEqual(StatInfo('0', child_versions={ 'a11y.html': '0', 'about_apps.html': '0', 'fakedir/': '0', }), fs.Stat('apps/')) self.assertEqual('New version!', fs.ReadSingle('404.html').Get()) fs.Update({ '404.html': 'Newer version!', 'apps': { 'fakedir': { 'file.html': 'yo' } } }) self.assertEqual(StatInfo('2', child_versions={ '404.html': '2', 'apps/': '2', 'extensions/': '0' }), fs.Stat('')) self.assertEqual(StatInfo('2'), fs.Stat('404.html')) self.assertEqual(StatInfo('2', child_versions={ 'a11y.html': '0', 'about_apps.html': '0', 'fakedir/': '2', }), fs.Stat('apps/')) self.assertEqual(StatInfo('0'), fs.Stat('apps/a11y.html')) self.assertEqual(StatInfo('2', child_versions={ 'file.html': '2' }), fs.Stat('apps/fakedir/')) self.assertEqual(StatInfo('2'), fs.Stat('apps/fakedir/file.html')) self.assertEqual(StatInfo('0', child_versions={ 'activeTab.html': '0', 'alarms.html': '0' }), fs.Stat('extensions/')) self.assertEqual('Newer version!', fs.ReadSingle('404.html').Get()) self.assertEqual('yo', fs.ReadSingle('apps/fakedir/file.html').Get())