Debian Codegraph @

tests/test_extension_manager.py

raw
1 # --------------------------------------------------------------------------------------------
2 # Copyright (c) Microsoft Corporation. All rights reserved.
3 # Licensed under the MIT License. See License.txt in the project root for license information.
4 # --------------------------------------------------------------------------------------------
5
6 import logging
7 import unittest
8 from azure_functions_devops_build.extension.extension_manager import ExtensionManager
9 from ._config import CREATE_DEVOPS_OBJECTS, ORGANIZATION_NAME, PROJECT_NAME
10 from ._helpers import get_credentials
11
12 class TestExtensionManager(unittest.TestCase):
13
14 @classmethod
15 def setUpClass(cls):
16 logging.disable(logging.CRITICAL)
17
18 @classmethod
19 def tearDownClass(cls):
20 logging.disable(logging.NOTSET)
21
22 def setUp(self):
23 self.extension_manager = ExtensionManager(organization_name=ORGANIZATION_NAME, creds=get_credentials())
24
25 def test_list_extensions(self):
26 extensions = self.extension_manager.list_extensions()
27 self.assertIsNotNone(extensions)
28 self.assertGreaterEqual(len(extensions), 0)
29
30 @unittest.skipIf(
31 not CREATE_DEVOPS_OBJECTS,
32 "Set CREATE_DEVOPS_OBJECTS to True if you want to create resources for unit testing"
33 )
34 def test_create_extension(self):
35 new_extension = self.extension_manager.create_extension('AzureAppServiceSetAppSettings', 'hboelman')
36 self.assertTrue(new_extension.publisher_id == 'hboelman')
37 self.assertTrue(new_extension.extension_id == 'AzureAppServiceSetAppSettings')
38
39 if __name__ == '__main__':
40 unittest.main()