Chromium Code Reviews| Index: chrome/common/extensions/docs/server2/availability_finder_test.py |
| diff --git a/chrome/common/extensions/docs/server2/availability_finder_test.py b/chrome/common/extensions/docs/server2/availability_finder_test.py |
| new file mode 100755 |
| index 0000000000000000000000000000000000000000..d8736ae33b887570a33bd2310a071aa5abf78dcb |
| --- /dev/null |
| +++ b/chrome/common/extensions/docs/server2/availability_finder_test.py |
| @@ -0,0 +1,105 @@ |
| +#!/usr/bin/env python |
| +# Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +import json |
| +import os |
| +import unittest |
| + |
| +from availability_finder import AvailabilityFinder |
| +from compiled_file_system import CompiledFileSystem |
| +from object_store_creator import ObjectStoreCreator |
| +from test_branch_utility import TestBranchUtility |
| +from test_file_system import TestFileSystem |
| + |
| +def _LoadJSON(name, mode='rb'): |
| + return json.load( |
| + open(os.path.join('test_data', 'availability_finder', name), mode)) |
| + |
| +def _CreateFileSystem(version): |
| + branch = _GetBranchNumberForVersion(version) |
| + return TestFileSystem(_LoadJSON('test_avail_filesystem.json')[branch]) |
| + |
| +def _GetBranchNumberForVersion(version): |
| + return _LoadJSON('test_avail_branch_list.json')[str(version)] |
| + |
| +class AvailabilityInfo(object): |
|
not at google - send to devlin
2013/06/05 00:24:09
this isn't used anywhere -
generally speaking ple
epeterson
2013/06/17 20:05:49
Done.
|
| + def __init__(self, channel, version): |
| + self.channel = channel |
| + self.version = version |
| + |
| +class _FakeChromeVersionUtility(object): |
| + def GetLatestVersionNumber(self): |
| + return 28 |
| + |
| + def GetBranchNumberForVersion(self, version): |
| + return _GetBranchNumberForVersion(version) |
| + |
| +class AvailabilityFinderTest(unittest.TestCase): |
| + def setUp(self): |
| + self._avail_ds_factory = AvailabilityFinder.Factory( |
| + ObjectStoreCreator.ForTest(), |
| + CompiledFileSystem.Factory( |
| + TestFileSystem(_LoadJSON('test_avail_filesystem.json')['trunk']), |
|
not at google - send to devlin
2013/06/05 00:24:09
put this file system in python not JSON.
epeterson
2013/06/17 20:05:49
Done, at least for the tests that I added. Should
not at google - send to devlin
2013/06/19 15:57:37
Nah don't worry about it, certainly not in this pa
|
| + ObjectStoreCreator.ForTest()), |
| + TestBranchUtility(), |
| + _CreateFileSystem) |
| + self._avail_ds = self._avail_ds_factory.Create() |
| + |
| + def testGetApiAvailability(self): |
| + self.assertEqual('stable', |
| + self._avail_ds.GetApiAvailability('earlyAPI1').channel) |
| + self.assertEqual('10', |
| + self._avail_ds.GetApiAvailability('earlyAPI1').version) |
| + self.assertEqual('trunk', |
| + self._avail_ds.GetApiAvailability('earlyAPI2').channel) |
| + self.assertEqual(None, |
| + self._avail_ds.GetApiAvailability('earlyAPI2').version) |
| + self.assertEquals('stable', |
| + self._avail_ds.GetApiAvailability('tabs').channel) |
| + self.assertEquals(18, |
| + self._avail_ds.GetApiAvailability('tabs').version) |
| + self.assertEquals('stable', |
| + self._avail_ds.GetApiAvailability('bookmarks').channel) |
| + self.assertEquals(21, |
| + self._avail_ds.GetApiAvailability('bookmarks').version) |
| + self.assertEquals('stable', |
| + self._avail_ds.GetApiAvailability('windows').channel) |
| + self.assertEquals(23, |
| + self._avail_ds.GetApiAvailability('windows').version) |
| + self.assertEquals('beta', |
| + self._avail_ds.GetApiAvailability('storage').channel) |
| + self.assertEquals(27, |
| + self._avail_ds.GetApiAvailability('storage').version) |
| + self.assertEquals('stable', |
| + self._avail_ds.GetApiAvailability('alarms').channel) |
| + self.assertEquals(24, |
| + self._avail_ds.GetApiAvailability('alarms').version) |
| + self.assertEquals('dev', |
| + self._avail_ds.GetApiAvailability('sync').channel) |
| + self.assertEquals(28, |
| + self._avail_ds.GetApiAvailability('sync').version) |
| + self.assertEquals('dev', |
| + self._avail_ds.GetApiAvailability('cookies').channel) |
| + self.assertEquals(28, |
| + self._avail_ds.GetApiAvailability('cookies').version) |
| + self.assertEquals('trunk', |
| + self._avail_ds.GetApiAvailability('notReallyBetaAPI').channel) |
| + self.assertEquals('trunk', |
| + self._avail_ds.GetApiAvailability('notReallyBetaAPI').version) |
| + self.assertEquals('trunk', |
| + self._avail_ds.GetApiAvailability('trunkAPI').channel) |
| + self.assertEquals('trunk', |
| + self._avail_ds.GetApiAvailability('trunkAPI').version) |
| + self.assertEquals('stable', |
| + self._avail_ds.GetApiAvailability('menus').channel) |
| + self.assertEquals(6, |
| + self._avail_ds.GetApiAvailability('menus').version) |
| + self.assertEquals('stable', |
| + self._avail_ds.GetApiAvailability('idle').channel) |
| + self.assertEquals(5, |
| + self._avail_ds.GetApiAvailability('idle').version) |
| + |
| +if __name__ == '__main__': |
| + unittest.main() |