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

Side by Side Diff: chrome/common/extensions/docs/server2/samples_data_source_test.py

Issue 437323003: Docserver: Factor SamplesModel out of SamplesDataSource (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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 unified diff | Download patch
OLDNEW
(Empty)
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.
5
6 import json
7 import os
8 import sys
9 import unittest
10
11 from samples_data_source import SamplesDataSource
12 from servlet import Request
13 from test_util import Server2Path
14
15
16 class SamplesDataSourceTest(unittest.TestCase):
17 def setUp(self):
18 self._base_path = Server2Path('test_data', 'samples_data_source')
19
20 def _ReadLocalFile(self, filename):
21 with open(os.path.join(self._base_path, filename), 'r') as f:
22 return f.read()
23
24 def _FakeGet(self, key):
25 return json.loads(self._ReadLocalFile(key))
26
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'))
32
33 if __name__ == '__main__':
34 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698