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

Python base.reverse函数代码示例

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

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



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

示例1: test_release_put_orchestrator_data_w_masks

    def test_release_put_orchestrator_data_w_masks(self):
        release = self.env.create_release(api=False)

        orchestrator_data = {
            'repo_metadata': {
                '5.1': 'http://{MASTER_IP}:8080/centos/x86_64',
                '5.1-user': 'http://{MASTER_IP}:8080/centos-user/x86_64',
            },
            'puppet_modules_source': 'rsync://{MASTER_IP}:/puppet/modules/',
            'puppet_manifests_source': 'rsync://{MASTER_IP}:/puppet/manifests/'
        }

        resp = self.app.put(
            reverse('ReleaseHandler', kwargs={'obj_id': release.id}),
            params=jsonutils.dumps({'orchestrator_data': orchestrator_data}),
            headers=self.default_headers)
        self.assertEqual(200, resp.status_code)

        resp = self.app.get(
            reverse('ReleaseHandler', kwargs={'obj_id': release.id}),
            headers=self.default_headers)
        self.assertEqual(200, resp.status_code)
        orchestrator_data = resp.json_body['orchestrator_data']

        self.assertEqual(orchestrator_data['repo_metadata'], {
            '5.1': 'http://127.0.0.1:8080/centos/x86_64',
            '5.1-user': 'http://127.0.0.1:8080/centos-user/x86_64'})
        self.assertEqual(
            orchestrator_data['puppet_modules_source'],
            'rsync://127.0.0.1:/puppet/modules/')
        self.assertEqual(
            orchestrator_data['puppet_manifests_source'],
            'rsync://127.0.0.1:/puppet/manifests/')
开发者ID:Zipfer,项目名称:fuel-web,代码行数:33,代码来源:test_release_handler.py


示例2: test_network_verify_if_old_task_is_running

    def test_network_verify_if_old_task_is_running(self,
                                                   macs_mock):
        macs_mock.return_value = self.master_macs

        resp = self.app.get(
            reverse(
                'NovaNetworkConfigurationHandler',
                kwargs={'cluster_id': self.env.clusters[0].id}
            ),
            headers=self.default_headers
        )
        nets = resp.body

        self.env.create_task(
            name="verify_networks",
            status="running",
            cluster_id=self.env.clusters[0].id
        )

        resp = self.app.put(
            reverse(
                'NovaNetworkConfigurationVerifyHandler',
                kwargs={'cluster_id': self.env.clusters[0].id}),
            nets,
            headers=self.default_headers,
            expect_errors=True
        )
        self.assertEquals(400, resp.status)
开发者ID:rustyrobot,项目名称:fuel-web,代码行数:28,代码来源:test_verify_networks_task_manager.py


示例3: test_node_timestamp_updated_only_by_agent

    def test_node_timestamp_updated_only_by_agent(self):
        node = self.env.create_node(api=False)
        timestamp = node.timestamp
        resp = self.app.put(
            reverse('NodeCollectionHandler'),
            json.dumps([
                {'mac': node.mac, 'status': 'discover',
                 'manufacturer': 'old'}
            ]),
            headers=self.default_headers)
        self.assertEquals(resp.status, 200)
        node = self.db.query(Node).get(node.id)
        self.assertEquals(node.timestamp, timestamp)

        resp = self.app.put(
            reverse('NodeCollectionHandler'),
            json.dumps([
                {'mac': node.mac, 'status': 'discover',
                 'manufacturer': 'new', 'is_agent': True}
            ]),
            headers=self.default_headers)
        self.assertEquals(resp.status, 200)
        node = self.db.query(Node).get(node.id)
        self.assertNotEquals(node.timestamp, timestamp)
        self.assertEquals('new', node.manufacturer)
开发者ID:sirmax123,项目名称:fuel-web,代码行数:25,代码来源:test_node_collection_handlers.py


