当前位置: 首页>>代码示例>>Python>>正文


Python ExtensionManager.make_test_instance方法代码示例

本文整理汇总了Python中stevedore.extension.ExtensionManager.make_test_instance方法的典型用法代码示例。如果您正苦于以下问题:Python ExtensionManager.make_test_instance方法的具体用法?Python ExtensionManager.make_test_instance怎么用?Python ExtensionManager.make_test_instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在stevedore.extension.ExtensionManager的用法示例。


在下文中一共展示了ExtensionManager.make_test_instance方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp

# 需要导入模块: from stevedore.extension import ExtensionManager [as 别名]
# 或者: from stevedore.extension.ExtensionManager import make_test_instance [as 别名]
    def setUp(self):
        super(PartitionTestCase, self).setUp()
        # Set up two user partition schemes: mock and random
        self.non_random_scheme = MockUserPartitionScheme(self.TEST_SCHEME_NAME)
        self.random_scheme = MockUserPartitionScheme("random")
        extensions = [
            Extension(
                self.non_random_scheme.name, USER_PARTITION_SCHEME_NAMESPACE, self.non_random_scheme, None
            ),
            Extension(
                self.random_scheme.name, USER_PARTITION_SCHEME_NAMESPACE, self.random_scheme, None
            ),
        ]
        UserPartition.scheme_extensions = ExtensionManager.make_test_instance(
            extensions, namespace=USER_PARTITION_SCHEME_NAMESPACE
        )

        # Create a test partition
        self.user_partition = UserPartition(
            self.TEST_ID,
            self.TEST_NAME,
            self.TEST_DESCRIPTION,
            self.TEST_GROUPS,
            extensions[0].plugin,
            self.TEST_PARAMETERS,
        )

        # Make sure the names are set on the schemes (which happens normally in code, but may not happen in tests).
        self.user_partition.get_scheme(self.non_random_scheme.name)
        self.user_partition.get_scheme(self.random_scheme.name)
开发者ID:10clouds,项目名称:edx-platform,代码行数:32,代码来源:test_partitions.py

示例2: test_get_default_driver

# 需要导入模块: from stevedore.extension import ExtensionManager [as 别名]
# 或者: from stevedore.extension.ExtensionManager import make_test_instance [as 别名]
    def test_get_default_driver(self):
        # Given
        class OtherRunner(BaseTestRunner):
            pass

        default = Extension(
            'default', None, BaseTestRunner, None)
        other = Extension(
            'other', None, OtherRunner, None)
        driver_managers = [
            (PluginManager.TEST_RUNNER, ExtensionManager.make_test_instance(
                [default, other], namespace=PluginManager.TEST_RUNNER)),
        ]
        plugin_manager = PluginManager.testing_plugin_manager(
            hook_managers=(), driver_managers=driver_managers)
        parser = create_argument_parser()
        plugin_manager.add_plugin_arguments(parser)

        # When
        args = parser.parse_args([])
        plugin_manager.get_driver(plugin_manager.TEST_RUNNER, args)
        runner = plugin_manager.get_driver(plugin_manager.TEST_RUNNER, args)

        # Then
        self.assertNotIsInstance(runner, OtherRunner)
开发者ID:sjagoe,项目名称:haas,代码行数:27,代码来源:test_plugin_manager.py

示例3: test_environment_hook_options

