• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python test_cli20.end_url函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_get_id_from_id_then_name_empty

    def test_get_id_from_id_then_name_empty(self):
        _id = uuidutils.generate_uuid()
        reses = {'networks': [{'id': _id, }, ], }
        resstr = self.client.serialize(reses)
        resstr1 = self.client.serialize({'networks': []})
        path = getattr(self.client, "networks_path")
        with mock.patch.object(self.client.httpclient,
                               "request") as mock_request:
            mock_request.side_effect = [(test_cli20.MyResp(200), resstr1),
                                        (test_cli20.MyResp(200), resstr)]
            returned_id = neutronV20.find_resourceid_by_name_or_id(
                self.client, 'network', _id)

        self.assertEqual(2, mock_request.call_count)
        mock_request.assert_has_calls([
            mock.call(
                test_cli20.MyUrlComparator(
                    test_cli20.end_url(path, "fields=id&id=" + _id),
                    self.client),
                'GET',
                body=None,
                headers=test_cli20.ContainsKeyValue(
                    {'X-Auth-Token': test_cli20.TOKEN})),
            mock.call(
                test_cli20.MyUrlComparator(
                    test_cli20.end_url(path, "fields=id&name=" + _id),
                    self.client),
                'GET',
                body=None,
                headers=test_cli20.ContainsKeyValue(
                    {'X-Auth-Token': test_cli20.TOKEN}))])
        self.assertEqual(_id, returned_id)
开发者ID:noironetworks,项目名称:python-neutronclient,代码行数:32,代码来源:test_name_or_id.py


示例2: test_get_id_from_id_then_name_empty

 def test_get_id_from_id_then_name_empty(self):
     _id = str(uuid.uuid4())
     reses = {'networks': [{'id': _id, }, ], }
     resstr = self.client.serialize(reses)
     resstr1 = self.client.serialize({'networks': []})
     self.mox.StubOutWithMock(self.client.httpclient, "request")
     path = getattr(self.client, "networks_path")
     self.client.httpclient.request(
         test_cli20.MyUrlComparator(
             test_cli20.end_url(path, "fields=id&id=" + _id),
             self.client),
         'GET',
         body=None,
         headers=mox.ContainsKeyValue('X-Auth-Token', test_cli20.TOKEN)
     ).AndReturn((test_cli20.MyResp(200), resstr1))
     self.client.httpclient.request(
         test_cli20.MyUrlComparator(
             test_cli20.end_url(path, "fields=id&name=" + _id),
             self.client),
         'GET',
         body=None,
         headers=mox.ContainsKeyValue('X-Auth-Token', test_cli20.TOKEN)
     ).AndReturn((test_cli20.MyResp(200), resstr))
     self.mox.ReplayAll()
     returned_id = neutronV20.find_resourceid_by_name_or_id(
         self.client, 'network', _id)
     self.assertEqual(_id, returned_id)
开发者ID:AsherBond,项目名称:python-quantumclient,代码行数:27,代码来源:test_name_or_id.py