示例4: test_network_verify_if_old_task_is_running

    def test_network_verify_if_old_task_is_running(self):

        resp = self.app.get(
            reverse(
                'NovaNetworkConfigurationHandler',
                kwargs={'cluster_id': self.env.clusters[0].id}
            ),
            headers=self.default_headers
        )
        nets = resp.body

        self.env.create_task(
            name="verify_networks",
            status=consts.TASK_STATUSES.running,
            cluster_id=self.env.clusters[0].id
        )

        resp = self.app.put(
            reverse(
                'NovaNetworkConfigurationVerifyHandler',
                kwargs={'cluster_id': self.env.clusters[0].id}),
            nets,
            headers=self.default_headers,
            expect_errors=True
        )
        self.assertEqual(400, resp.status_code)
开发者ID:apporc,项目名称:fuel-web,代码行数:26,代码来源:test_verify_networks_task_manager.py


示例5: test_node_agent_api

    def test_node_agent_api(self):
        self.env.create_node(
            api=False,
            status='provisioning',
            meta=self.env.default_metadata()
        )
        node_db = self.env.nodes[0]
        resp = self.app.put(
            reverse('NodeAgentHandler'),
            jsonutils.dumps(
                {'mac': node_db.mac,
                 'status': 'discover', 'manufacturer': 'new'}
            ),
            headers=self.default_headers
        )
        self.assertEqual(resp.status_code, 200)

        node_id = '080000000003'
        resp = self.app.post(
            reverse('NodeCollectionHandler'),
            jsonutils.dumps({'id': node_id,
                            'mac': self.env.generate_random_mac(),
                            'status': 'discover'}),
            headers=self.default_headers)

        self.assertEqual(201, resp.status_code)
开发者ID:Axam,项目名称:nsx-web,代码行数:26,代码来源:test_public_api.py


示例6: test_roles_add_duplicated_to_db_directly

    def test_roles_add_duplicated_to_db_directly(self):
        self.env.create_release()
        resp = self.app.get(
            reverse('ReleaseCollectionHandler'),
            headers=self.default_headers
        )
        release_json = json.loads(resp.body)[0]
        old_roles = list(release_json["roles"])

        role = Role(name=old_roles[0],
                    release_id=release_json["id"])
        added = True
        try:
            db().add(role)
            db().commit()
        except IntegrityError:
            db.rollback()
            added = False
        self.assertFalse(added)

        resp = self.app.get(
            reverse('ReleaseCollectionHandler'),
            headers=self.default_headers
        )
        release_json = json.loads(resp.body)[0]
        new_roles = list(release_json["roles"])
        self.assertEqual(old_roles, new_roles)
开发者ID:e0ne,项目名称:fuel-web,代码行数:27,代码来源:test_roles.py


示例7: test_deletion_during_deployment

    def test_deletion_during_deployment(self):
        self.env.create(cluster_kwargs={}, nodes_kwargs=[{"status": "ready", "pending_addition": True}])
        cluster_id = self.env.clusters[0].id
        resp = self.app.put(
            reverse("ClusterChangesHandler", kwargs={"cluster_id": cluster_id}), headers=self.default_headers
        )
        deploy_uuid = json.loads(resp.body)["uuid"]
        resp = self.app.delete(
            reverse("ClusterHandler", kwargs={"cluster_id": cluster_id}), headers=self.default_headers
        )
        timeout = 120
        timer = time.time()
        while True:
            task_deploy = self.db.query(Task).filter_by(uuid=deploy_uuid).first()
            task_delete = self.db.query(Task).filter_by(cluster_id=cluster_id, name="cluster_deletion").first()
            if not task_delete:
                break
            self.db.expire(task_deploy)
            self.db.expire(task_delete)
            if (time.time() - timer) > timeout:
                break
            time.sleep(0.24)

        cluster_db = self.db.query(Cluster).get(cluster_id)
        self.assertIsNone(cluster_db)
开发者ID:newsky,项目名称:fuelweb,代码行数:25,代码来源:test_task_managers.py