# 需要导入模块: from stevedore.extension import ExtensionManager [as 别名]
# 或者: from stevedore.extension.ExtensionManager import make_test_instance [as 别名]
    def test_environment_hook_options(self):
        class TestingPlugin(BaseTestingPlugin):
            add_parser_arguments_called = 0
            from_args_called = 0

            @classmethod
            def add_parser_arguments(cls, parser, name, option_prefix,
                                     dest_prefix):
                cls.add_parser_arguments_called += 1
                return super(TestingPlugin, cls).add_parser_arguments(
                    parser, name, option_prefix, dest_prefix)

            @classmethod
            def from_args(cls, args, name, dest_prefix):
                cls.from_args_called += 1
                return super(TestingPlugin, cls).from_args(
                    args, name, dest_prefix)

        # Given
        extension = Extension(
            'testing-plugin', None, TestingPlugin, None)
        environment_manager = ExtensionManager.make_test_instance(
            [extension], namespace=PluginManager.ENVIRONMENT_HOOK,
        )
        hook_managers = [(PluginManager.ENVIRONMENT_HOOK, environment_manager)]
        plugin_manager = PluginManager.testing_plugin_manager(
            hook_managers=hook_managers, driver_managers=())
        parser = ArgumentParser(add_help=False)

        # When
        plugin_manager.add_plugin_arguments(parser)

        # Then
        self.assertEqual(TestingPlugin.add_parser_arguments_called, 1)
        actions = parser._actions
        self.assertEqual(len(actions), 1)
        action, = actions
        self.assertEqual(action.option_strings, ['--with-testing-plugin'])

        # When
        args = parser.parse_args([])
        enabled_plugins = plugin_manager.get_enabled_hook_plugins(
            plugin_manager.ENVIRONMENT_HOOK, args)

        # Then
        self.assertEqual(enabled_plugins, [])
        self.assertEqual(TestingPlugin.from_args_called, 1)

        # When
        args = parser.parse_args(['--with-testing-plugin'])
        enabled_plugins = plugin_manager.get_enabled_hook_plugins(
            plugin_manager.ENVIRONMENT_HOOK, args)

        # Then
        self.assertEqual(len(enabled_plugins), 1)

        plugin_obj, = enabled_plugins
        self.assertEqual(TestingPlugin.from_args_called, 2)
        self.assertTrue(plugin_obj.enabled)
开发者ID:sjagoe,项目名称:haas,代码行数:61,代码来源:test_plugin_manager.py

示例4: test_no_driver_hook_found

# 需要导入模块: from stevedore.extension import ExtensionManager [as 别名]
# 或者: from stevedore.extension.ExtensionManager import make_test_instance [as 别名]
    def test_no_driver_hook_found(self):
        # Given
        driver_managers = [
            (PluginManager.TEST_RUNNER, ExtensionManager.make_test_instance(
                [], namespace=PluginManager.TEST_RUNNER)),
        ]
        plugin_manager = PluginManager.testing_plugin_manager(
            hook_managers=(), driver_managers=driver_managers)
        parser = ArgumentParser(add_help=False)

        # When
        plugin_manager.add_plugin_arguments(parser)

        # Then
        actions = parser._actions
        self.assertEqual(len(actions), 0)
开发者ID:sjagoe,项目名称:haas,代码行数:18,代码来源:test_plugin_manager.py

示例5: get_insert_cmpt_mgr

# 需要导入模块: from stevedore.extension import ExtensionManager [as 别名]
# 或者: from stevedore.extension.ExtensionManager import make_test_instance [as 别名]
 def get_insert_cmpt_mgr():
     return ExtensionManager.make_test_instance([Extension(
         'prepare_data',
         'monasca_transform.component.insert.prepare_data:PrepareData',
         PrepareData(),
         None),
         Extension('insert_data',
                   'tests.functional.component.insert.dummy_insert:'
                   'DummyInsert',
                   DummyInsert(),
                   None),
         Extension('insert_data_pre_hourly',
                   'tests.functional.component.insert.dummy_insert:'
                   'DummyInsert',
                   DummyInsert(),
                   None),
     ])
开发者ID:openstack,项目名称:monasca-transform,代码行数:19,代码来源:mock_component_manager.py

示例6: get_setter_cmpt_mgr

# 需要导入模块: from stevedore.extension import ExtensionManager [as 别名]
# 或者: from stevedore.extension.ExtensionManager import make_test_instance [as 别名]
 def get_setter_cmpt_mgr():
     return ExtensionManager.make_test_instance([Extension(
         'set_aggregated_metric_name',
         'monasca_transform.component.setter.'
         'set_aggregated_metric_name:SetAggregatedMetricName',
         SetAggregatedMetricName(),
         None),
         Extension('set_aggregated_period',
                   'monasca_transform.component.setter.'
                   'set_aggregated_period:SetAggregatedPeriod',
                   SetAggregatedPeriod(),
                   None),
         Extension('rollup_quantity',
                   'monasca_transform.component.setter.'
                   'rollup_quantity:RollupQuantity',
                   RollupQuantity(),
                   None)
     ])
开发者ID:openstack,项目名称:monasca-transform,代码行数:20,代码来源:mock_component_manager.py

示例7: get_usage_cmpt_mgr

# 需要导入模块: from stevedore.extension import ExtensionManager [as 别名]
# 或者: from stevedore.extension.ExtensionManager import make_test_instance [as 别名]
 def get_usage_cmpt_mgr():
     return ExtensionManager.make_test_instance([Extension(
         'fetch_quantity',
         'monasca_transform.component.usage.'
         'fetch_quantity:'
         'FetchQuantity',
         FetchQuantity(),
         None),
         Extension(
         'fetch_quantity_util',
         'monasca_transform.component.usage.'
         'fetch_quantity_util:'
         'FetchQuantityUtil',
         FetchQuantityUtil(),
         None),
         Extension(
             'calculate_rate',
             'monasca_transform.component.usage.'
             'calculate_rate:'
             'CalculateRate',
             CalculateRate(),
             None),
     ])
开发者ID:openstack,项目名称:monasca-transform,代码行数:25,代码来源:mock_component_manager.py

示例8: setUp

# 需要导入模块: from stevedore.extension import ExtensionManager [as 别名]
# 或者: from stevedore.extension.ExtensionManager import make_test_instance [as 别名]
    def setUp(self):
        # Set up two user partition schemes: mock and random
        extensions = [
            Extension(
                self.TEST_SCHEME_NAME, USER_PARTITION_SCHEME_NAMESPACE,
                MockUserPartitionScheme(self.TEST_SCHEME_NAME), None
            ),
            Extension(
                "random", USER_PARTITION_SCHEME_NAMESPACE, MockUserPartitionScheme("random"), None
            ),
        ]
        UserPartition.scheme_extensions = ExtensionManager.make_test_instance(
            extensions, namespace=USER_PARTITION_SCHEME_NAMESPACE
        )

        # Create a test partition
        self.user_partition = UserPartition(
            self.TEST_ID,
            self.TEST_NAME,
            self.TEST_DESCRIPTION,
            self.TEST_GROUPS,
            extensions[0].plugin
        )
开发者ID:JacobWay,项目名称:edx-platform,代码行数:25,代码来源:test_partitions.py

示例9: test_hook_plugin_none

# 需要导入模块: from stevedore.extension import ExtensionManager [as 别名]
# 或者: from stevedore.extension.ExtensionManager import make_test_instance [as 别名]
    def test_hook_plugin_none(self):
        class TestingPlugin(BaseTestingPlugin):

            @classmethod
            def from_args(cls, args, name, dest_prefix):
                return None

        # Given
        extension = Extension(
            'testing-plugin', None, TestingPlugin, None)
        environment_manager = ExtensionManager.make_test_instance(
            [extension], namespace=PluginManager.ENVIRONMENT_HOOK,
        )
        hook_managers = [(PluginManager.ENVIRONMENT_HOOK, environment_manager)]
        plugin_manager = PluginManager.testing_plugin_manager(
            hook_managers=hook_managers, driver_managers=())
        parser = ArgumentParser(add_help=False)
        args = parser.parse_args([])

        # When
        plugin = plugin_manager._create_hook_plugin(extension, args)

        # Then
        self.assertIsNone(plugin)
开发者ID:sjagoe,项目名称:haas,代码行数:26,代码来源:test_plugin_manager.py

示例10: test_environment_hook_options_no_plugins

