當前位置: 首頁>>代碼示例>>Python>>正文


Python Loader.list_available_services方法代碼示例

本文整理匯總了Python中botocore.loaders.Loader.list_available_services方法的典型用法代碼示例。如果您正苦於以下問題:Python Loader.list_available_services方法的具體用法?Python Loader.list_available_services怎麽用?Python Loader.list_available_services使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在botocore.loaders.Loader的用法示例。


在下文中一共展示了Loader.list_available_services方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_load_service_model

# 需要導入模塊: from botocore.loaders import Loader [as 別名]
# 或者: from botocore.loaders.Loader import list_available_services [as 別名]
    def test_load_service_model(self):
        class FakeLoader(object):
            def load_file(self, name):
                return ['loaded data']

        loader = Loader(extra_search_paths=['foo'],
                        file_loader=FakeLoader(),
                        include_default_search_paths=False)
        loader.determine_latest_version = mock.Mock(return_value='2015-03-01')
        loader.list_available_services = mock.Mock(return_value=['baz'])
        loaded = loader.load_service_model('baz', type_name='service-2')
        self.assertEqual(loaded, ['loaded data'])
開發者ID:henrysher,項目名稱:botocorev063p,代碼行數:14,代碼來源:test_loaders.py

示例2: test_load_service_model_enforces_case

# 需要導入模塊: from botocore.loaders import Loader [as 別名]
# 或者: from botocore.loaders.Loader import list_available_services [as 別名]
    def test_load_service_model_enforces_case(self):
        class FakeLoader(object):
            def load_file(self, name):
                return ['loaded data']

        loader = Loader(extra_search_paths=['foo'],
                        file_loader=FakeLoader(),
                        include_default_search_paths=False)
        loader.determine_latest_version = mock.Mock(return_value='2015-03-01')
        loader.list_available_services = mock.Mock(return_value=['baz'])

        with self.assertRaises(ValidationError):
            loader.load_service_model('BAZ', type_name='service-2')
開發者ID:henrysher,項目名稱:botocorev063p,代碼行數:15,代碼來源:test_loaders.py

示例3: test_load_service_model_uses_provided_type_name

# 需要導入模塊: from botocore.loaders import Loader [as 別名]
# 或者: from botocore.loaders.Loader import list_available_services [as 別名]
    def test_load_service_model_uses_provided_type_name(self):
        loader = Loader(extra_search_paths=['foo'],
                        file_loader=mock.Mock(),
                        include_default_search_paths=False)
        loader.list_available_services = mock.Mock(return_value=['baz'])

        # Should have a) the unknown service name and b) list of valid
        # service names.
        provided_type_name = 'not-service-2'
        with self.assertRaisesRegexp(UnknownServiceError,
                                     'Unknown service.*BAZ.*baz'):
            loader.load_service_model(
                'BAZ', type_name=provided_type_name)

        loader.list_available_services.assert_called_with(provided_type_name)
開發者ID:AdColony-Engineering,項目名稱:botocore,代碼行數:17,代碼來源:test_loaders.py

示例4: test_load_service_model_enforces_case

# 需要導入模塊: from botocore.loaders import Loader [as 別名]
# 或者: from botocore.loaders.Loader import list_available_services [as 別名]
    def test_load_service_model_enforces_case(self):
        class FakeLoader(object):
            def load_file(self, name):
                return ['loaded data']

        loader = Loader(extra_search_paths=['foo'],
                        file_loader=FakeLoader(),
                        include_default_search_paths=False)
        loader.determine_latest_version = mock.Mock(return_value='2015-03-01')
        loader.list_available_services = mock.Mock(return_value=['baz'])

        # Should have a) the unknown service name and b) list of valid
        # service names.
        with self.assertRaisesRegexp(UnknownServiceError,
                                     'Unknown service.*BAZ.*baz'):
            loader.load_service_model('BAZ', type_name='service-2')
開發者ID:brint,項目名稱:botocore,代碼行數:18,代碼來源:test_loaders.py

示例5: LoaderTestCase

# 需要導入模塊: from botocore.loaders import Loader [as 別名]
# 或者: from botocore.loaders.Loader import list_available_services [as 別名]
class LoaderTestCase(BaseEnvVar):
    def setUp(self):
        super(LoaderTestCase, self).setUp()
        self.data_path = os.path.join(os.path.dirname(__file__), 'data')
        self.environ['BOTO_DATA_PATH'] = self.data_path
        self.loader = Loader(data_path=self.environ['BOTO_DATA_PATH'])

        # Make sure the cache is clear.
        self.loader._cache.clear()

    def test_data_path_not_required(self):
        loader = Loader()
        self.assertEqual(loader.data_path, '')
        loader.data_path = 'foo:bar'
        self.assertEqual(loader.data_path, 'foo:bar')

    def test_get_search_paths(self):
        paths = self.loader.get_search_paths()
        self.assertTrue(self.data_path in paths)

    def test_determine_latest_no_version(self):
        path = self.loader.determine_latest('someservice')
        self.assertEqual(path, os.path.join('someservice',
                                            '2013-08-21.normal'))

    def test_determine_latest_with_version(self):
        path = self.loader.determine_latest(
            'someservice',
            api_version='2012-10-01'
        )
        self.assertEqual(path, os.path.join('someservice',
                                            '2012-10-01.normal'))

    def test_determine_latest_with_version_the_wrong_way(self):
        with self.assertRaises(ApiVersionNotFoundError):
            self.loader.determine_latest('someservice/2012-10-01')

    def test_determine_latest_with_version_not_found(self):
        with self.assertRaises(ApiVersionNotFoundError):
            path = self.loader.determine_latest(
                'someservice',
                api_version='2010-02-02'
            )

    def test_load_data_plain_file(self):
        data = self.loader.load_data('foo')
        self.assertEqual(data['test_key_1'], 'test_value_1')

    def test_load_data_plain_file_nonexistant(self):
        with self.assertRaises(DataNotFoundError):
            data = self.loader.load_data('i_totally_dont_exist')

    def test_load_service_model_latest_without_version(self):
        data = self.loader.load_service_model('someservice')
        self.assertEqual(data['api_version'], '2013-08-21')

    def test_load_service_model_with_version(self):
        data = self.loader.load_service_model(
            'someservice',
            api_version='2012-10-01'
        )
        self.assertEqual(data['api_version'], '2012-10-01')

    def test_load_service_model_version_not_found(self):
        with self.assertRaises(ApiVersionNotFoundError):
            data = self.loader.load_service_model(
                'someservice',
                api_version='2010-02-02'
            )

    def test_load_service_model_data_path_order(self):
        # There's an s3/ directory both in our custom BOTO_DATA_PATH
        # directory as well as in the botocore/data/ directory.
        # Our path should win since the default built in path is always
        # last.
        data = self.loader.load_service_model('aws/s3')
        self.assertTrue(data.get('WAS_OVERRIDEN_VIA_DATA_PATH'),
                        "S3 model was loaded from botocore's default "
                        "data path instead of from the BOTO_DATA_PATH"
                        " directory.")

    def test_list_available_services(self):
        avail = self.loader.list_available_services('')
        self.assertEqual(sorted(avail), [
            'aws',
            'aws',
            'someservice',
            'sub',
        ])

        aws_avail = self.loader.list_available_services('aws')
        self.assertTrue(len(aws_avail) > 10)
        self.assertTrue('ec2' in aws_avail)

    def test_load_data_overridden(self):
        self.overrides_path = os.path.join(
            os.path.dirname(__file__),
            'data_overrides'
        )
        self.environ['BOTO_DATA_PATH'] = "{0}{1}{2}".format(
#.........這裏部分代碼省略.........
開發者ID:charleso,項目名稱:botocore,代碼行數:103,代碼來源:test_loaders.py


注:本文中的botocore.loaders.Loader.list_available_services方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。