示例8: test_NIC_adds_by_agent

    def test_NIC_adds_by_agent(self):
        meta = self.env.default_metadata()
        self.env.set_interfaces_in_meta(meta, [
            {'name': 'eth0', 'mac': '12345', 'current_speed': 1}])
        node = self.env.create_node(api=True, meta=meta)

        meta['interfaces'].append({'name': 'new_nic', 'mac': '643'})
        node_data = {'mac': node['mac'], 'is_agent': True,
                     'meta': meta}
        resp = self.app.put(
            reverse('NodeCollectionHandler'),
            json.dumps([node_data]),
            headers=self.default_headers)
        self.assertEquals(resp.status, 200)

        resp = self.app.get(
            reverse('NodeNICsHandler', kwargs={'node_id': node['id']}),
            headers=self.default_headers)
        self.assertEquals(resp.status, 200)
        response = json.loads(resp.body)
        self.assertEquals(len(response), len(meta['interfaces']))
        for nic in meta['interfaces']:
            filtered_nics = filter(
                lambda i: i['mac'] == nic['mac'],
                response
            )
            resp_nic = filtered_nics[0]
            self.assertEquals(resp_nic['mac'], nic['mac'])
            self.assertEquals(resp_nic['current_speed'],
                              nic.get('current_speed'))
            self.assertEquals(resp_nic['max_speed'], nic.get('max_speed'))
            for conn in ('assigned_networks', 'allowed_networks'):
                self.assertEquals(resp_nic[conn], [])
开发者ID:AlexeyKasatkin,项目名称:fuel-web,代码行数:33,代码来源:test_node_nic_handler.py


示例9: test_get_handler_with_invalid_data

 def test_get_handler_with_invalid_data(self):
     meta = self.env.default_metadata()
     meta["interfaces"] = []
     node = self.env.create_node(api=True, meta=meta)
     meta_list = [
         {'interfaces': None},
         {'interfaces': {}}
     ]
     for nic_meta in meta_list:
         meta = self.env.default_metadata()
         meta.update(nic_meta)
         node_data = {'mac': node['mac'], 'is_agent': True,
                      'meta': meta}
         resp = self.app.put(
             reverse('NodeCollectionHandler'),
             json.dumps([node_data]),
             expect_errors=True,
             headers=self.default_headers
         )
         self.assertEquals(resp.status, 400)
         resp = self.app.get(
             reverse('NodeNICsHandler', kwargs={'node_id': node['id']}),
             headers=self.default_headers
         )
         self.assertEquals(resp.status, 200)
         response = json.loads(resp.body)
         self.assertEquals(response, [])
开发者ID:AlexeyKasatkin,项目名称:fuel-web,代码行数:27,代码来源:test_node_nic_handler.py


示例10: test_partial_user_contacts_info

    def test_partial_user_contacts_info(self):
        resp = self.app.get(
            reverse("MasterNodeSettingsHandler"),
            headers=self.default_headers)
        self.assertEqual(200, resp.status_code)
        data = resp.json_body

        # emulate user enabled contact info sending to support team
        data["settings"]["statistics"]["user_choice_saved"]["value"] = True
        data["settings"]["statistics"]["send_user_info"]["value"] = \
            True
        name = "user"
        email = "[email protected]"
        data["settings"]["statistics"]["name"]["value"] = name
        data["settings"]["statistics"]["email"]["value"] = email
        resp = self.app.put(
            reverse("MasterNodeSettingsHandler"),
            headers=self.default_headers,
            params=jsonutils.dumps(data)
        )
        self.assertEqual(200, resp.status_code)
        self.assertDictEqual(
            InstallationInfo().get_installation_info()['user_information'],
            {
                'contact_info_provided': True,
                'name': name,
                'email': email,
                'company': ''
            }
        )
开发者ID:Zipfer,项目名称:fuel-web,代码行数:30,代码来源:test_master_node_settings_handler.py


示例11: test_NIC_updates_by_agent

    def test_NIC_updates_by_agent(self):
        meta = self.env.default_metadata()
        self.env.set_interfaces_in_meta(meta, [
            {'name': 'eth0', 'mac': '12345', 'current_speed': 1}])
        node = self.env.create_node(api=True, meta=meta)
        new_meta = self.env.default_metadata()
        self.env.set_interfaces_in_meta(new_meta, [
            {'name': 'new_nic', 'mac': '12345', 'current_speed': 10,
             'max_speed': 10}])
        node_data = {'mac': node['mac'], 'is_agent': True,
                     'meta': new_meta}
        resp = self.app.put(
            reverse('NodeCollectionHandler'),
            json.dumps([node_data]),
            headers=self.default_headers)
        self.assertEquals(resp.status, 200)

        resp = self.app.get(
            reverse('NodeNICsHandler', kwargs={'node_id': node['id']}),
            headers=self.default_headers)
        self.assertEquals(resp.status, 200)
        response = json.loads(resp.body)
        self.assertEquals(len(response), 1)
        resp_nic = response[0]
        nic = new_meta['interfaces'][0]
        self.assertEquals(resp_nic['mac'], nic['mac'])
        self.assertEquals(resp_nic['current_speed'], nic['current_speed'])
        self.assertEquals(resp_nic['max_speed'], nic['max_speed'])
        for conn in ('assigned_networks', 'allowed_networks'):
            self.assertEquals(resp_nic[conn], [])
开发者ID:AlexeyKasatkin,项目名称:fuel-web,代码行数:30,代码来源:test_node_nic_handler.py


示例12: test_stats_sending_enabled

    def test_stats_sending_enabled(self):
        self.assertEqual(StatsSender().must_send_stats(), False)

        resp = self.app.get(
            reverse("MasterNodeSettingsHandler"),
            headers=self.default_headers)
        self.assertEqual(200, resp.status_code)
        data = resp.json_body

        # emulate user confirmed settings in UI
        data["settings"]["statistics"]["user_choice_saved"]["value"] = True
        resp = self.app.put(
            reverse("MasterNodeSettingsHandler"),
            headers=self.default_headers,
            params=jsonutils.dumps(data)
        )
        self.assertEqual(200, resp.status_code)
        self.assertEqual(StatsSender().must_send_stats(), True)

        # emulate user disabled statistics sending
        data["settings"]["statistics"]["send_anonymous_statistic"]["value"] = \
            False
        resp = self.app.put(
            reverse("MasterNodeSettingsHandler"),
            headers=self.default_headers,
            params=jsonutils.dumps(data)
        )
        self.assertEqual(200, resp.status_code)
        self.assertEqual(StatsSender().must_send_stats(), False)
开发者ID:Zipfer,项目名称:fuel-web,代码行数:29,代码来源:test_master_node_settings_handler.py


示例13: check_info_handler

    def check_info_handler(self, handler_name, get_info):
        # updating provisioning info
        orchestrator_data = {"field": "test"}
        put_resp = self.app.put(
            reverse(handler_name,
                    kwargs={'cluster_id': self.cluster.id}),
            json.dumps(orchestrator_data),
            headers=self.default_headers)

        self.assertEquals(put_resp.status, 200)
        self.assertEquals(get_info(), orchestrator_data)

        # getting provisioning info
        get_resp = self.app.get(
            reverse(handler_name,
                    kwargs={'cluster_id': self.cluster.id}),
            headers=self.default_headers)

        self.assertEquals(get_resp.status, 200)
        self.datadiff(orchestrator_data, json.loads(get_resp.body))

        # deleting provisioning info
        delete_resp = self.app.delete(
            reverse(handler_name,
                    kwargs={'cluster_id': self.cluster.id}),
            headers=self.default_headers)

        self.assertEquals(delete_resp.status, 202)
        self.assertEqual(get_info(), {})
开发者ID:loles,项目名称:fuelweb,代码行数:29,代码来源:test_orchestrator_handlers.py


