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


Python utils.reverse函数代码示例

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


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

示例1: test_roles_failed_to_delete_assigned

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

        release_json = resp.json_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={
                    "obj_id": release_json["id"]
                }
            ),
            jsonutils.dumps(release_json),
            headers=self.default_headers,
            expect_errors=True
        )
        self.assertEqual(resp.status_code, 400)
        self.assertEqual(
            resp.json_body["message"],
            "Cannot delete roles already assigned to nodes: controller"
        )
开发者ID:blkart,项目名称:fuel-web,代码行数:33,代码来源:test_roles.py

示例2: 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=jsonutils.dumps({
             'editable': {
                 "foo": "bar"
             },
         }),
         headers=self.default_headers,
         expect_errors=True
     )
     self.assertEqual(200, resp.status_code, resp.body)
     attrs = objects.Cluster.get_attributes(cluster_db)
     self.assertEqual("bar", attrs.editable["foo"])
     # Set attributes to defaults.
     resp = self.app.put(
         reverse(
             'ClusterAttributesDefaultsHandler',
             kwargs={'cluster_id': cluster['id']}),
         headers=self.default_headers
     )
     self.assertEqual(200, resp.status_code)
     release = self.db.query(Release).get(
         cluster['release_id']
     )
     self._compare_editable(
         release.attributes_metadata['editable'],
         resp.json_body['editable'],
         cluster_db
     )
开发者ID:thomasgoirand,项目名称:fuel-nailgun,代码行数:35,代码来源:test_attributes.py

示例3: test_network_changing_adds_pending_changes

 def test_network_changing_adds_pending_changes(self):
     cluster = self.env.create_cluster(api=True)
     cluster_db = self.env.clusters[0]
     objects.Cluster.clear_pending_changes(cluster_db)
     all_changes = self.db.query(ClusterChanges).all()
     self.assertEqual(len(all_changes), 0)
     resp = self.app.get(
         reverse(
             'NovaNetworkConfigurationHandler',
             kwargs={'cluster_id': cluster['id']}),
         headers=self.default_headers
     )
     net_id = resp.json_body['networks'][0]["id"]
     resp = self.app.put(
         reverse(
             'NovaNetworkConfigurationHandler',
             kwargs={'cluster_id': cluster['id']}),
         jsonutils.dumps({'networks': [{
             "id": net_id, "gateway": "10.0.0.1"}
         ]}),
         headers=self.default_headers
     )
     pending_changes = self.db.query(ClusterChanges).filter_by(
         name="networks"
     ).all()
     self.assertEqual(len(pending_changes), 1)
开发者ID:SergK,项目名称:fuel-web,代码行数:26,代码来源:test_changes_model.py

