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


Python munch.Munch方法代码示例

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


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

示例1: test_is_repo_committer_external_committer_restricting_another_one

# 需要导入模块: import munch [as 别名]
# 或者: from munch import Munch [as 别名]
def test_is_repo_committer_external_committer_restricting_another_one(
        self,
    ):
        """ Test is_repo_committer in pagure with EXTERNAL_COMMITTER
        configured to give access the provenpackager just for one repo not
        this one
        """
        repo = pagure.lib.query._get_project(self.session, "test2")

        g = munch.Munch()
        g.fas_user = tests.FakeUser(username="foo")
        g.authenticated = True
        g.fas_user.groups.append("provenpackager")
        g.session = self.session
        with mock.patch("flask.g", g):
            output = pagure.utils.is_repo_committer(repo)
            self.assertFalse(output) 
开发者ID:Pagure,项目名称:pagure,代码行数:19,代码来源:test_pagure_flask.py

示例2: test_release_listener

# 需要导入模块: import munch [as 别名]
# 或者: from munch import Munch [as 别名]
def test_release_listener(self):
        os_net = self.useFixture(k_fix.MockNetworkClient()).client
        lbaas = self.useFixture(k_fix.MockLBaaSClient()).client
        os_net.security_group_rules.return_value = (x for x in [])
        cls = d_lbaasv2.LBaaSv2Driver
        m_driver = mock.Mock(spec=d_lbaasv2.LBaaSv2Driver)
        m_driver._get_vip_port.return_value = munch.Munch({
            'security_group_ids': [mock.sentinel.sg_id]})
        loadbalancer = mock.Mock()
        listener = mock.Mock()

        cls.release_listener(m_driver, loadbalancer, listener)

        m_driver._release.assert_called_once_with(loadbalancer, listener,
                                                  lbaas.delete_listener,
                                                  listener.id) 
开发者ID:openstack,项目名称:kuryr-kubernetes,代码行数:18,代码来源:test_lbaasv2.py

示例3: test_create_loadbalancer_provider_mismatch

# 需要导入模块: import munch [as 别名]
# 或者: from munch import Munch [as 别名]
def test_create_loadbalancer_provider_mismatch(self):
        cls = d_lbaasv2.LBaaSv2Driver
        m_driver = mock.Mock(spec=d_lbaasv2.LBaaSv2Driver)
        lbaas = self.useFixture(k_fix.MockLBaaSClient()).client
        loadbalancer = obj_lbaas.LBaaSLoadBalancer(
            name='TEST_NAME', project_id='TEST_PROJECT', ip='1.2.3.4',
            subnet_id='D3FA400A-F543-4B91-9CD3-047AF0CE42D1',
            security_groups=[],
            provider='amphora')
        loadbalancer_id = '00EE9E11-91C2-41CF-8FD4-7970579E5C4C'
        req = {
            'name': loadbalancer.name,
            'project_id': loadbalancer.project_id,
            'vip_address': str(loadbalancer.ip),
            'vip_subnet_id': loadbalancer.subnet_id,
            'provider': loadbalancer.provider,
        }
        resp = o_lb.LoadBalancer(id=loadbalancer_id, provider='haproxy')
        lbaas.create_load_balancer.return_value = resp
        m_driver._get_vip_port.return_value = munch.Munch(
            {'id': mock.sentinel.port_id})

        ret = cls._create_loadbalancer(m_driver, loadbalancer)
        lbaas.create_load_balancer.assert_called_once_with(**req)
        self.assertIsNone(ret) 
开发者ID:openstack,项目名称:kuryr-kubernetes,代码行数:27,代码来源:test_lbaasv2.py

示例4: test_create_network

# 需要导入模块: import munch [as 别名]
# 或者: from munch import Munch [as 别名]
def test_create_network(self):
        cls = subnet_drv.NamespacePodSubnetDriver
        m_driver = mock.MagicMock(spec=cls)

        namespace = 'test'
        project_id = mock.sentinel.project_id
        os_net = self.useFixture(k_fix.MockNetworkClient()).client
        os_net.networks.return_value = iter([])
        net = munch.Munch({'id': mock.sentinel.net})
        os_net.create_network.return_value = net

        net_id_resp = cls.create_network(m_driver, namespace, project_id)

        self.assertEqual(net_id_resp, net['id'])
        os_net.create_network.assert_called_once()
        os_net.networks.assert_called_once() 
