本文整理汇总了Python中nailgun.db.sqlalchemy.models.Task.get方法的典型用法代码示例。如果您正苦于以下问题:Python Task.get方法的具体用法?Python Task.get怎么用?Python Task.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nailgun.db.sqlalchemy.models.Task
的用法示例。
在下文中一共展示了Task.get方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_verify_networks_resp_error_with_removed_node
# 需要导入模块: from nailgun.db.sqlalchemy.models import Task [as 别名]
# 或者: from nailgun.db.sqlalchemy.models.Task import get [as 别名]
def test_verify_networks_resp_error_with_removed_node(self):
self.env.create(cluster_kwargs={}, nodes_kwargs=[{"api": False}, {"api": False}])
cluster_db = self.env.clusters[0]
node1, node2 = self.env.nodes
nets_sent = [{"iface": "eth0", "vlans": range(100, 105)}]
nets_resp = [{"iface": "eth0", "vlans": range(100, 104)}]
task = Task(name="super", cluster_id=cluster_db.id)
task.cache = {"args": {"nodes": self.nodes_message((node1, node2), nets_sent), "offline": 0}}
self.db.add(task)
self.db.commit()
kwargs = {"task_uuid": task.uuid, "status": "ready", "nodes": self.nodes_message((node1, node2), nets_resp)}
self.db.delete(node2)
self.db.commit()
self.receiver.verify_networks_resp(**kwargs)
self.db.flush()
resp = self.app.get(reverse("TaskHandler", kwargs={"obj_id": task.id}), headers=self.default_headers)
self.assertEqual(resp.status_code, 200)
task = resp.json_body
self.assertEqual(task["status"], "error")
error_nodes = [
{
"uid": node1.id,
"interface": "eth0",
"name": node1.name,
"absent_vlans": [104],
"mac": node1.interfaces[0].mac,
},
{"uid": node2.id, "interface": "eth0", "name": node2.name, "absent_vlans": [104], "mac": "unknown"},
]
self.assertEqual(task.get("message"), "")
self.assertEqual(task["result"], error_nodes)
示例2: test_verify_networks_resp_error_with_removed_node
# 需要导入模块: from nailgun.db.sqlalchemy.models import Task [as 别名]
# 或者: from nailgun.db.sqlalchemy.models.Task import get [as 别名]
def test_verify_networks_resp_error_with_removed_node(self):
self.env.create(
cluster_kwargs={},
nodes_kwargs=[
{"api": False},
{"api": False}
]
)
cluster_db = self.env.clusters[0]
node1, node2 = self.env.nodes
nets_sent = [{'iface': 'eth0', 'vlans': range(100, 105)}]
nets_resp = [{'iface': 'eth0', 'vlans': range(100, 104)}]
task = Task(
name="super",
cluster_id=cluster_db.id
)
task.cache = {
"args": {
'nodes': self.nodes_message((node1, node2), nets_sent),
'offline': 0,
}
}
self.db.add(task)
self.db.commit()
kwargs = {'task_uuid': task.uuid,
'status': 'ready',
'nodes': self.nodes_message((node1, node2), nets_resp)}
self.db.delete(node2)
self.db.commit()
self.receiver.verify_networks_resp(**kwargs)
self.db.flush()
resp = self.app.get(
reverse('TaskHandler', kwargs={'obj_id': task.id}),
headers=self.default_headers
)
self.assertEqual(resp.status_code, 200)
task = resp.json_body
self.assertEqual(task['status'], "error")
error_nodes = [{'uid': node1.id,
'interface': 'eth0',
'name': node1.name,
'absent_vlans': [104],
'mac': node1.interfaces[0].mac},
{'uid': node2.id,
'interface': 'eth0',
'name': node2.name,
'absent_vlans': [104],
'mac': 'unknown'}]
self.assertEqual(task.get('message'), '')
self.assertEqual(task['result'], error_nodes)