示例3: _test_list_nets_extend_subnets

    def _test_list_nets_extend_subnets(self, data, expected):
        cmd = network.ListNetwork(test_cli20.MyApp(sys.stdout), None)
        nets_path = getattr(self.client, 'networks_path')
        subnets_path = getattr(self.client, 'subnets_path')
        nets_query = ''
        filters = ''
        for n in data:
            for s in n['subnets']:
                filters = filters + "&id=%s" % s
        subnets_query = 'fields=id&fields=cidr' + filters
        with mock.patch.object(cmd, 'get_client',
                               return_value=self.client) as mock_get_client, \
                mock.patch.object(self.client.httpclient,
                                  "request") as mock_request:
            resp1 = (test_cli20.MyResp(200),
                     self.client.serialize({'networks': data}))
            resp2 = (test_cli20.MyResp(200),
                     self.client.serialize({'subnets': [
                         {'id': 'mysubid1', 'cidr': '192.168.1.0/24'},
                         {'id': 'mysubid2', 'cidr': '172.16.0.0/24'},
                         {'id': 'mysubid3', 'cidr': '10.1.1.0/24'}]}))
            mock_request.side_effect = [resp1, resp2]
            args = []
            cmd_parser = cmd.get_parser('list_networks')
            parsed_args = cmd_parser.parse_args(args)
            result = cmd.take_action(parsed_args)

        mock_get_client.assert_called_with()
        self.assertEqual(2, mock_request.call_count)
        mock_request.assert_has_calls([
            mock.call(
                test_cli20.MyUrlComparator(
                    test_cli20.end_url(nets_path, nets_query),
                    self.client),
                'GET',
                body=None,
                headers=test_cli20.ContainsKeyValue(
                    {'X-Auth-Token': test_cli20.TOKEN})),
            mock.call(
                test_cli20.MyUrlComparator(
                    test_cli20.end_url(subnets_path, subnets_query),
                    self.client),
                'GET',
                body=None,
                headers=test_cli20.ContainsKeyValue(
                    {'X-Auth-Token': test_cli20.TOKEN}))])
        _result = [x for x in result[1]]
        self.assertEqual(len(expected), len(_result))
        for res, exp in zip(_result, expected):
            self.assertEqual(len(exp), len(res))
            for obsrvd, expctd in zip(res, exp):
                self.assertEqual(expctd, obsrvd)
开发者ID:sajuptpm,项目名称:python-neutronclient,代码行数:52,代码来源:test_cli20_network.py


示例4: _test_list_external_nets

    def _test_list_external_nets(self, resources, cmd, detail=False, tags=(), fields_1=(), fields_2=()):
        self.mox.StubOutWithMock(cmd, "get_client")
        self.mox.StubOutWithMock(self.client.httpclient, "request")
        self.mox.StubOutWithMock(network.ListNetwork, "extend_list")
        network.ListNetwork.extend_list(mox.IsA(list), mox.IgnoreArg())
        cmd.get_client().MultipleTimes().AndReturn(self.client)
        reses = {resources: [{"id": "myid1"}, {"id": "myid2"}]}

        resstr = self.client.serialize(reses)

        # url method body
        query = ""
        args = detail and ["-D"] or []
        if fields_1:
            for field in fields_1:
                args.append("--fields")
                args.append(field)
        if tags:
            args.append("--")
            args.append("--tag")
        for tag in tags:
            args.append(tag)
        if (not tags) and fields_2:
            args.append("--")
        if fields_2:
            args.append("--fields")
            for field in fields_2:
                args.append(field)
        for field in itertools.chain(fields_1, fields_2):
            if query:
                query += "&fields=" + field
            else:
                query = "fields=" + field
        if query:
            query += "&router%3Aexternal=True"
        else:
            query += "router%3Aexternal=True"
        for tag in tags:
            if query:
                query += "&tag=" + tag
            else:
                query = "tag=" + tag
        if detail:
            query = query and query + "&verbose=True" or "verbose=True"
        path = getattr(self.client, resources + "_path")

        self.client.httpclient.request(
            test_cli20.MyUrlComparator(test_cli20.end_url(path, query), self.client),
            "GET",
            body=None,
            headers=mox.ContainsKeyValue("X-Auth-Token", test_cli20.TOKEN),
        ).AndReturn((test_cli20.MyResp(200), resstr))
        self.mox.ReplayAll()
        cmd_parser = cmd.get_parser("list_" + resources)
        shell.run_command(cmd, cmd_parser, args)
        self.mox.VerifyAll()
        self.mox.UnsetStubs()
        _str = self.fake_stdout.make_string()

        self.assertIn("myid1", _str)
开发者ID:gocloudxyz,项目名称:rackspace-python-neutronclient,代码行数:60,代码来源:test_cli20_network.py


