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


Python tools.verify_mock_calls函数代码示例

本文整理汇总了Python中neutron.tests.tools.verify_mock_calls函数的典型用法代码示例。如果您正苦于以下问题:Python verify_mock_calls函数的具体用法?Python verify_mock_calls怎么用?Python verify_mock_calls使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: _test_get_traffic_counters_with_zero_helper

    def _test_get_traffic_counters_with_zero_helper(self, use_ipv6):
        self.iptables = iptables_manager.IptablesManager(use_ipv6=use_ipv6)
        self.execute = mock.patch.object(self.iptables, "execute").start()
        exp_packets = 800
        exp_bytes = 131802

        expected_calls_and_values = [
            (
                mock.call(["iptables", "-t", "filter", "-L", "OUTPUT", "-n", "-v", "-x", "-Z"], run_as_root=True),
                TRAFFIC_COUNTERS_DUMP,
            ),
            (mock.call(["iptables", "-t", "raw", "-L", "OUTPUT", "-n", "-v", "-x", "-Z"], run_as_root=True), ""),
            (mock.call(["iptables", "-t", "mangle", "-L", "OUTPUT", "-n", "-v", "-x", "-Z"], run_as_root=True), ""),
            (mock.call(["iptables", "-t", "nat", "-L", "OUTPUT", "-n", "-v", "-x", "-Z"], run_as_root=True), ""),
        ]
        if use_ipv6:
            expected_calls_and_values.append(
                (mock.call(["ip6tables", "-t", "raw", "-L", "OUTPUT", "-n", "-v", "-x", "-Z"], run_as_root=True), "")
            )
            expected_calls_and_values.append(
                (
                    mock.call(["ip6tables", "-t", "filter", "-L", "OUTPUT", "-n", "-v", "-x", "-Z"], run_as_root=True),
                    TRAFFIC_COUNTERS_DUMP,
                )
            )
            exp_packets *= 2
            exp_bytes *= 2

        tools.setup_mock_calls(self.execute, expected_calls_and_values)

        acc = self.iptables.get_traffic_counters("OUTPUT", zero=True)
        self.assertEqual(acc["pkts"], exp_packets)
        self.assertEqual(acc["bytes"], exp_bytes)

        tools.verify_mock_calls(self.execute, expected_calls_and_values, any_order=True)
开发者ID:tealover,项目名称:neutron,代码行数:35,代码来源:test_iptables_manager.py

示例2: test_rule_with_wrap_target

    def test_rule_with_wrap_target(self):
        name = '0123456789' * 5
        wrap = "%s-%s" % (iptables_manager.binary_name,
                          iptables_manager.get_chain_name(name))

        iptables_args = {'bn': iptables_manager.binary_name,
                         'wrap': wrap}

        filter_dump_mod = ('# Generated by iptables_manager\n'
                           '*filter\n'
                           ':neutron-filter-top - [0:0]\n'
                           ':%(bn)s-FORWARD - [0:0]\n'
                           ':%(bn)s-INPUT - [0:0]\n'
                           ':%(bn)s-local - [0:0]\n'
                           ':%(wrap)s - [0:0]\n'
                           ':%(bn)s-OUTPUT - [0:0]\n'
                           '[0:0] -A FORWARD -j neutron-filter-top\n'
                           '[0:0] -A OUTPUT -j neutron-filter-top\n'
                           '[0:0] -A neutron-filter-top -j %(bn)s-local\n'
                           '[0:0] -A INPUT -j %(bn)s-INPUT\n'
                           '[0:0] -A OUTPUT -j %(bn)s-OUTPUT\n'
                           '[0:0] -A FORWARD -j %(bn)s-FORWARD\n'
                           '[0:0] -A %(bn)s-INPUT -s 0/0 -d 192.168.0.2 -j '
                           '%(wrap)s\n'
                           'COMMIT\n'
                           '# Completed by iptables_manager\n'
                           % iptables_args)

        expected_calls_and_values = [
            (mock.call(['iptables-save', '-c'],
                       root_helper=self.root_helper),
             ''),
            (mock.call(['iptables-restore', '-c'],
                       process_input=NAT_DUMP + filter_dump_mod,
                       root_helper=self.root_helper),
             None),
            (mock.call(['iptables-save', '-c'],
                       root_helper=self.root_helper),
             ''),
            (mock.call(['iptables-restore', '-c'],
                       process_input=NAT_DUMP + FILTER_DUMP,
                       root_helper=self.root_helper),
             None),
        ]
        tools.setup_mock_calls(self.execute, expected_calls_and_values)

        self.iptables.ipv4['filter'].add_chain(name)
        self.iptables.ipv4['filter'].add_rule('INPUT',
                                              '-s 0/0 -d 192.168.0.2 -j'
                                              ' $%s' % name)
        self.iptables.apply()

        self.iptables.ipv4['filter'].remove_rule('INPUT',
                                                 '-s 0/0 -d 192.168.0.2 -j'
                                                 ' $%s' % name)
        self.iptables.ipv4['filter'].remove_chain(name)

        self.iptables.apply()

        tools.verify_mock_calls(self.execute, expected_calls_and_values)