示例14: test_attributes_update

 def test_attributes_update(self):
     cluster_id = self.env.create_cluster(api=True)["id"]
     resp = self.app.get(
         reverse("ClusterAttributesHandler", kwargs={"cluster_id": cluster_id}), headers=self.default_headers
     )
     self.assertEquals(200, resp.status)
     resp = self.app.put(
         reverse("ClusterAttributesHandler", kwargs={"cluster_id": cluster_id}),
         params=json.dumps({"editable": {"foo": "bar"}}),
         headers=self.default_headers,
     )
     self.assertEquals(200, resp.status)
     attrs = self.db.query(Attributes).filter(Attributes.cluster_id == cluster_id).first()
     self.assertEquals("bar", attrs.editable["foo"])
     # 400 on generated update
     resp = self.app.put(
         reverse("ClusterAttributesHandler", kwargs={"cluster_id": cluster_id}),
         params=json.dumps({"generated": {"foo": "bar"}}),
         headers=self.default_headers,
         expect_errors=True,
     )
     self.assertEquals(400, resp.status)
     # 400 if editable is not dict
     resp = self.app.put(
         reverse("ClusterAttributesHandler", kwargs={"cluster_id": cluster_id}),
         params=json.dumps({"editable": ["foo", "bar"]}),
         headers=self.default_headers,
         expect_errors=True,
     )
     self.assertEquals(400, resp.status)
开发者ID:rustyrobot,项目名称:fuelweb,代码行数:30,代码来源:test_attributes.py


示例15: test_discovered_node_unified_name

    def test_discovered_node_unified_name(self):
        node_mac = self.env.generate_random_mac()

        def node_name_test(mac):
            self.env.create_node(
                api=True,
                **{'mac': mac}
            )

            node = json.loads(
                self.app.get(reverse('NodeCollectionHandler')).body
            )[0]
            self.assertEqual(node['name'],
                             'Untitled ({0})'.format(node_mac[-5:]))

        node_name_test(node_mac.upper())

        node_id = json.loads(
            self.app.get(reverse('NodeCollectionHandler')).body
        )[0]['id']

        self.app.delete(
            reverse('NodeHandler', {'obj_id': node_id})
        )

        node_name_test(node_mac.lower())
开发者ID:MsiRgb,项目名称:fuel-web,代码行数:26,代码来源:test_node_collection_handlers.py


示例16: test_deletion_during_deployment

    def test_deletion_during_deployment(self):
        self.env.create(
            cluster_kwargs={
                "name": u"Вася"
            },
            nodes_kwargs=[
                {"status": "ready", "pending_addition": True},
            ]
        )
        cluster_id = self.env.clusters[0].id
        self.app.put(
            reverse(
                'ClusterChangesHandler',
                kwargs={'cluster_id': cluster_id}),
            headers=self.default_headers
        )
        self.app.delete(
            reverse(
                'ClusterHandler',
                kwargs={'obj_id': cluster_id}),
            headers=self.default_headers
        )
        timeout = 10
        timer = time.time()
        while True:
            c = self.db.query(Cluster).get(cluster_id)
            if not c:
                break
            if (time.time() - timer) > timeout:
                raise Exception("Cluster deletion timeout")
            time.sleep(0.24)

        cluster_db = self.db.query(Cluster).get(cluster_id)
        self.assertIsNone(cluster_db)
开发者ID:Mellanox,项目名称:fuel-web,代码行数:34,代码来源:test_charset_issues.py


示例17: test_roles_failed_to_delete_assigned

    def test_roles_failed_to_delete_assigned(self):
        self.env.create(
            cluster_kwargs={},
            nodes_kwargs=[
                {"status": "ready", "roles": ["controller"]}
            ]
        )
        resp = self.app.get(
            reverse('ReleaseCollectionHandler'),
            headers=self.default_headers
        )

        release_json = json.loads(resp.body)[0]

        old_roles = set(release_json["roles"])
        old_roles.remove("controller")
        release_json["roles"] = list(old_roles)

        resp = self.app.put(
            reverse(
                'ReleaseHandler',
                kwargs={
                    "release_id": release_json["id"]
                }
            ),
            json.dumps(release_json),
            headers=self.default_headers,
            expect_errors=True
        )
        self.assertEqual(resp.status, 400)
        self.assertEqual(
            resp.body,
            "Cannot delete roles already assigned to nodes: controller"
        )
开发者ID:e0ne,项目名称:fuel-web,代码行数:34,代码来源:test_roles.py


示例18: test_attributes_update_patch

 def test_attributes_update_patch(self):
     cluster_id = self.env.create_cluster(api=True)['id']
     cluster_db = self.env.clusters[0]
     resp = self.app.get(
         reverse(
             'ClusterAttributesHandler',
             kwargs={'cluster_id': cluster_id}),
         headers=self.default_headers
     )
     self.assertEquals(200, resp.status_code)
     resp = self.app.patch(
         reverse(
             'ClusterAttributesHandler',
             kwargs={'cluster_id': cluster_id}),
         params=json.dumps({
             'editable': {
                 "foo": "bar"
             },
         }),
         headers=self.default_headers
     )
     self.assertEquals(200, resp.status_code)
     attrs = objects.Cluster.get_attributes(cluster_db)
     self.assertEquals("bar", attrs.editable["foo"])
     attrs.editable.pop('foo')
     self.assertNotEqual(attrs.editable, {})
开发者ID:Mellanox,项目名称:fuel-web,代码行数:26,代码来源:test_attributes.py


示例19: test_network_assignment_when_node_added

    def test_network_assignment_when_node_added(self):
        cluster = self.env.create_cluster(api=True)
        mac = self.env.generate_random_mac()
        meta = self.env.default_metadata()
        self.env.set_interfaces_in_meta(
            meta, [{"name": "eth0", "mac": mac}, {"name": "eth1", "mac": self.env.generate_random_mac()}]
        )
        node = self.env.create_node(api=True, meta=meta, mac=mac)
        resp = self.app.put(
            reverse("NodeCollectionHandler"),
            jsonutils.dumps([{"id": node["id"], "cluster_id": cluster["id"]}]),
            headers=self.default_headers,
        )
        self.assertEqual(resp.status_code, 200)

        resp = self.app.get(reverse("NodeNICsHandler", kwargs={"node_id": node["id"]}), headers=self.default_headers)
        self.assertEqual(resp.status_code, 200)
        response = jsonutils.loads(resp.body)
        for resp_nic in response:
            net_names = [net["name"] for net in resp_nic["assigned_networks"]]
            if resp_nic["mac"] == mac:
                self.assertTrue("fuelweb_admin" in net_names)
            else:
                self.assertTrue("public" in net_names)
            self.assertGreater(len(resp_nic["assigned_networks"]), 0)
开发者ID:koder-ua,项目名称:nailgun-fcert,代码行数:25,代码来源:test_node_nic_assignment.py


示例20: test_attributes_set_defaults

 def test_attributes_set_defaults(self):
     cluster = self.env.create_cluster(api=True)
     cluster_db = self.env.clusters[0]
     # Change editable attributes.
     resp = self.app.put(
         reverse(
             'ClusterAttributesHandler',
             kwargs={'cluster_id': cluster['id']}),
         params=json.dumps({
             'editable': {
                 "foo": "bar"
             },
         }),
         headers=self.default_headers,
         expect_errors=True
     )
     self.assertEquals(200, resp.status_code)
     attrs = objects.Cluster.get_attributes(cluster_db)
     self.assertEquals("bar", attrs.editable["foo"])
     # Set attributes to defaults.
     resp = self.app.put(
         reverse(
             'ClusterAttributesDefaultsHandler',
             kwargs={'cluster_id': cluster['id']}),
         headers=self.default_headers
     )
     self.assertEquals(200, resp.status_code)
     release = self.db.query(Release).get(
         cluster['release_id']
     )
     self.assertEquals(
         json.loads(resp.body)['editable'],
         release.attributes_metadata['editable']
     )
开发者ID:Mellanox,项目名称:fuel-web,代码行数:34,代码来源:test_attributes.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python utils.dict_merge函数代码示例发布时间:2022-05-27
下一篇:
Python base.reflect_db_metadata函数代码示例发布时间: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