示例5: test_list_nets_empty_with_column

 def test_list_nets_empty_with_column(self):
     resources = "networks"
     cmd = network.ListNetwork(test_cli20.MyApp(sys.stdout), None)
     self.mox.StubOutWithMock(cmd, "get_client")
     self.mox.StubOutWithMock(self.client.httpclient, "request")
     self.mox.StubOutWithMock(network.ListNetwork, "extend_list")
     network.ListNetwork.extend_list(mox.IsA(list), mox.IgnoreArg())
     cmd.get_client().MultipleTimes().AndReturn(self.client)
     reses = {resources: []}
     resstr = self.client.serialize(reses)
     # url method body
     query = "id=myfakeid"
     args = ["-c", "id", "--", "--id", "myfakeid"]
     path = getattr(self.client, resources + "_path")
     self.client.httpclient.request(
         test_cli20.MyUrlComparator(test_cli20.end_url(path, query), self.client),
         "GET",
         body=None,
         headers=mox.ContainsKeyValue("X-Auth-Token", test_cli20.TOKEN),
     ).AndReturn((test_cli20.MyResp(200), resstr))
     self.mox.ReplayAll()
     cmd_parser = cmd.get_parser("list_" + resources)
     shell.run_command(cmd, cmd_parser, args)
     self.mox.VerifyAll()
     self.mox.UnsetStubs()
     _str = self.fake_stdout.make_string()
     self.assertEqual("\n", _str)
开发者ID:gocloudxyz,项目名称:rackspace-python-neutronclient,代码行数:27,代码来源:test_cli20_network.py


示例6: test_show_quota_default

    def test_show_quota_default(self):
        resource = 'quota'
        cmd = test_quota.ShowQuotaDefault(
            test_cli20.MyApp(sys.stdout), None)
        args = ['--tenant-id', self.test_id]
        expected_res = {'quota': {'port': 50, 'network': 10, 'subnet': 10}}
        resstr = self.client.serialize(expected_res)
        path = getattr(self.client, "quota_default_path")
        return_tup = (test_cli20.MyResp(200), resstr)
        with mock.patch.object(cmd, 'get_client',
                               return_value=self.client) as mock_get_client, \
                mock.patch.object(self.client.httpclient, 'request',
                                  return_value=return_tup) as mock_request:
            cmd_parser = cmd.get_parser("test_" + resource)
            parsed_args = cmd_parser.parse_args(args)
            cmd.run(parsed_args)

        mock_get_client.assert_called_once_with()
        mock_request.assert_called_once_with(
            test_cli20.end_url(path % self.test_id), 'GET',
            body=None,
            headers=test_cli20.ContainsKeyValue(
                {'X-Auth-Token': test_cli20.TOKEN}))
        _str = self.fake_stdout.make_string()
        self.assertIn('network', _str)
        self.assertIn('subnet', _str)
        self.assertIn('port', _str)
        self.assertNotIn('subnetpool', _str)
开发者ID:noironetworks,项目名称:python-neutronclient,代码行数:28,代码来源:test_quota.py


示例7: test_remove_firewall_rule

    def test_remove_firewall_rule(self):
        # firewall-policy-remove-rule myid ruleid
        resource = 'firewall_policy'
        cmd = firewallpolicy.FirewallPolicyRemoveRule(
            test_cli20.MyApp(sys.stdout),
            None)
        myid = 'myid'
        args = ['myid', 'removerule']
        extrafields = {'firewall_rule_id': 'removerule', }

        body = extrafields
        path = getattr(self.client, resource + "_remove_path")
        cmd_parser = cmd.get_parser(resource + "_remove_rule")
        resp = (test_cli20.MyResp(204), None)

        with mock.patch.object(cmd, "get_client",
                               return_value=self.client) as mock_get_client, \
                mock.patch.object(self.client.httpclient, "request",
                                  return_value=resp) as mock_request:
            shell.run_command(cmd, cmd_parser, args)
        self.assert_mock_multiple_calls_with_same_arguments(
            mock_get_client, mock.call(), 2)
        mock_request.assert_called_once_with(
            test_cli20.MyUrlComparator(
                test_cli20.end_url(path % myid),
                self.client),
            'PUT', body=test_cli20.MyComparator(body, self.client),
            headers=test_cli20.ContainsKeyValue(
                {'X-Auth-Token': test_cli20.TOKEN}))