开发者ID:ArifovicH,项目名称:neutron,代码行数:60,代码来源:test_iptables_manager.py

示例3: test_get_traffic_counters_with_zero

    def test_get_traffic_counters_with_zero(self):
        iptables_dump = (
            'Chain OUTPUT (policy ACCEPT 400 packets, 65901 bytes)\n'
            '    pkts      bytes target     prot opt in     out     source'
            '               destination         \n'
            '     400   65901 chain1     all  --  *      *       0.0.0.0/0'
            '            0.0.0.0/0           \n'
            '     400   65901 chain2     all  --  *      *       0.0.0.0/0'
            '            0.0.0.0/0           \n')

        expected_calls_and_values = [
            (mock.call(['iptables', '-t', 'filter', '-L', 'OUTPUT',
                        '-n', '-v', '-x', '-Z'],
                       root_helper=self.root_helper),
             iptables_dump),
            (mock.call(['iptables', '-t', 'nat', '-L', 'OUTPUT', '-n',
                        '-v', '-x', '-Z'],
                       root_helper=self.root_helper),
             ''),
            (mock.call(['ip6tables', '-t', 'filter', '-L', 'OUTPUT',
                        '-n', '-v', '-x', '-Z'],
                       root_helper=self.root_helper),
             iptables_dump),
        ]
        tools.setup_mock_calls(self.execute, expected_calls_and_values)

        acc = self.iptables.get_traffic_counters('OUTPUT', zero=True)
        self.assertEqual(acc['pkts'], 1600)
        self.assertEqual(acc['bytes'], 263604)

        tools.verify_mock_calls(self.execute, expected_calls_and_values)
开发者ID:ArifovicH,项目名称:neutron,代码行数:31,代码来源:test_iptables_manager.py

示例4: test_get_vif_port_set

    def test_get_vif_port_set(self):
        id_key = 'iface-id'
        headings = ['name', 'external_ids', 'ofport']
        data = [
            # A vif port on this bridge:
            ['tap99', {id_key: 'tap99id', 'attached-mac': 'tap99mac'}, 1],
            # A vif port on this bridge not yet configured
            ['tap98', {id_key: 'tap98id', 'attached-mac': 'tap98mac'}, []],
            # Another vif port on this bridge not yet configured
            ['tap97', {id_key: 'tap97id', 'attached-mac': 'tap97mac'},
             ['set', []]],

            # Non-vif port on this bridge:
            ['bogus', {}, 2],
        ]

        # Each element is a tuple of (expected mock call, return_value)
        expected_calls_and_values = [
            (self._vsctl_mock("list-ports", self.BR_NAME), 'tap99\\ntun22'),
            (self._vsctl_mock("--if-exists",
                              "--columns=name,external_ids,ofport",
                              "list", "Interface", 'tap99', 'tun22'),
             self._encode_ovs_json(headings, data)),
        ]
        tools.setup_mock_calls(self.execute, expected_calls_and_values)

        port_set = self.br.get_vif_port_set()
        self.assertEqual(set(['tap99id']), port_set)
        tools.verify_mock_calls(self.execute, expected_calls_and_values)
开发者ID:AradhanaSingh,项目名称:neutron,代码行数:29,代码来源:test_ovs_lib.py

示例5: _test_get_vif_port_by_id

    def _test_get_vif_port_by_id(self, iface_id, data, br_name=None,
                                 extra_calls_and_values=None):
        headings = ['external_ids', 'name', 'ofport']

        # Each element is a tuple of (expected mock call, return_value)
        expected_calls_and_values = [
            (self._vsctl_mock("--columns=external_ids,name,ofport", "find",
                              "Interface",
                              'external_ids:iface-id=%s' % iface_id,
                              'external_ids:attached-mac!=""'),
             self._encode_ovs_json(headings, data))]
        if data:
            if not br_name:
                br_name = self.BR_NAME

            # Only the last information list in 'data' is used, so if more
            # than one vif is described in data, the rest must be declared
            # in the argument 'expected_calls_and_values'.
            if extra_calls_and_values:
                expected_calls_and_values.extend(extra_calls_and_values)

            expected_calls_and_values.append(
                (self._vsctl_mock("iface-to-br",
                                  data[-1][headings.index('name')]), br_name))
        tools.setup_mock_calls(self.execute, expected_calls_and_values)
        vif_port = self.br.get_vif_port_by_id(iface_id)

        tools.verify_mock_calls(self.execute, expected_calls_and_values)
        return vif_port
开发者ID:EnterSrl,项目名称:neutron,代码行数:29,代码来源:test_ovs_lib.py

示例6: test_add_patch_port

    def test_add_patch_port(self):
        pname = "tap99"
        peer = "bar10"
        ofport = "6"

        # Each element is a tuple of (expected mock call, return_value)
        expected_calls_and_values = [
            (mock.call(["ovs-vsctl", self.TO, "add-port",
                        self.BR_NAME, pname], root_helper=self.root_helper),
             None),
            (mock.call(["ovs-vsctl", self.TO, "set", "Interface",
                        pname, "type=patch"], root_helper=self.root_helper),
             None),
            (mock.call(["ovs-vsctl", self.TO, "set",
                        "Interface", pname, "options:peer=" + peer],
                       root_helper=self.root_helper),
             None),
            (mock.call(["ovs-vsctl", self.TO, "get",
                        "Interface", pname, "ofport"],
                       root_helper=self.root_helper),
             ofport)
        ]
        tools.setup_mock_calls(self.execute, expected_calls_and_values)

        self.assertEqual(self.br.add_patch_port(pname, peer), ofport)
        tools.verify_mock_calls(self.execute, expected_calls_and_values)
开发者ID:Karbit,项目名称:neutron,代码行数:26,代码来源:test_ovs_lib.py

示例7: test_delete_neutron_ports_list_error

 def test_delete_neutron_ports_list_error(self):
     expected_calls_and_values = [
         (self._vsctl_mock("list-ports", self.BR_NAME), RuntimeError()),
     ]
     tools.setup_mock_calls(self.execute, expected_calls_and_values)
     self.assertRaises(RuntimeError, self.br.delete_ports, all_ports=False)
     tools.verify_mock_calls(self.execute, expected_calls_and_values)
开发者ID:EnterSrl,项目名称:neutron,代码行数:7,代码来源:test_ovs_lib.py

示例8: test_add_tunnel_port

    def test_add_tunnel_port(self):
        pname = "tap99"
        local_ip = "1.1.1.1"
        remote_ip = "9.9.9.9"
        ofport = 6
        command = ["--may-exist", "add-port", self.BR_NAME, pname]
        command.extend(["--", "set", "Interface", pname])
        command.extend(
            [
                "type=gre",
                "options:df_default=true",
                "options:remote_ip=" + remote_ip,
                "options:local_ip=" + local_ip,
                "options:in_key=flow",
                "options:out_key=flow",
            ]
        )
        # Each element is a tuple of (expected mock call, return_value)
        expected_calls_and_values = [
            (self._vsctl_mock(*command), None),
            (
                self._vsctl_mock("--columns=ofport", "list", "Interface", pname),
                self._encode_ovs_json(["ofport"], [[ofport]]),
            ),
        ]
        tools.setup_mock_calls(self.execute, expected_calls_and_values)

        self.assertEqual(self.br.add_tunnel_port(pname, remote_ip, local_ip), ofport)

        tools.verify_mock_calls(self.execute, expected_calls_and_values)
开发者ID:yizhongyin,项目名称:OpenstackLiberty,代码行数:30,代码来源:test_ovs_lib.py

