How to use update_all_tags method in tempest

Best Python code snippet using tempest_python

ROI_move_shape.py

Source:ROI_move_shape.py Github

copy

Full Screen

1import numpy as np2import re3def update_all_tags(closest_roi):4 if closest_roi['Shape_type'] == 'Rectangle':5 closest_roi['Tags']['Center tag'] = (int(closest_roi['topLeftX'] + closest_roi['width'] / 2), int(closest_roi['topLeftY'] + closest_roi['height'] / 2))6 closest_roi['Tags']['Top left tag'] = (int(closest_roi['topLeftX']), int(closest_roi['topLeftY']))7 closest_roi['Tags']['Bottom right tag'] = (int(closest_roi['topLeftX'] + closest_roi['width']), int(closest_roi['topLeftY'] + closest_roi['height']))8 closest_roi['Tags']['Top right tag'] = (int(closest_roi['topLeftX'] + closest_roi['width']), int(closest_roi['topLeftY']))9 closest_roi['Tags']['Bottom left tag'] = (int(closest_roi['topLeftX']), int(closest_roi['topLeftY'] + closest_roi['height']))10 closest_roi['Tags']['Top tag'] = (int(closest_roi['topLeftX'] + closest_roi['width'] / 2), int(closest_roi['topLeftY']))11 closest_roi['Tags']['Right tag'] = (int(closest_roi['topLeftX'] + closest_roi['width']), int(closest_roi['topLeftY'] + closest_roi['height'] / 2))12 closest_roi['Tags']['Left tag'] = (int(closest_roi['topLeftX']), int(closest_roi['topLeftY'] + closest_roi['height'] / 2))13 closest_roi['Tags']['Bottom tag'] = (int(closest_roi['topLeftX'] + closest_roi['width'] / 2), int(closest_roi['topLeftY'] + closest_roi['height']))14 elif closest_roi['Shape_type'] == 'Circle':15 closest_roi['Tags']['Center tag'] = (closest_roi['centerX'], closest_roi['centerY'])16 closest_roi['Tags']['Border tag'] = (int(closest_roi['centerX'] - closest_roi['radius']), closest_roi['centerY'])17 else:18 pass19 return closest_roi20def move_edge(closest_roi, closest_tag, new_click_loc):21 def rectangle_integrity_check(closest_roi):22 if closest_roi['topLeftX'] > closest_roi['Bottom_right_X']:23 top_left_x, bottom_right_x = closest_roi['topLeftX'], closest_roi['Bottom_right_X']24 closest_roi['topLeftX'] = bottom_right_x25 closest_roi['Bottom_right_X'] = top_left_x26 closest_roi['width'] = closest_roi['Bottom_right_X'] - closest_roi['topLeftX']27 closest_roi['height'] = closest_roi['Bottom_right_Y'] - closest_roi['topLeftY']28 if closest_roi['topLeftY'] > closest_roi['Bottom_right_Y']:29 top_left_y, bottom_right_y = closest_roi['topLeftY'], closest_roi['Bottom_right_Y']30 closest_roi['topLeftY'] = bottom_right_y31 closest_roi['Bottom_right_Y'] = top_left_y32 closest_roi['width'] = closest_roi['Bottom_right_X'] - closest_roi['topLeftX']33 closest_roi['height'] = closest_roi['Bottom_right_Y'] - closest_roi['topLeftY']34 return closest_roi35 if closest_roi['Shape_type'] == 'Polygon':36 if closest_tag == 'Center_tag':37 delta_x, delta_y = closest_roi['Center_X'] - new_click_loc[0], closest_roi['Center_Y'] - new_click_loc[1]38 closest_roi['Center_X'], closest_roi['Center_Y'] = new_click_loc[0], new_click_loc[1]39 new_array = np.zeros((0))40 for v in closest_roi['vertices']:41 new_x = v[0] - delta_x42 new_y = v[1] - delta_y43 new_array = np.concatenate((new_array, np.array([new_x, new_y])), axis=0).astype('int32')44 closest_roi['vertices'] = np.reshape(new_array, (-1, 2))45 polygon_pts_dict = {}46 for v, p in enumerate(closest_roi['vertices']):47 polygon_pts_dict['Tag_' + str(v)] = (p[0], p[1])48 polygon_pts_dict['Center_tag'] = (closest_roi['Center_X'], int(closest_roi['Center_Y']))49 closest_roi['Tags'] = polygon_pts_dict50 else:51 tag_ix = int(re.sub("[^0-9]", "", closest_tag))52 closest_roi['vertices'][tag_ix] = new_click_loc53 closest_roi['Tags'][closest_tag] = new_click_loc54 poly_center = closest_roi['vertices'].mean(axis=0)55 closest_roi['Tags']['Center_tag'] = (int(poly_center[0]), int(poly_center[1]))56 closest_roi['Center_X'], closest_roi['Center_Y'] = int(poly_center[0]), int(poly_center[1])57 elif closest_roi['Shape_type'] == 'Rectangle':58 if closest_tag == "Right tag":59 closest_roi['Bottom_right_X'] = new_click_loc[0]60 closest_roi['width'] = closest_roi['Bottom_right_X'] - closest_roi['topLeftX']61 if closest_tag == "Left tag":62 closest_roi['topLeftX'] = new_click_loc[0]63 closest_roi['width'] = closest_roi['Bottom_right_X'] - closest_roi['topLeftX']64 if closest_tag == "Top tag":65 closest_roi['topLeftY'] = new_click_loc[1]66 closest_roi['height'] = closest_roi['Bottom_right_Y'] - closest_roi['topLeftY']67 if closest_tag == "Bottom tag":68 closest_roi['Bottom_right_Y'] = new_click_loc[1]69 closest_roi['height'] = closest_roi['Bottom_right_Y'] - closest_roi['topLeftY']70 if closest_tag == "Top left tag":71 closest_roi['topLeftX'], closest_roi['topLeftY'] = new_click_loc[0], new_click_loc[1]72 closest_roi['width'] = closest_roi['Bottom_right_X'] - closest_roi['topLeftX']73 closest_roi['height'] = closest_roi['Bottom_right_Y'] - closest_roi['topLeftY']74 if closest_tag == "Top right tag":75 closest_roi['Bottom_right_X'], closest_roi['topLeftY'] = new_click_loc[0], new_click_loc[1]76 closest_roi['width'] = closest_roi['Bottom_right_X'] - closest_roi['topLeftX']77 closest_roi['height'] = closest_roi['Bottom_right_Y'] - closest_roi['topLeftY']78 if closest_tag == "Bottom left tag":79 closest_roi['topLeftX'], closest_roi['Bottom_right_Y'] = new_click_loc[0], new_click_loc[1]80 closest_roi['width'] = closest_roi['Bottom_right_X'] - closest_roi['topLeftX']81 closest_roi['height'] = closest_roi['Bottom_right_Y'] - closest_roi['topLeftY']82 if closest_tag == "Bottom right tag":83 closest_roi['Bottom_right_X'], closest_roi['Bottom_right_Y'] = new_click_loc[0], new_click_loc[1]84 closest_roi['width'] = closest_roi['Bottom_right_X'] - closest_roi['topLeftX']85 closest_roi['height'] = closest_roi['Bottom_right_Y'] - closest_roi['topLeftY']86 if closest_tag == 'Center tag':87 delta_x, delta_y = closest_roi['Tags']['Center tag'][0] - new_click_loc[0], closest_roi['Tags']['Center tag'][1] - new_click_loc[1]88 closest_roi['topLeftX'] = closest_roi['topLeftX'] - delta_x89 closest_roi['topLeftY'] = closest_roi['topLeftY'] - delta_y90 closest_roi['Bottom_right_X'] = closest_roi['topLeftX'] + closest_roi['width']91 closest_roi['Bottom_right_Y'] = closest_roi['topLeftY'] + closest_roi['height']92 closest_roi = rectangle_integrity_check(closest_roi)93 update_all_tags(closest_roi)94 elif closest_roi['Shape_type'] == 'Circle':95 if closest_tag == "Center tag":96 closest_roi['centerX'], closest_roi['centerY'] = new_click_loc[0], new_click_loc[1]97 if closest_tag == "Border tag":98 closest_roi['radius'] = int((np.sqrt((closest_roi['centerX'] - new_click_loc[0]) ** 2 + (closest_roi['centerY'] - new_click_loc[1]) ** 2)))99 update_all_tags(closest_roi)100def move_edge_align(move_roi, move_tag, target_roi, target_tag):101 move_cord = target_roi['Tags'][target_tag]102 if move_roi['Shape_type'] == 'Rectangle':103 if move_tag == 'Top left tag':104 move_roi['topLeftX'] = move_cord[0]105 move_roi['topLeftY'] = move_cord[1]106 if move_tag == 'Top tag':107 move_roi['topLeftX'] = move_cord[0] - int(move_roi['width'] / 2)108 move_roi['topLeftY'] = move_cord[1]109 if move_tag == 'Top right tag':110 move_roi['topLeftX'] = move_cord[0] - move_roi['width']111 move_roi['topLeftY'] = move_cord[1]112 if move_tag == 'Left tag':113 move_roi['topLeftX'] = move_cord[0]114 move_roi['topLeftY'] = move_cord[1] - int(move_roi['height'] / 2)115 if move_tag == 'Bottom left tag':116 move_roi['topLeftX'] = move_cord[0]117 move_roi['topLeftY'] = move_cord[1] - int(move_roi['height'])118 if move_tag == 'Bottom tag':119 move_roi['topLeftX'] = move_cord[0] - int(move_roi['width'] / 2)120 move_roi['topLeftY'] = move_cord[1] - int(move_roi['height'])121 if move_tag == 'Bottom right tag':122 move_roi['topLeftX'] = move_cord[0] - int(move_roi['width'])123 move_roi['topLeftY'] = move_cord[1] - int(move_roi['height'])124 if move_tag == 'Right tag':125 move_roi['topLeftX'] = move_cord[0] - int(move_roi['width'])126 move_roi['topLeftY'] = move_cord[1] - int(move_roi['height'] / 2)127 if move_tag == 'Center tag':128 move_roi['topLeftX'] = move_cord[0] - int(move_roi['width'] / 2)129 move_roi['topLeftY'] = move_cord[1] - int(move_roi['height'] / 2)130 move_roi['Bottom_right_X'] = move_roi['topLeftX'] + move_roi['width']131 move_roi['Bottom_right_Y'] = move_roi['topLeftY'] + move_roi['height']132 update_all_tags(move_roi)133 if move_roi['Shape_type'] == 'Polygon':134 move_roi['Tags'][move_tag] = (move_cord[0], move_cord[1])135 new_array = np.zeros((0))136 for tag in list(move_roi['Tags'].keys())[:-1]:137 new_x = move_roi['Tags'][tag][0]138 new_y = move_roi['Tags'][tag][1]139 new_array = np.concatenate((new_array, np.array([new_x, new_y])), axis=0).astype('int32')140 move_roi['vertices'] = np.reshape(new_array, (-1, 2))141 poly_center = move_roi['vertices'].mean(axis=0)142 move_roi['Center_X'], move_roi['Center_Y'] = int(poly_center[0]), int(poly_center[1])143 if move_roi['Shape_type'] == 'Circle':144 if move_tag == 'Center tag':145 move_roi['centerX'], move_roi['centerY'] = move_cord[0], move_cord[1]146 if move_tag == 'Border tag':147 move_roi['centerX'], move_roi['centerY'] = int(move_cord[0] + move_roi['radius']), move_cord[1]...

Full Screen

Full Screen

test_transform.py

Source:test_transform.py Github

copy

Full Screen

...139 },140 }141 for i in p2m_connections142 ]143 update_all_tags(all_agents, connections)144 assert transform.transform_connections(all_agents, connections, "P2M") == {145 "auto gen 1": {146 "type": "endpoint",147 "id": 1,148 "state": "present",149 "services": [],150 "connect_to": {151 "test": {152 "state": "present",153 "type": "tag",154 "services": [],155 },156 },157 },158 }159def test_transform_connections__p2m_tagged_multiple(all_agents, p2m_connections):160 connections = [161 {162 **i,163 "agent_2": {164 **i["agent_2"],165 "agent_tags": [166 {"agent_tag_name": "test"},167 {"agent_tag_name": "TEST"},168 ],169 },170 }171 for i in p2m_connections172 ]173 update_all_tags(all_agents, connections)174 assert transform.transform_connections(all_agents, connections, "P2M") == {175 "auto gen 1": {176 "type": "endpoint",177 "id": 1,178 "state": "present",179 "services": [],180 "connect_to": {181 "test": {182 "state": "present",183 "type": "tag",184 "services": [],185 },186 "TEST": {187 "state": "present",188 "type": "tag",189 "services": [],190 },191 },192 },193 }194def test_transform_connections__mesh(all_agents, mesh_connections):195 assert transform.transform_connections(all_agents, mesh_connections, "MESH") == {196 "auto gen 10": {197 "type": "endpoint",198 "state": "present",199 "services": [],200 "id": 10,201 },202 "auto gen 11": {203 "type": "endpoint",204 "state": "present",205 "services": [],206 "id": 11,207 },208 "auto gen 12": {209 "type": "endpoint",210 "state": "present",211 "services": [],212 "id": 12,213 },214 "auto gen 13": {215 "type": "endpoint",216 "state": "present",217 "services": [],218 "id": 13,219 },220 }221def test_transform_connections__mesh_tagged_multiple(all_agents, mesh_connections):222 connections = [223 {224 **i,225 "agent_1": {226 **i["agent_1"],227 "agent_tags": [228 {"agent_tag_name": "test"},229 {"agent_tag_name": "TEST"},230 ],231 },232 "agent_2": {233 **i["agent_2"],234 "agent_tags": [235 {"agent_tag_name": "test"},236 {"agent_tag_name": "TEST"},237 ],238 },239 }240 for i in mesh_connections241 ]242 update_all_tags(all_agents, connections)243 assert transform.transform_connections(all_agents, connections, "MESH") == {244 "test": {245 "type": "tag",246 "state": "present",247 "services": [],248 },249 "TEST": {250 "type": "tag",251 "state": "present",252 "services": [],253 },254 }255def test_group_agents_by_tags():256 agents = {...

Full Screen

Full Screen

main.py

Source:main.py Github

copy

Full Screen

1from tags_api import TagsAPI2api = TagsAPI('problems.json', 'tags.json')...

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