开发者ID:noironetworks,项目名称:python-neutronclient,代码行数:29,代码来源:test_cli20_firewallpolicy.py


示例8: test_retrieve_loadbalancer_stats

    def test_retrieve_loadbalancer_stats(self):
        # lbaas-loadbalancer-stats test_id.
        resource = 'loadbalancer'
        cmd = lb.RetrieveLoadBalancerStats(test_cli20.MyApp(sys.stdout), None)
        my_id = self.test_id
        fields = ['bytes_in', 'bytes_out']
        args = ['--fields', 'bytes_in', '--fields', 'bytes_out', my_id]

        self.mox.StubOutWithMock(cmd, "get_client")
        self.mox.StubOutWithMock(self.client.httpclient, "request")
        cmd.get_client().MultipleTimes().AndReturn(self.client)
        query = "&".join(["fields=%s" % field for field in fields])
        expected_res = {'stats': {'bytes_in': '1234', 'bytes_out': '4321'}}
        resstr = self.client.serialize(expected_res)
        path = getattr(self.client, "lbaas_loadbalancer_path_stats")
        return_tup = (test_cli20.MyResp(200), resstr)
        self.client.httpclient.request(
            test_cli20.end_url(path % my_id, query), 'GET',
            body=None,
            headers=mox.ContainsKeyValue(
                'X-Auth-Token', test_cli20.TOKEN)).AndReturn(return_tup)
        self.mox.ReplayAll()

        cmd_parser = cmd.get_parser("test_" + resource)
        parsed_args = cmd_parser.parse_args(args)
        cmd.run(parsed_args)

        self.mox.VerifyAll()
        self.mox.UnsetStubs()
        _str = self.fake_stdout.make_string()
        self.assertIn('bytes_in', _str)
        self.assertIn('1234', _str)
        self.assertIn('bytes_out', _str)
        self.assertIn('4321', _str)
开发者ID:ChameleonCloud,项目名称:python-neutronclient,代码行数:34,代码来源:test_cli20_loadbalancer.py


示例9: _test_list_router_port

    def _test_list_router_port(self, resources, cmd,
                               myid, detail=False, tags=[],
                               fields_1=[], fields_2=[]):
        self.mox.StubOutWithMock(cmd, "get_client")
        self.mox.StubOutWithMock(self.client.httpclient, "request")
        cmd.get_client().MultipleTimes().AndReturn(self.client)
        reses = {resources: [{'id': 'myid1', },
                             {'id': 'myid2', }, ], }

        resstr = self.client.serialize(reses)

        # url method body
        query = ""
        args = detail and ['-D', ] or []

        if fields_1:
            for field in fields_1:
                args.append('--fields')
                args.append(field)
        args.append(myid)
        if tags:
            args.append('--')
            args.append("--tag")
        for tag in tags:
            args.append(tag)
        if (not tags) and fields_2:
            args.append('--')
        if fields_2:
            args.append("--fields")
            for field in fields_2:
                args.append(field)
        fields_1.extend(fields_2)
        for field in fields_1:
            if query:
                query += "&fields=" + field
            else:
                query = "fields=" + field

        for tag in tags:
            if query:
                query += "&tag=" + tag
            else:
                query = "tag=" + tag
        if detail:
            query = query and query + '&verbose=True' or 'verbose=True'
        query = query and query + '&device_id=%s' or 'device_id=%s'
        path = getattr(self.client, resources + "_path")
        self.client.httpclient.request(
            test_cli20.end_url(path, query % myid), 'GET',
            body=None,
            headers=mox.ContainsKeyValue('X-Auth-Token', test_cli20.TOKEN)
        ).AndReturn((test_cli20.MyResp(200), resstr))
        self.mox.ReplayAll()
        cmd_parser = cmd.get_parser("list_" + resources)
        shell.run_command(cmd, cmd_parser, args)
        self.mox.VerifyAll()
        self.mox.UnsetStubs()
        _str = self.fake_stdout.make_string()

        self.assertTrue('myid1' in _str)
开发者ID:openstack-vmwareapi-team,项目名称:python-neutronclient,代码行数:60,代码来源:test_cli20_port.py


示例10: _test_get_resource_by_id

 def _test_get_resource_by_id(self, id_only=False):
     _id = uuidutils.generate_uuid()
     net = {'id': _id, 'name': 'test'}
     reses = {'networks': [net], }
     resstr = self.client.serialize(reses)
     self.mox.StubOutWithMock(self.client.httpclient, "request")
     path = getattr(self.client, "networks_path")
     if id_only:
         query_params = "fields=id&id=%s" % _id
     else:
         query_params = "id=%s" % _id
     self.client.httpclient.request(
         test_cli20.MyUrlComparator(
             test_cli20.end_url(path, query_params),
             self.client),
         'GET',
         body=None,
         headers=mox.ContainsKeyValue('X-Auth-Token', test_cli20.TOKEN)
     ).AndReturn((test_cli20.MyResp(200), resstr))
     self.mox.ReplayAll()
     if id_only:
         returned_id = neutronV20.find_resourceid_by_id(
             self.client, 'network', _id)
         self.assertEqual(_id, returned_id)
     else:
         result = neutronV20.find_resource_by_id(
             self.client, 'network', _id)
         self.assertEqual(net, result)
开发者ID:huntxu,项目名称:python-neutronclient,代码行数:28,代码来源:test_name_or_id.py


示例11: test_get_id_from_name_multiple

 def test_get_id_from_name_multiple(self):
     name = 'myname'
     reses = {
         'networks': [{
             'id': str(uuid.uuid4())
         }, {
             'id': str(uuid.uuid4())
         }]
     }
     resstr = self.client.serialize(reses)
     self.mox.StubOutWithMock(self.client.httpclient, "request")
     path = getattr(self.client, "networks_path")
     self.client.httpclient.request(
         test_cli20.end_url(path, "fields=id&name=" + name),
         'GET',
         body=None,
         headers=mox.ContainsKeyValue('X-Auth-Token',
                                      test_cli20.TOKEN)).AndReturn(
                                          (test_cli20.MyResp(200), resstr))
     self.mox.ReplayAll()
     try:
         neutronV20.find_resourceid_by_name_or_id(self.client, 'network',
                                                  name)
     except exceptions.NeutronClientNoUniqueMatch as ex:
         self.assertIn('Multiple', ex.message)
开发者ID:B-Rich,项目名称:python-neutronclient,代码行数:25,代码来源:test_name_or_id.py


示例12: _test_get_resource_by_id

    def _test_get_resource_by_id(self, id_only=False):
        _id = uuidutils.generate_uuid()
        net = {'id': _id, 'name': 'test'}
        reses = {'networks': [net], }
        resstr = self.client.serialize(reses)
        resp = (test_cli20.MyResp(200), resstr)
        path = getattr(self.client, "networks_path")
        if id_only:
            query_params = "fields=id&id=%s" % _id
        else:
            query_params = "id=%s" % _id
        with mock.patch.object(self.client.httpclient, "request",
                               return_value=resp) as mock_request:
            if id_only:
                returned_id = neutronV20.find_resourceid_by_id(
                    self.client, 'network', _id)
                self.assertEqual(_id, returned_id)
            else:
                result = neutronV20.find_resource_by_id(
                    self.client, 'network', _id)
                self.assertEqual(net, result)

        mock_request.assert_called_once_with(
            test_cli20.MyUrlComparator(
                test_cli20.end_url(path, query_params),
                self.client),
            'GET',
            body=None,
            headers=test_cli20.ContainsKeyValue(
                {'X-Auth-Token': test_cli20.TOKEN}))
开发者ID:noironetworks,项目名称:python-neutronclient,代码行数:30,代码来源:test_name_or_id.py