开发者ID:openstack,项目名称:kuryr-kubernetes,代码行数:18,代码来源:test_namespace_subnet.py

示例5: test_create_subnet_existing

# 需要导入模块: import munch [as 别名]
# 或者: from munch import Munch [as 别名]
def test_create_subnet_existing(self):
        cls = subnet_drv.NamespacePodSubnetDriver
        m_driver = mock.MagicMock(spec=cls)

        namespace = 'test'
        project_id = mock.sentinel.project_id
        net_id = mock.sentinel.net_id
        subnet = munch.Munch({'id': mock.sentinel.subnet,
                              'cidr': mock.sentinel.cidr})
        os_net = self.useFixture(k_fix.MockNetworkClient()).client
        os_net.subnets.return_value = iter([subnet])

        subnet_id, subnet_cidr = cls.create_subnet(m_driver, namespace,
                                                   project_id, net_id)

        self.assertEqual(subnet_id, subnet['id'])
        self.assertEqual(subnet_cidr, subnet['cidr'])
        os_net.create_subnet.assert_not_called()
        os_net.subnets.assert_called_once() 
开发者ID:openstack,项目名称:kuryr-kubernetes,代码行数:21,代码来源:test_namespace_subnet.py

示例6: test_create_security_group_rules_from_network_policy

# 需要导入模块: import munch [as 别名]
# 或者: from munch import Munch [as 别名]
def test_create_security_group_rules_from_network_policy(self, m_utils,
                                                             m_parse,
                                                             m_add_crd,
                                                             m_get_crd,
                                                             m_add_default):
        self._driver.os_net.create_security_group.return_value = (
            munch.Munch({'id': mock.sentinel.id,
                         'security_group_rules': []}))
        m_utils.get_subnet_cidr.return_value = mock.sentinel.cidr
        m_parse.return_value = (self._i_rules, self._e_rules)
        self._driver.os_net.create_security_group_rule.return_value = (
            munch.Munch({'id': mock.sentinel.id}))
        self._driver.create_security_group_rules_from_network_policy(
            self._policy, self._project_id)
        m_get_crd.assert_called_once()
        m_add_crd.assert_called_once()
        m_add_default.assert_called_once() 
开发者ID:openstack,项目名称:kuryr-kubernetes,代码行数:19,代码来源:test_network_policy.py

示例7: test_create_security_group_rules_with_k8s_exc

# 需要导入模块: import munch [as 别名]
# 或者: from munch import Munch [as 别名]
def test_create_security_group_rules_with_k8s_exc(self, m_utils, m_parse,
                                                      m_add_crd, m_get_crd,
                                                      m_add_default):
        self._driver.os_net.create_security_group.return_value = (
            munch.Munch({'id': mock.sentinel.id,
                         'security_group_rules': []}))
        m_utils.get_subnet_cidr.return_value = mock.sentinel.cidr
        m_parse.return_value = (self._i_rules, self._e_rules)
        m_get_crd.side_effect = exceptions.K8sClientException
        self._driver.os_net.create_security_group_rule.return_value = (
            munch.Munch({'id': mock.sentinel.id}))
        self.assertRaises(
            exceptions.K8sClientException,
            self._driver.create_security_group_rules_from_network_policy,
            self._policy, self._project_id)
        m_add_crd.assert_called_once()
        m_add_default.assert_called_once() 
开发者ID:openstack,项目名称:kuryr-kubernetes,代码行数:19,代码来源:test_network_policy.py

示例8: test_create_security_group_rules_error_add_crd

# 需要导入模块: import munch [as 别名]
# 或者: from munch import Munch [as 别名]
def test_create_security_group_rules_error_add_crd(self, m_utils, m_parse,
                                                       m_add_crd, m_get_crd,
                                                       m_add_default):
        self._driver.os_net.create_security_group.return_value = (
            munch.Munch({'id': mock.sentinel.id,
                         'security_group_rules': []}))
        m_utils.get_subnet_cidr.return_value = mock.sentinel.cidr
        m_parse.return_value = (self._i_rules, self._e_rules)
        m_add_crd.side_effect = exceptions.K8sClientException
        self._driver.os_net.create_security_group_rule.return_value = (
            munch.Munch({'id': mock.sentinel.id}))
        self.assertRaises(
            exceptions.K8sClientException,
            self._driver.create_security_group_rules_from_network_policy,
            self._policy, self._project_id)
        m_get_crd.assert_not_called()
        m_add_default.assert_called_once() 
开发者ID:openstack,项目名称:kuryr-kubernetes,代码行数:19,代码来源:test_network_policy.py

示例9: test_release_vif

# 需要导入模块: import munch [as 别名]
# 或者: from munch import Munch [as 别名]
def test_release_vif(self):
        cls = vif_pool.BaseVIFPool
        m_driver = mock.MagicMock(spec=cls)
        m_driver._recyclable_ports = {}
        m_driver._existing_vifs = {}

        pod = get_pod_obj()
        project_id = mock.sentinel.project_id
        security_groups = [mock.sentinel.security_groups]
        net_id = str(uuid.uuid4())
        _net = munch.Munch({'id': net_id,
                            'name': None,
                            'mtu': None,
                            'provider_network_type': None})
        network = ovu.neutron_to_osvif_network(_net)
        vif = osv_vif.VIFOpenVSwitch(id='0fa0e837-d34e-4580-a6c4-04f5f607d93e',
                                     network=network)

        m_driver._return_ports_to_pool.return_value = None

        cls.release_vif(m_driver, pod, vif, project_id, security_groups)

        m_driver._return_ports_to_pool.assert_not_called() 
开发者ID:openstack,项目名称:kuryr-kubernetes,代码行数:25,代码来源:test_vif_pool.py

示例10: test_cleanup_leftover_ports

# 需要导入模块: import munch [as 别名]
# 或者: from munch import Munch [as 别名]
def test_cleanup_leftover_ports(self):
        cls = vif_pool.BaseVIFPool
        m_driver = mock.MagicMock(spec=cls)

        os_net = self.useFixture(k_fix.MockNetworkClient()).client

        port_id = str(uuid.uuid4())
        port = fake.get_port_obj(port_id=port_id)
        net_id = port.network_id
        tags = 'clusterTest'
        port.tags = [tags]
        os_net.ports.return_value = [port]
        oslo_cfg.CONF.set_override('resource_tags',
                                   tags,
                                   group='neutron_defaults')
        self.addCleanup(oslo_cfg.CONF.clear_override, 'resource_tags',
                        group='neutron_defaults')

        os_net.networks.return_value = [munch.Munch({'id': net_id})]

        cls._cleanup_leftover_ports(m_driver)
        os_net.networks.assert_called()
        os_net.delete_port.assert_not_called() 
开发者ID:openstack,项目名称:kuryr-kubernetes,代码行数:25,代码来源:test_vif_pool.py

示例11: test_cleanup_leftover_ports_no_binding

# 需要导入模块: import munch [as 别名]
# 或者: from munch import Munch [as 别名]
def test_cleanup_leftover_ports_no_binding(self):
        cls = vif_pool.BaseVIFPool
        m_driver = mock.MagicMock(spec=cls)

        os_net = self.useFixture(k_fix.MockNetworkClient()).client

        port_id = str(uuid.uuid4())
        port = fake.get_port_obj(port_id=port_id)
        net_id = port.network_id
        tags = 'clusterTest'
        port.tags = [tags]
        port.binding_host_id = None
        os_net.ports.return_value = [port]
        oslo_cfg.CONF.set_override('resource_tags',
                                   tags,
                                   group='neutron_defaults')
        self.addCleanup(oslo_cfg.CONF.clear_override, 'resource_tags',
                        group='neutron_defaults')

        os_net.networks.return_value = [munch.Munch({'id': net_id})]

        cls._cleanup_leftover_ports(m_driver)
        os_net.networks.assert_called()
        os_net.delete_port.assert_called_once_with(port.id) 
开发者ID:openstack,项目名称:kuryr-kubernetes,代码行数:26,代码来源:test_vif_pool.py

示例12: test_cleanup_leftover_ports_no_tags

# 需要导入模块: import munch [as 别名]
# 或者: from munch import Munch [as 别名]
def test_cleanup_leftover_ports_no_tags(self):
        cls = vif_pool.BaseVIFPool
        m_driver = mock.MagicMock(spec=cls)

        os_net = self.useFixture(k_fix.MockNetworkClient()).client

        port_id = str(uuid.uuid4())
        port = fake.get_port_obj(port_id=port_id)
        net_id = port.network_id
        tags = 'clusterTest'
        os_net.ports.return_value = [port]
        oslo_cfg.CONF.set_override('resource_tags',
                                   tags,
                                   group='neutron_defaults')
        self.addCleanup(oslo_cfg.CONF.clear_override, 'resource_tags',
                        group='neutron_defaults')

        os_net.networks.return_value = [munch.Munch({'id': net_id})]

        cls._cleanup_leftover_ports(m_driver)
        os_net.networks.assert_called()
        os_net.delete_port.assert_called_once_with(port.id) 
