當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。