示例13: test_disassociate_healthmonitor

    def test_disassociate_healthmonitor(self):
        cmd = healthmonitor.DisassociateHealthMonitor(
            test_cli20.MyApp(sys.stdout),
            None)
        resource = 'health_monitor'
        health_monitor_id = 'hm-id'
        pool_id = 'p_id'
        args = [health_monitor_id, pool_id]

        path = (getattr(self.client,
                        "disassociate_pool_health_monitors_path") %
                {'pool': pool_id, 'health_monitor': health_monitor_id})
        return_tup = (test_cli20.MyResp(204), None)
        cmd_parser = cmd.get_parser('test_' + resource)
        parsed_args = cmd_parser.parse_args(args)

        with mock.patch.object(cmd, "get_client",
                               return_value=self.client) as mock_get_client, \
                mock.patch.object(self.client.httpclient, "request",
                                  return_value=return_tup) as mock_request:
            cmd.run(parsed_args)

        mock_get_client.assert_called_once_with()
        mock_request.assert_called_once_with(
            test_cli20.end_url(path), 'DELETE',
            body=None,
            headers=test_cli20.ContainsKeyValue(
                {'X-Auth-Token': test_cli20.TOKEN}))
开发者ID:noironetworks,项目名称:python-neutronclient,代码行数:28,代码来源:test_cli20_healthmonitor.py


示例14: test_associate_healthmonitor

    def test_associate_healthmonitor(self):
        cmd = healthmonitor.AssociateHealthMonitor(
            test_cli20.MyApp(sys.stdout),
            None)
        resource = 'health_monitor'
        health_monitor_id = 'hm-id'
        pool_id = 'p_id'
        args = [health_monitor_id, pool_id]

        body = {resource: {'id': health_monitor_id}}
        result = {resource: {'id': health_monitor_id}, }
        result_str = self.client.serialize(result)

        path = getattr(self.client,
                       "associate_pool_health_monitors_path") % pool_id
        return_tup = (test_cli20.MyResp(200), result_str)
        cmd_parser = cmd.get_parser('test_' + resource)
        parsed_args = cmd_parser.parse_args(args)

        with mock.patch.object(cmd, "get_client",
                               return_value=self.client) as mock_get_client, \
                mock.patch.object(self.client.httpclient, "request",
                                  return_value=return_tup) as mock_request:
            cmd.run(parsed_args)

        mock_get_client.assert_called_once_with()
        mock_request.assert_called_once_with(
            test_cli20.end_url(path), 'POST',
            body=test_cli20.MyComparator(body, self.client),
            headers=test_cli20.ContainsKeyValue(
                {'X-Auth-Token': test_cli20.TOKEN}))
开发者ID:noironetworks,项目名称:python-neutronclient,代码行数:31,代码来源:test_cli20_healthmonitor.py


示例15: test_get_loadbalancer_statuses

    def test_get_loadbalancer_statuses(self):
        # lbaas-loadbalancer-status test_id.
        resource = 'loadbalancer'
        cmd = lb.RetrieveLoadBalancerStatus(test_cli20.MyApp(sys.stdout), None)
        my_id = self.test_id
        args = [my_id]

        expected_res = {'statuses': {'operating_status': 'ONLINE',
                                     'provisioning_status': 'ACTIVE'}}

        resstr = self.client.serialize(expected_res)

        path = getattr(self.client, "lbaas_loadbalancer_path_status")
        return_tup = (test_cli20.MyResp(200), resstr)

        cmd_parser = cmd.get_parser("test_" + resource)
        parsed_args = cmd_parser.parse_args(args)
        with mock.patch.object(cmd, "get_client",
                               return_value=self.client) as mock_get_client, \
                mock.patch.object(self.client.httpclient, "request",
                                  return_value=return_tup) as mock_request:
            cmd.run(parsed_args)

        mock_get_client.assert_called_once_with()
        mock_request.assert_called_once_with(
            test_cli20.end_url(path % my_id), 'GET',
            body=None,
            headers=test_cli20.ContainsKeyValue(
                {'X-Auth-Token': test_cli20.TOKEN}))
        _str = self.fake_stdout.make_string()
        self.assertIn('operating_status', _str)
        self.assertIn('ONLINE', _str)
        self.assertIn('provisioning_status', _str)
        self.assertIn('ACTIVE', _str)