示例9: test_add_blank_rule

    def test_add_blank_rule(self):
        self.iptables = iptables_manager.IptablesManager(
            use_ipv6=False)
        self.execute = mock.patch.object(self.iptables, "execute").start()

        iptables_args = {}
        iptables_args.update(IPTABLES_ARG)
        filter_rules = ('-A %(bn)s-test-filter\n' % iptables_args)
        iptables_args['filter_rules'] = filter_rules
        filter_dump_mod = FILTER_RESTORE_DUMP % iptables_args

        expected_calls_and_values = [
            (mock.call(['iptables-save'],
                       run_as_root=True),
             (filter_dump_mod + MANGLE_RESTORE_DUMP +
              NAT_RESTORE_DUMP + RAW_RESTORE_DUMP)),
        ]

        tools.setup_mock_calls(self.execute, expected_calls_and_values)

        self.iptables.ipv4['filter'].add_chain('test-filter')
        self.iptables.ipv4['filter'].add_rule('test-filter', '')

        self.iptables.apply()

        tools.verify_mock_calls(self.execute, expected_calls_and_values)
开发者ID:sebrandon1,项目名称:neutron,代码行数:26,代码来源:test_iptables_manager.py

示例10: test_add_vxlan_fragmented_tunnel_port

    def test_add_vxlan_fragmented_tunnel_port(self):
        pname = "tap99"
        local_ip = "1.1.1.1"
        remote_ip = "9.9.9.9"
        ofport = 6
        vxlan_udp_port = "9999"
        dont_fragment = False
        command = ["--may-exist", "add-port", self.BR_NAME, pname]
        command.extend(["--", "set", "Interface", pname])
        command.extend(["type=" + constants.TYPE_VXLAN,
                        "options:dst_port=" + vxlan_udp_port,
                        "options:df_default=false",
                        "options:remote_ip=" + remote_ip,
                        "options:local_ip=" + local_ip,
                        "options:in_key=flow",
                        "options:out_key=flow"])
        # Each element is a tuple of (expected mock call, return_value)
        expected_calls_and_values = [
            (self._vsctl_mock(*command), None),
            (self._vsctl_mock("--columns=ofport", "list", "Interface", pname),
             self._encode_ovs_json(['ofport'], [[ofport]])),
        ]
        tools.setup_mock_calls(self.execute, expected_calls_and_values)

        self.assertEqual(
            self.br.add_tunnel_port(pname, remote_ip, local_ip,
                                    constants.TYPE_VXLAN, vxlan_udp_port,
                                    dont_fragment),
            ofport)

        tools.verify_mock_calls(self.execute, expected_calls_and_values)
开发者ID:EnterSrl,项目名称:neutron,代码行数:31,代码来源:test_ovs_lib.py

示例11: test_add_tunnel_port

    def test_add_tunnel_port(self):
        pname = "tap99"
        local_ip = "1.1.1.1"
        remote_ip = "9.9.9.9"
        ofport = "6"
        command = ["ovs-vsctl", self.TO, '--', "--may-exist", "add-port",
                   self.BR_NAME, pname]
        command.extend(["--", "set", "Interface", pname])
        command.extend(["type=gre", "options:remote_ip=" + remote_ip,
                        "options:local_ip=" + local_ip,
                        "options:in_key=flow",
                        "options:out_key=flow"])
        # Each element is a tuple of (expected mock call, return_value)
        expected_calls_and_values = [
            (mock.call(command, root_helper=self.root_helper), None),
            (mock.call(["ovs-vsctl", self.TO, "get",
                        "Interface", pname, "ofport"],
                       root_helper=self.root_helper),
             ofport),
        ]
        tools.setup_mock_calls(self.execute, expected_calls_and_values)

        self.assertEqual(
            self.br.add_tunnel_port(pname, remote_ip, local_ip),
            ofport)

        tools.verify_mock_calls(self.execute, expected_calls_and_values)
开发者ID:yuhui7red,项目名称:neutron,代码行数:27,代码来源:test_ovs_lib.py

示例12: test_get_vif_port_set_list_ports_error

 def test_get_vif_port_set_list_ports_error(self):
     expected_calls_and_values = [
         (self._vsctl_mock("list-ports", self.BR_NAME), RuntimeError()),
     ]
     tools.setup_mock_calls(self.execute, expected_calls_and_values)
     self.assertRaises(RuntimeError, self.br.get_vif_port_set)
     tools.verify_mock_calls(self.execute, expected_calls_and_values)
开发者ID:EnterSrl,项目名称:neutron,代码行数:7,代码来源:test_ovs_lib.py

示例13: _test_add_filter_rule_helper

    def _test_add_filter_rule_helper(self, use_ipv6):
        self.iptables = iptables_manager.IptablesManager(
            root_helper=self.root_helper, use_ipv6=use_ipv6)
        self.execute = mock.patch.object(self.iptables, "execute").start()

        filter_dump_mod = ('# Generated by iptables_manager\n'
                           '*filter\n'
                           ':neutron-filter-top - [0:0]\n'
                           ':%(bn)s-FORWARD - [0:0]\n'
                           ':%(bn)s-INPUT - [0:0]\n'
                           ':%(bn)s-OUTPUT - [0:0]\n'
                           ':%(bn)s-filter - [0:0]\n'
                           ':%(bn)s-local - [0:0]\n'
                           '[0:0] -A FORWARD -j neutron-filter-top\n'
                           '[0:0] -A OUTPUT -j neutron-filter-top\n'
                           '[0:0] -A neutron-filter-top -j %(bn)s-local\n'
                           '[0:0] -A INPUT -j %(bn)s-INPUT\n'
                           '[0:0] -A OUTPUT -j %(bn)s-OUTPUT\n'
                           '[0:0] -A FORWARD -j %(bn)s-FORWARD\n'
                           '[0:0] -A %(bn)s-filter -j DROP\n'
                           '[0:0] -A %(bn)s-INPUT -s 0/0 -d 192.168.0.2 -j '
                           '%(bn)s-filter\n'
                           'COMMIT\n'
                           '# Completed by iptables_manager\n' % IPTABLES_ARG)

        expected_calls_and_values = [
            (mock.call(['iptables-save', '-c'], root_helper=self.root_helper),
             ''),
            (mock.call(['iptables-restore', '-c'],
                       process_input=RAW_DUMP + NAT_DUMP + filter_dump_mod,
                       root_helper=self.root_helper), None),
            (mock.call(['iptables-save', '-c'], root_helper=self.root_helper),
             ''),
            (mock.call(['iptables-restore', '-c'],
                       process_input=RAW_DUMP + NAT_DUMP + FILTER_DUMP,
                       root_helper=self.root_helper), None),
        ]
        if use_ipv6:
            self._extend_with_ip6tables_filter(expected_calls_and_values,
                                               FILTER_DUMP)

        tools.setup_mock_calls(self.execute, expected_calls_and_values)

        self.iptables.ipv4['filter'].add_chain('filter')
        self.iptables.ipv4['filter'].add_rule('filter', '-j DROP')
        self.iptables.ipv4['filter'].add_rule(
            'INPUT', '-s 0/0 -d 192.168.0.2 -j'
            ' %(bn)s-filter' % IPTABLES_ARG)
        self.iptables.apply()

        self.iptables.ipv4['filter'].remove_rule('filter', '-j DROP')
        self.iptables.ipv4['filter'].remove_rule(
            'INPUT', '-s 0/0 -d 192.168.0.2 -j'
            ' %(bn)s-filter' % IPTABLES_ARG)
        self.iptables.ipv4['filter'].remove_chain('filter')

        self.iptables.apply()

        tools.verify_mock_calls(self.execute, expected_calls_and_values)
开发者ID:chrisacbr,项目名称:openstack-neutron,代码行数:59,代码来源:test_iptables_manager.py

示例14: test_add_filter_rule

    def test_add_filter_rule(self):
        filter_dump_mod = (
            "# Generated by iptables_manager\n"
            "*filter\n"
            ":neutron-filter-top - [0:0]\n"
            ":%(bn)s-FORWARD - [0:0]\n"
            ":%(bn)s-INPUT - [0:0]\n"
            ":%(bn)s-OUTPUT - [0:0]\n"
            ":%(bn)s-filter - [0:0]\n"
            ":%(bn)s-local - [0:0]\n"
            "[0:0] -A FORWARD -j neutron-filter-top\n"
            "[0:0] -A OUTPUT -j neutron-filter-top\n"
            "[0:0] -A neutron-filter-top -j %(bn)s-local\n"
            "[0:0] -A INPUT -j %(bn)s-INPUT\n"
            "[0:0] -A OUTPUT -j %(bn)s-OUTPUT\n"
            "[0:0] -A FORWARD -j %(bn)s-FORWARD\n"
            "[0:0] -A %(bn)s-filter -j DROP\n"
            "[0:0] -A %(bn)s-INPUT -s 0/0 -d 192.168.0.2 -j "
            "%(bn)s-filter\n"
            "COMMIT\n"
            "# Completed by iptables_manager\n" % IPTABLES_ARG
        )

        raw_dump = _generate_raw_dump(IPTABLES_ARG)

        expected_calls_and_values = [
            (mock.call(["iptables-save", "-c"], root_helper=self.root_helper), ""),
            (
                mock.call(
                    ["iptables-restore", "-c"],
                    process_input=(raw_dump + COMMENTED_NAT_DUMP + filter_dump_mod),
                    root_helper=self.root_helper,
                ),
                None,
            ),
            (mock.call(["iptables-save", "-c"], root_helper=self.root_helper), ""),
            (
                mock.call(
                    ["iptables-restore", "-c"],
                    process_input=(raw_dump + COMMENTED_NAT_DUMP + FILTER_DUMP),
                    root_helper=self.root_helper,
                ),
                None,
            ),
        ]
        tools.setup_mock_calls(self.execute, expected_calls_and_values)

        self.iptables.ipv4["filter"].add_chain("filter")
        self.iptables.ipv4["filter"].add_rule("filter", "-j DROP")
        self.iptables.ipv4["filter"].add_rule("INPUT", "-s 0/0 -d 192.168.0.2 -j" " %(bn)s-filter" % IPTABLES_ARG)
        self.iptables.apply()

        self.iptables.ipv4["filter"].remove_rule("filter", "-j DROP")
        self.iptables.ipv4["filter"].remove_rule("INPUT", "-s 0/0 -d 192.168.0.2 -j" " %(bn)s-filter" % IPTABLES_ARG)
        self.iptables.ipv4["filter"].remove_chain("filter")

        self.iptables.apply()

        tools.verify_mock_calls(self.execute, expected_calls_and_values)
开发者ID:hyunsun,项目名称:quantum,代码行数:59,代码来源:test_iptables_manager.py

示例15: _test_add_filter_rule_helper

    def _test_add_filter_rule_helper(self, use_ipv6):
        self.iptables = iptables_manager.IptablesManager(
            use_ipv6=use_ipv6)
        self.execute = mock.patch.object(self.iptables, "execute").start()

        iptables_args = {}
        iptables_args.update(IPTABLES_ARG)
        filter_rules = ('-I %(bn)s-INPUT 1 -s 0/0 -d 192.168.0.2 -j '
                        '%(bn)s-filter\n-I %(bn)s-filter 1 -j DROP\n'
                        % iptables_args)
        iptables_args['filter_rules'] = filter_rules
        filter_dump_mod = FILTER_WITH_RULES_TEMPLATE % iptables_args

        raw_dump = RAW_DUMP % IPTABLES_ARG

        expected_calls_and_values = [
            (mock.call(['iptables-save'],
                       run_as_root=True),
             ''),
            (mock.call(['iptables-restore', '-n'],
                       process_input=(filter_dump_mod + MANGLE_DUMP +
                                      NAT_DUMP + RAW_DUMP),
                       run_as_root=True),
             None),
            (mock.call(['iptables-save'],
                       run_as_root=True),
             ''),
            (mock.call(['iptables-restore', '-n'],
                       process_input=(FILTER_DUMP + MANGLE_DUMP + NAT_DUMP +
                                      RAW_DUMP),
                       run_as_root=True
                       ),
             None),
        ]
        if use_ipv6:
            self._extend_with_ip6tables_filter(
                expected_calls_and_values,
                FILTER_DUMP + MANGLE_DUMP_V6 + raw_dump)

        tools.setup_mock_calls(self.execute, expected_calls_and_values)

        self.iptables.ipv4['filter'].add_chain('filter')
        self.iptables.ipv4['filter'].add_rule('filter', '-j DROP')
        self.iptables.ipv4['filter'].add_rule('INPUT',
                                              '-s 0/0 -d 192.168.0.2 -j'
                                              ' %(bn)s-filter' % IPTABLES_ARG)
        self.iptables.apply()

        self.iptables.ipv4['filter'].remove_rule('filter', '-j DROP')
        self.iptables.ipv4['filter'].remove_rule('INPUT',
                                                 '-s 0/0 -d 192.168.0.2 -j'
                                                 ' %(bn)s-filter'
                                                 % IPTABLES_ARG)
        self.iptables.ipv4['filter'].remove_chain('filter')

        self.iptables.apply()

        tools.verify_mock_calls(self.execute, expected_calls_and_values)
开发者ID:MODITDC,项目名称:neutron,代码行数:58,代码来源:test_iptables_manager.py


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