示例4: test_network_assignment_when_node_added

    def test_network_assignment_when_node_added(self):
        cluster = self.env.create_cluster(
            api=True,
            editable_attributes={'public_network_assignment': {
                'assign_to_all_nodes': {'value': 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 = resp.json_body
        for resp_nic in response:
            net_names = [net['name'] for net in resp_nic['assigned_networks']]
            if resp_nic['mac'] == mac:
                self.assertIn("fuelweb_admin", net_names)
            else:
                self.assertIn("public", net_names)
            self.assertGreater(len(resp_nic['assigned_networks']), 0)
开发者ID:openstack,项目名称:fuel-web,代码行数:31,代码来源:test_node_nic_assignment.py

示例5: test_failing_attributes_put

 def test_failing_attributes_put(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.assertEqual(200, resp.status_code)
     resp = self.app.patch(
         reverse(
             'ClusterAttributesHandler',
             kwargs={'cluster_id': cluster_id}),
         params=jsonutils.dumps({
             'editable': {
                 'storage': {
                     'osd_pool_size': {
                         'description': 'desc',
                         'label': 'OSD Pool Size',
                         'type': 'text',
                         'value': True,
                         'weight': 80,
                     },
                 },
             },
         }),
         headers=self.default_headers,
         expect_errors=True
     )
     self.assertEqual(400, resp.status_code)
开发者ID:thomasgoirand,项目名称:fuel-nailgun,代码行数:30,代码来源:test_attributes.py

示例6: 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': '00:00:00:00:00:00', 'current_speed': 1,
             'pxe': True, 'state': 'up'}])
        node = self.env.create_node(api=True, meta=meta)

        meta['interfaces'].append({
            'name': 'new_nic', 'mac': '00:00:00:00:00:01'})
        node_data = {'mac': node['mac'], 'meta': meta}
        resp = self.app.put(
            reverse('NodeAgentHandler'),
            jsonutils.dumps(node_data),
            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)
        self.assertEqual(len(resp.json_body), len(meta['interfaces']))
        for nic in meta['interfaces']:
            filtered_nics = filter(
                lambda i: i['mac'] == nic['mac'],
                resp.json_body
            )
            resp_nic = filtered_nics[0]
            self.assertEqual(resp_nic['mac'], nic['mac'])
            self.assertEqual(resp_nic['current_speed'],
                             nic.get('current_speed'))
            self.assertEqual(resp_nic['max_speed'], nic.get('max_speed'))
            self.assertEqual(resp_nic['state'], nic.get('state'))
            for conn in ('assigned_networks', ):
                self.assertEqual(resp_nic[conn], [])
开发者ID:SmartInfrastructures,项目名称:fuel-web-dev,代码行数:34,代码来源:test_node_nic_handler.py

示例7: test_openstack_config_upload_override_multinode

    def test_openstack_config_upload_override_multinode(self):
        data = {
            'cluster_id': self.clusters[0].id,
            'node_ids': [self.nodes[1].id, self.nodes[2].id],
            'configuration': {
                'nova_config': 'overridden_value'
            }
        }
        resp = self.app.post(
            reverse('OpenstackConfigCollectionHandler'),
            jsonutils.dumps(data),
            headers=self.default_headers)

        self.assertEqual(resp.status_code, 201)
        configs = resp.json_body
        self.assertEqual(configs[0]['node_id'], self.nodes[1].id)
        self.assertEqual(configs[1]['node_id'], self.nodes[2].id)

        resp = self.app.get(
            reverse('OpenstackConfigHandler',
                    {'obj_id': self.configs[1].id}),
            headers=self.default_headers)
        self.assertEqual(resp.status_code, 200)
        self.assertEqual(resp.json_body['is_active'], False)

        resp = self.app.get(
            reverse('OpenstackConfigHandler',
                    {'obj_id': self.configs[2].id}),
            headers=self.default_headers)
        self.assertEqual(resp.status_code, 200)
        self.assertEqual(resp.json_body['is_active'], False)
开发者ID:ekorekin,项目名称:fuel-web,代码行数:31,代码来源:test_openstack_config_handler.py

示例8: test_network_assignment_when_node_added

    def test_network_assignment_when_node_added(self):
        cluster = self.env.create_cluster(
            api=True, editable_attributes={"public_network_assignment": {"assign_to_all_nodes": {"value": 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 = resp.json_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:mmalchuk,项目名称:openstack-fuel-web,代码行数:27,代码来源:test_node_nic_assignment.py

示例9: launch_verify_networks

    def launch_verify_networks(self, data=None):
        if self.clusters:
            net_urls = {
                "nova_network": {
                    "config": "NovaNetworkConfigurationHandler",
                    "verify": "NovaNetworkConfigurationVerifyHandler",
                },
                "neutron": {
                    "config": "NeutronNetworkConfigurationHandler",
                    "verify": "NeutronNetworkConfigurationVerifyHandler",
                },
            }
            provider = self.clusters[0].net_provider
            if data:
                nets = jsonutils.dumps(data)
            else:
                resp = self.app.get(
                    reverse(net_urls[provider]["config"], kwargs={"cluster_id": self.clusters[0].id}),
                    headers=self.default_headers,
                )
                self.tester.assertEqual(200, resp.status_code)
                nets = resp.body

            resp = self.app.put(
                reverse(net_urls[provider]["verify"], kwargs={"cluster_id": self.clusters[0].id}),
                nets,
                headers=self.default_headers,
            )
            task_uuid = resp.json_body["uuid"]
            return self.db.query(Task).filter_by(uuid=task_uuid).first()
        else:
            raise NotImplementedError("Nothing to verify - try creating cluster")
开发者ID:thefuyang,项目名称:fuel-web,代码行数:32,代码来源:base.py

示例10: test_log_entry_collection_handler

    def test_log_entry_collection_handler(self):
        node_ip = "10.20.30.40"
        log_entries = [
            [time.strftime(settings.UI_LOG_DATE_FORMAT), "LEVEL111", "text1"],
            [time.strftime(settings.UI_LOG_DATE_FORMAT), "LEVEL222", "text2"],
        ]
        self.env.create_cluster()
        cluster = self.env.clusters[0]
        node = self.env.create_node(cluster_id=cluster.id, ip=node_ip)
        self._create_logfile_for_node(settings.LOGS[0], log_entries)
        self._create_logfile_for_node(settings.LOGS[1], log_entries, node)

        resp = self.app.get(
            reverse("LogEntryCollectionHandler"),
            params={"source": settings.LOGS[0]["id"]},
            headers=self.default_headers,
        )
        self.assertEqual(200, resp.status_code)
        response = resp.json_body
        response["entries"].reverse()
        self.assertEqual(response["entries"], log_entries)

        resp = self.app.get(
            reverse("LogEntryCollectionHandler"),
            params={"node": node.id, "source": settings.LOGS[1]["id"]},
            headers=self.default_headers,
        )
        self.assertEqual(200, resp.status_code)
        response = resp.json_body
        response["entries"].reverse()
        self.assertEqual(response["entries"], log_entries)
开发者ID:naveenzhang,项目名称:fuel-web,代码行数:31,代码来源:test_logs_handlers.py

示例11: test_cluster_node_list_update

    def test_cluster_node_list_update(self):
        node1 = self.env.create_node(api=False, hostname='name1')
        cluster = self.env.create_cluster(api=False)
        resp = self.app.put(
            reverse('ClusterHandler', kwargs={'obj_id': cluster.id}),
            jsonutils.dumps({'nodes': [node1.id]}),
            headers=self.default_headers,
            expect_errors=True
        )
        self.assertEqual(resp.status_code, 200)
        node2 = self.env.create_node(api=False, hostname='name1')

        nodes = self.db.query(Node).filter(Node.cluster == cluster).all()
        self.assertEqual(1, len(nodes))
        self.assertEqual(nodes[0].id, node1.id)

        resp = self.app.put(
            reverse('ClusterHandler', kwargs={'obj_id': cluster.id}),
            jsonutils.dumps({'nodes': [node2.id]}),
            headers=self.default_headers
        )
        self.assertEqual(resp.status_code, 200)

        self.assertEqual('node-{0}'.format(node1.id), node1.hostname)

        nodes = self.db.query(Node).filter(Node.cluster == cluster)
        self.assertEqual(1, nodes.count())
开发者ID:sebrandon1,项目名称:fuel-web,代码行数:27,代码来源:test_cluster_handler.py

示例12: 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:dnikishov,项目名称:fuel-web,代码行数:30,代码来源:test_master_node_settings_handler.py

示例13: test_get_notification_status

    def test_get_notification_status(self):
        resp = self.app.get(
            reverse(
                'NotificationCollectionStatsHandler',
            ),
            headers=self.default_headers
        )
        self.assertEqual({'total': 0, 'read': 0, 'unread': 0}, resp.json_body)
        self.assertEqual(200, resp.status_code)

        self.env.create_notification()
        resp = self.app.get(
            reverse(
                'NotificationCollectionStatsHandler',
            ),
            headers=self.default_headers
        )
        self.assertEqual({'total': 1, 'read': 0, 'unread': 1}, resp.json_body)

        self.env.create_notification(status='read')
        self.env.create_notification(status='read')
        resp = self.app.get(
            reverse(
                'NotificationCollectionStatsHandler',
            ),
            headers=self.default_headers
        )
        self.assertEqual({'total': 3, 'read': 2, 'unread': 1}, resp.json_body)
开发者ID:openstack,项目名称:fuel-web,代码行数:28,代码来源:test_notification_handler.py

示例14: 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 = resp.json_body[0]
        old_roles = list(release_json["roles"])

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

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

示例15: 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:
            cluster = self.db.query(Cluster).filter_by(id=cluster_id).first()
            if not cluster:
                break
            if (time.time() - timer) > timeout:
                raise Exception("Cluster deletion timeout")
            time.sleep(0.24)

        self.assertIsNone(cluster)
开发者ID:MoArif,项目名称:fuel-web,代码行数:33,代码来源:test_charset_issues.py


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