# 需要导入模块: from stevedore.extension import ExtensionManager [as 别名]
# 或者: from stevedore.extension.ExtensionManager import make_test_instance [as 别名]
    def test_environment_hook_options_no_plugins(self):
        # Given
        environment_manager = ExtensionManager.make_test_instance(
            [], namespace=PluginManager.ENVIRONMENT_HOOK,
        )
        hook_managers = [(PluginManager.ENVIRONMENT_HOOK, environment_manager)]
        plugin_manager = PluginManager.testing_plugin_manager(
            hook_managers=hook_managers, driver_managers=())
        parser = ArgumentParser(add_help=False)

        # When
        plugin_manager.add_plugin_arguments(parser)

        # Then
        actions = parser._actions
        self.assertEqual(len(actions), 0)

        # When
        args = parser.parse_args([])
        enabled_plugins = plugin_manager.get_enabled_hook_plugins(
            plugin_manager.ENVIRONMENT_HOOK, args)

        # Then
        self.assertEqual(enabled_plugins, [])
开发者ID:sjagoe,项目名称:haas,代码行数:26,代码来源:test_plugin_manager.py

示例11: setUp

# 需要导入模块: from stevedore.extension import ExtensionManager [as 别名]
# 或者: from stevedore.extension.ExtensionManager import make_test_instance [as 别名]
    def setUp(self):
        super(GroupAccessTestCase, self).setUp()

        UserPartition.scheme_extensions = ExtensionManager.make_test_instance(
            [
                Extension(
                    "memory",
                    USER_PARTITION_SCHEME_NAMESPACE,
                    MemoryUserPartitionScheme(),
                    None
                ),
                Extension(
                    "random",
                    USER_PARTITION_SCHEME_NAMESPACE,
                    MemoryUserPartitionScheme(),
                    None
                )
            ],
            namespace=USER_PARTITION_SCHEME_NAMESPACE
        )

        self.cat_group = Group(10, 'cats')
        self.dog_group = Group(20, 'dogs')
        self.worm_group = Group(30, 'worms')
        self.animal_partition = UserPartition(
            0,
            'Pet Partition',
            'which animal are you?',
            [self.cat_group, self.dog_group, self.worm_group],
            scheme=UserPartition.get_scheme("memory"),
        )

        self.red_group = Group(1000, 'red')
        self.blue_group = Group(2000, 'blue')
        self.gray_group = Group(3000, 'gray')
        self.color_partition = UserPartition(
            100,
            'Color Partition',
            'what color are you?',
            [self.red_group, self.blue_group, self.gray_group],
            scheme=UserPartition.get_scheme("memory"),
        )

        self.course = CourseFactory.create(
            user_partitions=[self.animal_partition, self.color_partition],
        )
        with self.store.bulk_operations(self.course.id, emit_signals=False):
            chapter = ItemFactory.create(category='chapter', parent=self.course)
            section = ItemFactory.create(category='sequential', parent=chapter)
            vertical = ItemFactory.create(category='vertical', parent=section)
            component = ItemFactory.create(category='problem', parent=vertical)

            self.chapter_location = chapter.location
            self.section_location = section.location
            self.vertical_location = vertical.location
            self.component_location = component.location

        self.red_cat = UserFactory()  # student in red and cat groups
        self.set_user_group(self.red_cat, self.animal_partition, self.cat_group)
        self.set_user_group(self.red_cat, self.color_partition, self.red_group)

        self.blue_dog = UserFactory()  # student in blue and dog groups
        self.set_user_group(self.blue_dog, self.animal_partition, self.dog_group)
        self.set_user_group(self.blue_dog, self.color_partition, self.blue_group)

        self.white_mouse = UserFactory()  # student in no group

        self.gray_worm = UserFactory()  # student in deleted group
        self.set_user_group(self.gray_worm, self.animal_partition, self.worm_group)
        self.set_user_group(self.gray_worm, self.color_partition, self.gray_group)
        # delete the gray/worm groups from the partitions now so we can test scenarios
        # for user whose group is missing.
        self.animal_partition.groups.pop()
        self.color_partition.groups.pop()

        # add a staff user, whose access will be unconditional in spite of group access.
        self.staff = StaffFactory.create(course_key=self.course.id)
开发者ID:10clouds,项目名称:edx-platform,代码行数:79,代码来源:test_group_access.py


注:本文中的stevedore.extension.ExtensionManager.make_test_instance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。