开发者ID:noironetworks,项目名称:python-neutronclient,代码行数:34,代码来源:test_cli20_loadbalancer.py


示例16: _test_show_ext_resource

    def _test_show_ext_resource(self, resource, cmd, myid, args, fields=(),
                                cmd_resource=None, parent_id=None):
        self.mox.StubOutWithMock(cmd, "get_client")
        self.mox.StubOutWithMock(self.client.httpclient, "request")
        cmd.get_client().MultipleTimes().AndReturn(self.client)
        if not cmd_resource:
            cmd_resource = resource

        query = "&".join(["fields=%s" % field for field in fields])
        expected_res = {resource:
                        {self.id_field: myid,
                         'name': 'myname', }, }
        resstr = self.client.serialize(expected_res)
        path = getattr(self.client, cmd_resource + "_path")
        if parent_id:
            path = path % parent_id
        path = path % myid
        self.client.httpclient.request(
            test_cli20.end_url(path, query, format=self.format), 'GET',
            body=None,
            headers=mox.ContainsKeyValue(
                'X-Auth-Token', TOKEN)).AndReturn((MyResp(200), resstr))
        self.mox.ReplayAll()
        cmd_parser = cmd.get_parser("show_" + cmd_resource)
        shell.run_command(cmd, cmd_parser, args)
        self.mox.VerifyAll()
        self.mox.UnsetStubs()
        _str = self.fake_stdout.make_string()
        self.assertIn(myid, _str)
        self.assertIn('myname', _str)
开发者ID:Prabhat2015,项目名称:networking-midonet,代码行数:30,代码来源:test_cli20.py


示例17: test_show_quota_default

    def test_show_quota_default(self):
        resource = 'quota'
        cmd = test_quota.ShowQuotaDefault(
            test_cli20.MyApp(sys.stdout), None)
        args = ['--tenant-id', self.test_id]
        self.mox.StubOutWithMock(cmd, "get_client")
        self.mox.StubOutWithMock(self.client.httpclient, "request")
        cmd.get_client().MultipleTimes().AndReturn(self.client)
        expected_res = {'quota': {'port': 50, 'network': 10, 'subnet': 10}}
        resstr = self.client.serialize(expected_res)
        path = getattr(self.client, "quota_default_path")
        return_tup = (test_cli20.MyResp(200), resstr)
        self.client.httpclient.request(
            test_cli20.end_url(path % self.test_id), 'GET',
            body=None,
            headers=mox.ContainsKeyValue(
                'X-Auth-Token', test_cli20.TOKEN)).AndReturn(return_tup)
        self.mox.ReplayAll()

        cmd_parser = cmd.get_parser("test_" + resource)
        parsed_args = cmd_parser.parse_args(args)
        cmd.run(parsed_args)

        self.mox.VerifyAll()
        self.mox.UnsetStubs()
        _str = self.fake_stdout.make_string()
        self.assertIn('network', _str)
        self.assertIn('subnet', _str)
        self.assertIn('port', _str)
        self.assertNotIn('subnetpool', _str)
开发者ID:Juniper,项目名称:python-neutronclient,代码行数:30,代码来源:test_quota.py


