Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / common / extensions / docs / server2 / samples_data_source_test.py
blob68d4f33b97eaaecc13e9cab3393f19a8f14b6213
1 #!/usr/bin/env python
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.
6 import json
7 import os
8 import sys
9 import unittest
11 from samples_data_source import SamplesDataSource
12 from servlet import Request
14 class SamplesDataSourceTest(unittest.TestCase):
15 def setUp(self):
16 self._base_path = os.path.join(sys.path[0],
17 'test_data',
18 'samples_data_source')
20 def _ReadLocalFile(self, filename):
21 with open(os.path.join(self._base_path, filename), 'r') as f:
22 return f.read()
24 def _FakeGet(self, key):
25 return json.loads(self._ReadLocalFile(key))
27 def testFilterSamples(self):
28 sds = SamplesDataSource({}, {}, '.', Request.ForTest('/'))
29 sds.get = self._FakeGet
30 self.assertEquals(json.loads(self._ReadLocalFile('expected.json')),
31 sds.FilterSamples('samples.json', 'bobaloo'))
33 if __name__ == '__main__':
34 unittest.main()