cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / chrome / common / extensions / docs / server2 / samples_model_test.py
blob2d3a6be0cf8463c7d7c816f9b43cf0c919d7a576
1 #!/usr/bin/env python
2 # Copyright 2014 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.
6 import json
7 import os
8 import unittest
10 from future import Future
11 from server_instance import ServerInstance
12 from test_file_system import TestFileSystem
13 from test_util import Server2Path
16 def _ReadLocalFile(filename):
17 base_path = Server2Path('test_data', 'samples_data_source')
18 with open(os.path.join(base_path, filename), 'r') as f:
19 return f.read()
22 class _FakeCache(object):
23 def __init__(self, obj):
24 self._cache = obj
26 def GetFromFileListing(self, _):
27 return Future(value=self._cache)
30 class SamplesModelSourceTest(unittest.TestCase):
31 def setUp(self):
32 server_instance = ServerInstance.ForTest(file_system=TestFileSystem({}))
33 self._samples_model = server_instance.platform_bundle.GetSamplesModel(
34 'apps')
35 self._samples_model._samples_cache = _FakeCache(json.loads(_ReadLocalFile(
36 'samples.json')))
38 def testFilterSamples(self):
39 self.assertEquals(json.loads(_ReadLocalFile('expected.json')),
40 self._samples_model.FilterSamples('bobaloo').Get())
42 if __name__ == '__main__':
43 unittest.main()