示例18: test_remove_firewall_rule

    def test_remove_firewall_rule(self):
        # firewall-policy-remove-rule myid ruleid
        resource = 'firewall_policy'
        cmd = firewallpolicy.FirewallPolicyRemoveRule(
            test_cli20.MyApp(sys.stdout),
            None)
        myid = 'myid'
        args = ['myid', 'removerule']
        extrafields = {'firewall_rule_id': 'removerule', }

        self.mox.StubOutWithMock(cmd, "get_client")
        self.mox.StubOutWithMock(self.client.httpclient, "request")
        cmd.get_client().MultipleTimes().AndReturn(self.client)
        body = extrafields
        path = getattr(self.client, resource + "_remove_path")
        self.client.httpclient.request(
            test_cli20.MyUrlComparator(
                test_cli20.end_url(path % myid),
                self.client),
            'PUT', body=test_cli20.MyComparator(body, self.client),
            headers=mox.ContainsKeyValue(
                'X-Auth-Token',
                test_cli20.TOKEN)).AndReturn((test_cli20.MyResp(204), None))
        self.mox.ReplayAll()
        cmd_parser = cmd.get_parser(resource + "_remove_rule")
        shell.run_command(cmd, cmd_parser, args)
        self.mox.VerifyAll()
        self.mox.UnsetStubs()
开发者ID:huntxu,项目名称:python-neutronclient,代码行数:28,代码来源:test_cli20_firewallpolicy.py


示例19: test_retrieve_pool_stats

    def test_retrieve_pool_stats(self):
        # lb-pool-stats test_id.
        resource = 'pool'
        cmd = pool.RetrievePoolStats(test_cli20.MyApp(sys.stdout), None)
        my_id = self.test_id
        fields = ['bytes_in', 'bytes_out']
        args = ['--fields', 'bytes_in', '--fields', 'bytes_out', my_id]

        query = "&".join(["fields=%s" % field for field in fields])
        expected_res = {'stats': {'bytes_in': '1234', 'bytes_out': '4321'}}
        resstr = self.client.serialize(expected_res)
        path = getattr(self.client, "pool_path_stats")
        return_tup = (test_cli20.MyResp(200), resstr)

        cmd_parser = cmd.get_parser("test_" + resource)
        parsed_args = cmd_parser.parse_args(args)

        with mock.patch.object(cmd, "get_client",
                               return_value=self.client) as mock_get_client, \
                mock.patch.object(self.client.httpclient, "request",
                                  return_value=return_tup) as mock_request:
            cmd.run(parsed_args)

        self.assert_mock_multiple_calls_with_same_arguments(
            mock_get_client, mock.call(), 2)
        mock_request.assert_called_once_with(
            test_cli20.end_url(path % my_id, query), 'GET',
            body=None,
            headers=test_cli20.ContainsKeyValue(
                {'X-Auth-Token': test_cli20.TOKEN}))
        _str = self.fake_stdout.make_string()
        self.assertIn('bytes_in', _str)
        self.assertIn('bytes_out', _str)
开发者ID:noironetworks,项目名称:python-neutronclient,代码行数:33,代码来源:test_cli20_pool.py


示例20: test_extend_list

    def test_extend_list(self):
        data = [{'name': 'default',
                 'remote_group_id': 'remgroupid%02d' % i}
                for i in range(10)]
        data.append({'name': 'default', 'remote_group_id': None})
        resources = "security_groups"

        cmd = securitygroup.ListSecurityGroupRule(
            test_cli20.MyApp(sys.stdout), None)

        path = getattr(self.client, resources + '_path')
        responses = self._build_test_data(data)
        known_args, _vs = cmd.get_parser(
            'list' + resources).parse_known_args()
        resp = responses[0]['response']

        with mock.patch.object(cmd, "get_client",
                               return_value=self.client) as mock_get_client, \
                mock.patch.object(self.client.httpclient, "request",
                                  return_value=resp) as mock_request:
            cmd.extend_list(data, known_args)

        mock_get_client.assert_called_once_with()
        mock_request.assert_called_once_with(
            test_cli20.MyUrlComparator(test_cli20.end_url(
                path, responses[0]['filter']), self.client),
            'GET',
            body=None,
            headers=test_cli20.ContainsKeyValue(
                {'X-Auth-Token': test_cli20.TOKEN}))
开发者ID:noironetworks,项目名称:python-neutronclient,代码行数:30,代码来源:test_cli20_securitygroup.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python client.Client类代码示例发布时间:2022-05-27
下一篇:
Python shell.run_command函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap