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.
8 from platform_util
import (GetPlatforms
,
10 ExtractPlatformFromURL
,
12 PlatformToExtensionType
)
15 class PlatformBundleUtilityTest(unittest
.TestCase
):
16 def testGetPlatforms(self
):
17 self
.assertEqual(('apps', 'extensions'), GetPlatforms())
19 def testGetExtensionTypes(self
):
20 self
.assertEqual(('platform_app', 'extension'), GetExtensionTypes())
22 def testExtractPlatformFromURL(self
):
23 self
.assertEqual('apps', ExtractPlatformFromURL('apps/something'))
24 self
.assertEqual('apps', ExtractPlatformFromURL('apps'))
25 self
.assertEqual('extensions', ExtractPlatformFromURL('extensions/a/b'))
26 self
.assertTrue(ExtractPlatformFromURL('a/b') is None)
27 self
.assertTrue(ExtractPlatformFromURL('app') is None)
29 def testPluralToSingular(self
):
30 self
.assertEqual('app', PluralToSingular('apps'))
31 self
.assertEqual('extension', PluralToSingular('extensions'))
32 self
.assertRaises(AssertionError, PluralToSingular
, 'ab')
34 def testPlatformToExtensionType(self
):
35 self
.assertEqual('platform_app', PlatformToExtensionType('apps'))
36 self
.assertEqual('extension', PlatformToExtensionType('extensions'))
37 self
.assertRaises(AssertionError, PlatformToExtensionType
, 'ab')
39 if __name__
== '__main__':