开发者ID:openstack,项目名称:kuryr-kubernetes,代码行数:24,代码来源:test_vif_pool.py

示例13: test__trigger_return_to_pool_delete_key_error

# 需要导入模块: import munch [as 别名]
# 或者: from munch import Munch [as 别名]
def test__trigger_return_to_pool_delete_key_error(self):
        cls = vif_pool.NeutronVIFPool
        m_driver = mock.MagicMock(spec=cls)

        os_net = self.useFixture(k_fix.MockNetworkClient()).client

        pool_key = ('node_ip', 'project_id')
        port_id = str(uuid.uuid4())
        pool_length = 10

        m_driver._recyclable_ports = {port_id: pool_key}
        m_driver._available_ports_pools = {}
        m_driver._existing_vifs = {}
        oslo_cfg.CONF.set_override('ports_pool_max',
                                   5,
                                   group='vif_pool')
        os_net.ports.return_value = [
            munch.Munch({'id': port_id,
                         'security_group_ids': ['security_group_modified']})]
        m_driver._get_pool_size.return_value = pool_length

        cls._trigger_return_to_pool(m_driver)

        os_net.update_port.assert_not_called()
        os_net.delete_port.assert_not_called() 
开发者ID:openstack,项目名称:kuryr-kubernetes,代码行数:27,代码来源:test_vif_pool.py

示例14: test_acquire_service_pub_ip_info_usr_specified_ip

# 需要导入模块: import munch [as 别名]
# 或者: from munch import Munch [as 别名]
def test_acquire_service_pub_ip_info_usr_specified_ip(self):
        cls = d_lb_public_ip.FloatingIpServicePubIPDriver
        m_driver = mock.Mock(spec=cls)
        m_driver._drv_pub_ip = public_ip.FipPubIpDriver()
        os_net = self.useFixture(k_fix.MockNetworkClient()).client

        fip = munch.Munch({'floating_ip_address': '1.2.3.4',
                           'port_id': None,
                           'id': 'a2a62ea7-e3bf-40df-8c09-aa0c29876a6b'})
        os_net.ips.return_value = (ip for ip in [fip])
        project_id = mock.sentinel.project_id
        spec_type = 'LoadBalancer'
        spec_lb_ip = '1.2.3.4'

        expected_resp = (obj_lbaas
                         .LBaaSPubIp(ip_id=fip.id,
                                     ip_addr=fip.floating_ip_address,
                                     alloc_method='user'))

        result = cls.acquire_service_pub_ip_info(m_driver, spec_type,
                                                 spec_lb_ip,  project_id)
        self.assertEqual(result, expected_resp) 
开发者ID:openstack,项目名称:kuryr-kubernetes,代码行数:24,代码来源:test_lb_public_ip.py

示例15: test_acquire_service_pub_ip_info_user_specified_occupied_fip

# 需要导入模块: import munch [as 别名]
# 或者: from munch import Munch [as 别名]
def test_acquire_service_pub_ip_info_user_specified_occupied_fip(self):
        cls = d_lb_public_ip.FloatingIpServicePubIPDriver
        m_driver = mock.Mock(spec=cls)
        m_driver._drv_pub_ip = public_ip.FipPubIpDriver()
        os_net = self.useFixture(k_fix.MockNetworkClient()).client

        fip = munch.Munch({'floating_ip_address': '1.2.3.4',
                           'port_id': 'ec29d641-fec4-4f67-928a-124a76b3a8e6'})
        os_net.ips.return_value = (ip for ip in [fip])

        project_id = mock.sentinel.project_id
        spec_type = 'LoadBalancer'
        spec_lb_ip = '1.2.3.4'

        result = cls.acquire_service_pub_ip_info(m_driver, spec_type,
                                                 spec_lb_ip,  project_id)
        self.assertIsNone(result) 
开发者ID:openstack,项目名称:kuryr-kubernetes,代码行数:19,代码来源:test_lb_public_ip.py


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