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
4 # found in the LICENSE file.
11 from appengine_wrappers
import files
12 from fake_fetchers
import ConfigureFakeFetchers
13 from github_file_system
import GithubFileSystem
14 from object_store_creator
import ObjectStoreCreator
15 from test_util
import Server2Path
18 class GithubFileSystemTest(unittest
.TestCase
):
20 ConfigureFakeFetchers()
21 self
._base
_path
= Server2Path('test_data', 'github_file_system')
22 self
._file
_system
= GithubFileSystem
.CreateChromeAppsSamples(
23 ObjectStoreCreator
.ForTest())
25 def _ReadLocalFile(self
, filename
):
26 with
open(os
.path
.join(self
._base
_path
, filename
), 'r') as f
:
30 self
.assertEqual(json
.loads(self
._ReadLocalFile
('expected_list.json')),
31 self
._file
_system
.Read(['']).Get())
34 self
.assertEqual(self
._ReadLocalFile
('expected_read.txt'),
35 self
._file
_system
.ReadSingle('analytics/launch.js').Get())
38 self
.assertEqual(0, self
._file
_system
.Stat('zipball').version
)
40 def testKeyGeneration(self
):
41 self
.assertEqual(0, len(files
.GetBlobKeys()))
42 self
._file
_system
.ReadSingle('analytics/launch.js').Get()
43 self
.assertEqual(1, len(files
.GetBlobKeys()))
44 self
._file
_system
.ReadSingle('analytics/main.css').Get()
45 self
.assertEqual(1, len(files
.GetBlobKeys()))
47 if __name__
== '__main__':