OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import json | 6 import json |
7 import os | 7 import os |
8 import sys | 8 import sys |
9 import unittest | 9 import unittest |
10 | 10 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
68 | 68 |
69 def Create(self, *args, **kwargs): | 69 def Create(self, *args, **kwargs): |
70 return self | 70 return self |
71 | 71 |
72 def get(self, key, disable_refs=False): | 72 def get(self, key, disable_refs=False): |
73 if key not in self._json: | 73 if key not in self._json: |
74 raise FileNotFoundError(key) | 74 raise FileNotFoundError(key) |
75 return self._json[key] | 75 return self._json[key] |
76 | 76 |
77 | 77 |
78 class _FakeNamespace(object): | |
79 | |
80 def __init__(self): | |
81 self.documentation_options = {} | |
82 | |
83 | |
78 class _FakeAPIModels(object): | 84 class _FakeAPIModels(object): |
79 | 85 |
80 def __init__(self, names): | 86 def __init__(self, names): |
81 self._names = names | 87 self._names = names |
82 | 88 |
83 def GetNames(self): | 89 def GetNames(self): |
84 return self._names | 90 return self._names |
85 | 91 |
92 def GetModel(self, name): | |
93 return Future(value=_FakeNamespace()) | |
ahernandez
2014/03/26 22:03:32
I needed to return a namespace object so the addit
| |
94 | |
86 | 95 |
87 class _FakeTemplateCache(object): | 96 class _FakeTemplateCache(object): |
88 | 97 |
89 def GetFromFile(self, key): | 98 def GetFromFile(self, key): |
90 return Future(value='handlebar %s' % key) | 99 return Future(value='handlebar %s' % key) |
91 | 100 |
92 | 101 |
93 class APIDataSourceTest(unittest.TestCase): | 102 class APIDataSourceTest(unittest.TestCase): |
94 | 103 |
95 def setUp(self): | 104 def setUp(self): |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
289 # Check that the second event has addListener defined. | 298 # Check that the second event has addListener defined. |
290 self.assertEquals('noRules', dict_['events'][1]['name']) | 299 self.assertEquals('noRules', dict_['events'][1]['name']) |
291 self.assertEquals('add_rules_tester', dict_['name']) | 300 self.assertEquals('add_rules_tester', dict_['name']) |
292 self.assertEquals('noRules', dict_['events'][1]['name']) | 301 self.assertEquals('noRules', dict_['events'][1]['name']) |
293 self.assertEquals('callback', | 302 self.assertEquals('callback', |
294 dict_['events'][0]['byName']['addListener'][ | 303 dict_['events'][0]['byName']['addListener'][ |
295 'parameters'][0]['name']) | 304 'parameters'][0]['name']) |
296 | 305 |
297 if __name__ == '__main__': | 306 if __name__ == '__main__': |
298 unittest.main() | 307 unittest.main() |
OLD | NEW |