How to use create_trunk method in tempest

Best Python code snippet using tempest_python

bodyfeature.py

Source:bodyfeature.py Github

copy

Full Screen

...47 def __init__(self, points, confi):48 self.points = np.array(points)49 self.c = confi50 self.standard = length(self.points[1]-self.points[8])51 def create_trunk(self, i, center):52 return trunk(self.points[i] - self.points[center], self.c[i], self.c[center],53 self.c[i] > 0.0 and self.c[center] > 0.0 and length(self.points[i] - self.points[center]) > self.standard * 0.1)54 @property55 def lleg_in(self):56 return self.create_trunk(12, 13)57 @property58 def lleg_out(self):59 return self.create_trunk(14, 13)60 @property61 def rleg_in(self):62 return self.create_trunk(9, 10)63 @property64 def body(self):65 return self.create_trunk(1, 8)66 @property67 def rleg_out(self):68 return self.create_trunk(11, 10)69 @property70 def larm_in(self):71 return self.create_trunk(5, 6)72 @property73 def larm_out(self):74 return self.create_trunk(7, 6)75 @property76 def rarm_in(self):77 return self.create_trunk(2, 3)78 @property79 def rarm_out(self):80 return self.create_trunk(4, 3)81 @property82 def head(self):83 return self.create_trunk(0, 1)84 @property85 def lshoulder(self):86 return self.create_trunk(5, 1)87 @property88 def rshoulder(self):89 return self.create_trunk(2, 1)90 def is_stand(self):91 """92 判断是否站立93 当前判断逻辑:分别判断左右腿,有一条满足则为站立94 每条腿判断逻辑:95 两条腿长度比例相差不超过20%,96 大腿和小腿夹角超过150°,97 每条腿和水平线的距离大于75°(近乎垂直)98 :return:99 """100 if self.is_lie():101 return False102 if self.lleg_in.useable and self.lleg_out.useable:103 x, y = self.lleg_in.vector, self.lleg_out.vector104 if abs(length(x) - length(y)) / length(x) < 0.2 and degree(x, y) > 150 and degree(x) > 75 and degree(105 y) > 75:106 return True107 if self.rleg_in.useable and self.rleg_out.useable:108 x, y = self.rleg_in.vector, self.rleg_out.vector109 if abs(length(x) - length(y)) / length(x) < 0.2 and degree(x, y) > 150 and degree(x) > 75 and degree(110 y) > 75:111 return True112 return False113 def _is_raise(self, x, y):114 if degree(y, np.array([0, -1])) < 45 and y[1] < 0:115 return True116 # if degree(x, y) < 45 and degree(y) > 60:117 # return True118 return False119 def is_raise(self):120 """121 判断是否举手122 当前判断逻辑:123 分左右手分别判断,有一只手为举起,则返回举手状态124 每只手判断逻辑:判断小臂对应向量(6->7和3->4)与竖直方向夹角是否小于45°,且y轴方向是否向上125 (由于手势没有办法判断的很细,所以第一张看手机也被认为是举手)126 :return:127 """128 if self.larm_in.useable and self.larm_out.useable:129 if self._is_raise(self.larm_in.vector, self.larm_out.vector):130 return True131 if self.rarm_in.useable and self.rarm_out.useable:132 if self._is_raise(self.rarm_in.vector, self.rarm_out.vector):133 return True134 return False135 def is_sit(self):136 """137 判断是否坐下138 当前判断逻辑:139 首先判断是否躺下,如果躺下则返回False140 如果没有躺下,则依次判断左右腿的状态。141 根据三角形两边之和大于第三边的原理,判断两腿的向量长度,以及脚踝到胯部的向量长度(11->9和14->12)142 (两条大腿向量为13->12和10->9,小腿向量为13->14和10->11)143 如果大腿和小腿长大于第三边向量长度的某个倍数,则为坐下144 (由于站直时候也是三角形,因此需要超过一定阈值,来确保弯曲程度)145 (用大腿和小腿夹角判断也可以,只是判断的时候用了三角形三边)146 两条腿有一条满足则为坐下的状态147 :return:148 """149 if self.is_lie():150 return False151 if self.lleg_in.useable and self.lleg_out.useable:152 x, y = self.lleg_in.vector, self.lleg_out.vector153 third = self.create_trunk(9, 11)154 if third.useable:155 if length(x) + length(y) > length(third.vector) * 1.20:156 return True157 if self.rleg_in.useable and self.rleg_out.useable:158 x, y = self.rleg_in.vector, self.rleg_out.vector159 third = self.create_trunk(9, 11)160 if third.useable:161 if length(x) + length(y) > length(third.vector) * 1.20:162 return True163 return False164 def is_lie(self):165 """166 判断是否躺下167 当前判断标准:判断身体躯干向量(8->1)与水平方向的夹角(小于90°的),如果夹角小于45°则为躺下168 :return:169 """170 if self.body.useable:171 x = self.body.vector172 dg = degree(x)173 if dg > 90:...

Full Screen

Full Screen

test_trunks_rbac.py

Source:test_trunks_rbac.py Github

copy

Full Screen

...28 def resource_setup(cls):29 super(TrunksExtRbacTest, cls).resource_setup()30 cls.network = cls.create_network()31 cls.port_id = cls.create_port(cls.network)["id"]32 def create_trunk(self, port_id):33 trunk = self.ntp_client.create_trunk(port_id, [])34 self.addCleanup(35 test_utils.call_and_ignore_notfound_exc,36 self.ntp_client.delete_trunk, trunk["trunk"]['id'])37 return trunk38 @decorators.idempotent_id('c02618e7-bb20-1a3a-83c8-6eec2af08130')39 @rbac_rule_validation.action(service="neutron",40 rules=["create_trunk"])41 def test_create_trunk(self):42 """Create trunk.43 RBAC test for the neutron "create_trunk" policy44 """45 with self.override_role():46 self.create_trunk(self.port_id)47 @decorators.idempotent_id('c02618e7-bb20-1a3a-83c8-6eec2af08131')48 @rbac_rule_validation.action(service="neutron",49 rules=["get_trunk"],50 expected_error_codes=[404])51 def test_show_trunk(self):52 """Show trunk.53 RBAC test for the neutron "get_trunk" policy54 """55 trunk = self.create_trunk(self.port_id)56 with self.override_role():57 self.ntp_client.show_trunk(trunk['trunk']['id'])58 @decorators.idempotent_id('c02618e7-bb20-1a3a-83c8-6eec2af08132')59 @rbac_rule_validation.action(service="neutron",60 rules=["get_trunk",61 "delete_trunk"],62 expected_error_codes=[404, 403])63 def test_delete_trunk(self):64 """Delete trunk.65 RBAC test for the neutron "delete_trunk" policy66 """67 trunk = self.create_trunk(self.port_id)68 with self.override_role():69 self.ntp_client.delete_trunk(trunk['trunk']['id'])70 @decorators.idempotent_id('047badd1-e4ff-40c5-9929-99ffcb8750a7')71 @rbac_rule_validation.action(service="neutron", rules=["get_trunk"])72 def test_list_trunks(self):73 """Show trunk.74 RBAC test for the neutron ``list_trunks``` function and75 the ``get_trunk`` policy76 """77 admin_resource_id = self.create_trunk(self.port_id)["trunk"]['id']78 with (self.override_role_and_validate_list(79 admin_resource_id=admin_resource_id)) as ctx:80 ctx.resources = self.ntp_client.list_trunks(81 id=admin_resource_id)["trunks"]82class TrunksSubportsExtRbacTest(base.BaseNetworkExtRbacTest):83 @classmethod84 def skip_checks(cls):85 super(TrunksSubportsExtRbacTest, cls).skip_checks()86 if not utils.is_extension_enabled('trunk', 'network'):87 msg = "trunk extension not enabled."88 raise cls.skipException(msg)89 @classmethod90 def resource_setup(cls):91 super(TrunksSubportsExtRbacTest, cls).resource_setup()92 cls.network = cls.create_network()93 cls.port_id = cls.create_port(cls.network)["id"]94 cls.trunk_id = cls.ntp_client.create_trunk(95 cls.port_id, [])['trunk']['id']96 cls.addClassResourceCleanup(97 test_utils.call_and_ignore_notfound_exc,98 cls.ntp_client.delete_trunk, cls.trunk_id)99 def create_subports(self, trunk_id, port_id):100 subports = [{'port_id': port_id,101 'segmentation_type': 'vlan',102 'segmentation_id': 4000}]103 sub = self.ntp_client.add_subports(trunk_id, subports)104 self.addCleanup(105 test_utils.call_and_ignore_notfound_exc,106 self.ntp_client.remove_subports,107 trunk_id, subports)108 return sub["sub_ports"]...

Full Screen

Full Screen

trunk.py

Source:trunk.py Github

copy

Full Screen

...134 return self.get(config.NEUTRON_TRUNKS + '/' + trunkid)135 def get_trunks(self):136 logging.info('get all trunks')137 return self.get(config.NEUTRON_TRUNKS)138 def create_trunk(self, payload):139 if 'trunk' in payload:140 logging.info('create trunk: ' + payload['trunk']['id'])141 else:142 logging.info('bulk create trunks: ' + ', '.join([trunk['id'] for trunk in payload['trunks']]))143 return self.post(config.NEUTRON_TRUNKS, payload)144 def update_trunk(self, trunkid, payload):145 logging.info('update trunk: ' + trunkid)146 return self.put(config.NEUTRON_TRUNKS + '/' + trunkid, payload)147 def delete_trunk(self, trunkid):148 logging.info('delete trunk: ' + trunkid)149 return self.delete(config.NEUTRON_TRUNKS + '/' + trunkid)150 @staticmethod151 def perform_tests(servername, username, count=0):152 logging.info('perform trunk tests, server: %s, user: %s' % (servername, username))153 tester = Trunk(servername, username)154 utils.assert_status(tester.get_trunks(), 200)155 trunk_one = tester.create_trunk(change_id(TRUNK_ONE, count))156 utils.assert_status(trunk_one, 201)157 if trunk_one.status_code == 201:158 trunk_one_id = json.loads(trunk_one.text)['trunk']['id']159 utils.assert_status(tester.get_trunk(trunk_one_id), 200)160 utils.assert_status(tester.create_trunk(change_id(TRUNK_DEFAULT, count)), 201)161 utils.assert_status(tester.update_trunk(change_id(TRUNK_UPDATE['trunk'], count)['trunk']['id'],162 change_id(TRUNK_UPDATE['trunk'], count)), 201)163 if count == 0:164 utils.assert_status(tester.create_trunk(TRUNKS_BULK), 201)165 utils.assert_status(tester.delete_trunk(TRUNKS_BULK['trunks'][0]['id']), 204)166 utils.assert_status(tester.get_trunk(TRUNKS_BULK['trunks'][0]['id']), 404)167 trunks = tester.get_trunks()168 for trunk in json.loads(trunks.text)['trunks']:169 utils.assert_status(tester.delete_trunk(trunk['id']), 204)170if __name__ == '__main__':...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful