本文整理汇总了Python中nailgun.test.base.reverse函数的典型用法代码示例。如果您正苦于以下问题:Python reverse函数的具体用法?Python reverse怎么用?Python reverse使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了reverse函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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/')
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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], [])
示例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, [])
示例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': ''
}
)
示例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], [])
示例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)
示例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(), {})
示例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)
示例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())