How to use check_exists method in autotest

Best Python code snippet using autotest_python

dataplatform.py

Source:dataplatform.py Github

copy

Full Screen

...15 if not os.path.exists(self.templates_dataplatform_setup):16 raise NotFoundException(self.templates_dataplatform_setup)17 self.load_yaml_dict()18 def load_yaml_dict(self):19 file_name = self.check_exists(self.system_dataplatform, "system-sa-dataplatform.yaml")20 system_sa_dataplatform_yaml_file = YamlFile("system-sa-dataplatform", "Data Platform Operator Service Account",21 file_name, "system_dataplatform_components")22 self.yamls.append(system_sa_dataplatform_yaml_file)23 file_name = self.check_exists(self.system_dataplatform, "system-cr-dataplatform.yaml")24 system_cr_dataplatform_yaml_file = YamlFile("system-cr-dataplatform", "Data Platform Operator ClusterRole",25 file_name, "system_dataplatform_components")26 self.yamls.append(system_cr_dataplatform_yaml_file)27 file_name = self.check_exists(self.system_dataplatform, "system-crb-dataplatform.yaml")28 system_crb_dataplatform_yaml_file = YamlFile("system-crb-dataplatform",29 "Data Platform Operator ClusterRoleBinding", file_name,30 "system_dataplatform_components")31 self.yamls.append(system_crb_dataplatform_yaml_file)32 file_name = self.check_exists(self.system_dataplatform, "system-crd-dataplatformoperator.yaml")33 system_crd_dataplatform_yaml_file = YamlFile("system-crd-dataplatform", "Data Platform CRD", file_name,34 "system_dataplatform_components")35 self.yamls.append(system_crd_dataplatform_yaml_file)36 file_name = self.check_exists(self.system_dataplatform, "system-deploy-dataplatformoperator.yaml")37 system_dataplatformoperator_yaml_file = YamlFile("system-dataplatformoperator", "Data Platform Operator",38 file_name, "system_dataplatform_components")39 self.yamls.append(system_dataplatformoperator_yaml_file)40 # file_name = self.check_exists(self.system_dataplatform, "system-scc-dataplatform.yaml")41 # system_scc_dataplatform_yaml_file = YamlFile("system-scc-dataplatform", "Data Platform Operator SCC" ,file_name, "system-dataplatform_components", True)42 # self.yamls.append(system_scc_dataplatform_yaml_file)43 file_name = self.check_exists(self.templates_dataplatform_setup, "template-namespace.yaml")44 template_namespace_yaml_file = YamlFile("template-namespace", "Data Platform Templates Namespace", file_name,45 "dataplatform_templates")46 self.yamls.append(template_namespace_yaml_file)47 file_name = self.check_exists(self.templates_dataplatform, "template-admincli-cm.yaml")48 template_admincli_cm_yaml_file = YamlFile("template-admincli-cm", "Data Platform Templates AdminCLI CM",49 file_name, "dataplatform_templates")50 self.yamls.append(template_admincli_cm_yaml_file)51 file_name = self.check_exists(self.templates_dataplatform, "template-cldb-cm.yaml")52 template_cldb_cm_yaml_file = YamlFile("template-cldb-cm", "Data Platform Templates CLDB CM", file_name,53 "dataplatform_templates")54 self.yamls.append(template_cldb_cm_yaml_file)55 file_name = self.check_exists(self.templates_dataplatform, "template-collectd-cm.yaml")56 template_collectd_cm_yaml_file = YamlFile("template-collectd-cm", "Data Platform Templates Collectd CM",57 file_name, "dataplatform_templates")58 self.yamls.append(template_collectd_cm_yaml_file)59 file_name = self.check_exists(self.templates_dataplatform, "template-elasticsearch-cm.yaml")60 template_elasticsearch_cm_yaml_file = YamlFile("template-elasticsearch-cm",61 "Data Platform Templates Elastic Search CM", file_name,62 "dataplatform_templates")63 self.yamls.append(template_elasticsearch_cm_yaml_file)64 file_name = self.check_exists(self.templates_dataplatform, "template-fluent-cm.yaml")65 template_fluent_cm_yaml_file = YamlFile("template-fluent-cm", "Data Platform Templates Fluent CM", file_name,66 "dataplatform_templates")67 self.yamls.append(template_fluent_cm_yaml_file)68 file_name = self.check_exists(self.templates_dataplatform, "template-httpfs-cm.yaml")69 template_httpfs_cm_yaml = YamlFile("template-httpfs-cm", "Data Platform Templates HTTPfs CM", file_name,70 "dataplatform_templates")71 self.yamls.append(template_httpfs_cm_yaml)72 file_name = self.check_exists(self.templates_dataplatform, "template-grafana-cm.yaml")73 template_grafana_cm_yaml = YamlFile("template-grafana-cm", "Data Platform Templates Grafana CM", file_name,74 "dataplatform_templates")75 self.yamls.append(template_grafana_cm_yaml)76 file_name = self.check_exists(self.templates_dataplatform, "template-kibana-cm.yaml")77 template_kibana_cm_yaml = YamlFile("template-kibana-cm", "Data Platform Templates Kibana CM", file_name,78 "dataplatform_templates")79 self.yamls.append(template_kibana_cm_yaml)80 file_name = self.check_exists(self.templates_dataplatform, "template-maprgateway-cm.yaml")81 template_maprgateway_cm_yaml = YamlFile("template-maprgateway-cm", "Data Platform Templates Mapr Gateway CM",82 file_name, "dataplatform_templates")83 self.yamls.append(template_maprgateway_cm_yaml)84 file_name = self.check_exists(self.templates_dataplatform, "template-mfs-cm.yaml")85 template_mfs_cm_yaml = YamlFile("template-mfs-cm", "Data Platform Templates MFS CM", file_name,86 "dataplatform_templates")87 self.yamls.append(template_mfs_cm_yaml)88 # file_name = self.check_exists(self.templates_dataplatform, "template-nfs-cm.yaml")89 # template_nfs_cm_yaml = YamlFile("template-nfs-cm", "Data Platform Templates NFS CM" ,file_name, "dataplatform_templates", True)90 # self.yamls.append(template_nfs_cm_yaml)91 file_name = self.check_exists(self.templates_dataplatform, "template-objectstore-cm.yaml")92 template_objectstore_cm_yaml = YamlFile("template-objectstore-cm", "Data Platform Templates Objectstore CM",93 file_name, "dataplatform_templates")94 self.yamls.append(template_objectstore_cm_yaml)95 file_name = self.check_exists(self.templates_dataplatform, "template-opentsdb-cm.yaml")96 template_opentsdb_cm_yaml = YamlFile("template-opentsdb-cm", "Data Platform Templates OpenTSDB CM", file_name,97 "dataplatform_templates")98 self.yamls.append(template_opentsdb_cm_yaml)99 file_name = self.check_exists(self.templates_dataplatform, "template-webserver-cm.yaml")100 template_webserver_cm_yaml = YamlFile("template-webserver-cm", "Data Platform Templates Webserver CM",101 file_name, "dataplatform_templates")102 self.yamls.append(template_webserver_cm_yaml)103 file_name = self.check_exists(self.templates_dataplatform, "template-zookeeper-cm.yaml")104 template_zookeeper_cm_yaml = YamlFile("template-zookeeper-cm", "Data Platform Templates Zookeeper CM",105 file_name, "dataplatform_templates")106 self.yamls.append(template_zookeeper_cm_yaml)107 file_name = self.check_exists(self.templates_dataplatform, "template-role-dataplatform.yaml")108 template_role_dataplatform_yaml = YamlFile("template-role-dataplatform", "Data Platform Templates Role",109 file_name, "dataplatform_templates")110 self.yamls.append(template_role_dataplatform_yaml)111 file_name = self.check_exists(self.templates_dataplatform, "template-role-dataplatform-user.yaml")112 template_role_dataplatform_user_yaml = YamlFile("template-role-dataplatform-user",113 "Data Platform Templates User Role", file_name,114 "dataplatform_templates")115 self.yamls.append(template_role_dataplatform_user_yaml)116 file_name = self.check_exists(self.templates_dataplatform, "template-role-admincli.yaml")117 template_role_admincli_yaml = YamlFile("template-role-admincli", "Data Platform AdminCLI Templates Role",118 file_name, "dataplatform_templates")119 self.yamls.append(template_role_admincli_yaml)120 file_name = self.check_exists(self.templates_dataplatform, "template-clusterrole-metrics.yaml")121 template_clusterrole_metrics_yaml = YamlFile("template-clusterrole-metrics",122 "Data Platform Templates Cluster Role for metrics service account",123 file_name, "dataplatform_templates")124 self.yamls.append(template_clusterrole_metrics_yaml)125 file_name = self.check_exists(self.templates_dataplatform, "template-clusterrole-init.yaml")126 template_clusterrole_init_yaml = YamlFile("template-clusterrole-init",127 "Data Platform Templates Cluster Role for init service account",128 file_name, "dataplatform_templates")129 self.yamls.append(template_clusterrole_init_yaml)130 file_name = self.check_exists(self.templates_dataplatform, "template-clusterrole-noderw.yaml")131 template_clusterrole_noderw_yaml = YamlFile("template-clusterrole-noderw",132 "Data Platform Templates Cluster Role for node read/write ops",133 file_name, "dataplatform_templates")134 self.yamls.append(template_clusterrole_noderw_yaml)135 file_name = self.check_exists(self.templates_dataplatform, "template-psp-dataplatform.yaml")136 template_psp_dataplatform_yaml = YamlFile("template-psp-dataplatform", "Data Platform Pod Security Policy",137 file_name, "dataplatform_templates")138 self.yamls.append(template_psp_dataplatform_yaml)139 file_name = self.check_exists(self.templates_dataplatform, "template-kafkarest-cm.yaml")140 template_kafkarest_cm_yaml_file = YamlFile("template-kafkarest-cm", "Data Platform Templates Kafkarest CM",141 file_name, "dataplatform_templates")142 self.yamls.append(template_kafkarest_cm_yaml_file)143 file_name = self.check_exists(self.templates_dataplatform, "template-hivemeta-cm.yaml")144 template_hivemeta_cm_yaml_file = YamlFile("template-hivemeta-cm", "Data Platform Templates Hive Metastore CM",145 file_name, "dataplatform_templates")146 self.yamls.append(template_hivemeta_cm_yaml_file)147 return True148 def install_dataplatform(self, upgrade_mode=False, install_templates=False):149 installable_yaml_types = ["system_dataplatform_components"]150 if install_templates:151 installable_yaml_types.append("dataplatform_templates")152 self.install_components(installable_yaml_types=installable_yaml_types, upgrade_mode=upgrade_mode)153 def uninstall_dataplatform(self, uninstall_templates=False):154 uninstallable_yaml_types = ["system_dataplatform_components"]155 if uninstall_templates:156 uninstallable_yaml_types.append("dataplatform_templates")157 self.uninstall_components(uninstallable_yaml_types=uninstallable_yaml_types)

Full Screen

Full Screen

SeatingSystem.py

Source:SeatingSystem.py Github

copy

Full Screen

...12 new_seats[y][x] = check_seat(x, y, seats, occupied_criteria)13 if part == 2:14 new_seats[y][x] = check_seat_pt2(x, y, seats, occupied_criteria)15 return new_seats16def check_exists(x, y, seats):17 try:18 seats[y][x]19 except IndexError:20 return False21 return True22def check_seat(x, y, seats, occupied_criteria):23 seat_state = seats[y][x]24 connected_seats = []25 dseat = 126 #Get Horizontals, Verticals, and Diagonals27 if check_exists(x+dseat, y, seats):28 connected_seats.append(seats[y][x+dseat])29 if check_exists(x-dseat, y, seats) and x-dseat >= 0:30 connected_seats.append(seats[y][x-dseat])31 #Verticals32 if check_exists(x, y+dseat, seats):33 connected_seats.append(seats[y+dseat][x])34 if check_exists(x, y-dseat, seats) and y-dseat >= 0:35 connected_seats.append(seats[y-dseat][x])36 #Diagonals37 if check_exists(x+dseat, y+dseat, seats):38 connected_seats.append(seats[y+dseat][x+dseat])39 if check_exists(x-dseat, y-dseat, seats) and y-dseat >= 0 and x-dseat >= 0:40 connected_seats.append(seats[y-dseat][x-dseat])41 if check_exists(x-dseat, y+dseat, seats) and x-dseat >= 0:42 connected_seats.append(seats[y+dseat][x-dseat])43 if check_exists(x+dseat, y-dseat, seats) and y-dseat >= 0:44 connected_seats.append(seats[y-dseat][x+dseat])45 if seat_state == "L" and connected_seats.count("#") == 0:46 return "#"47 elif seat_state == "#" and connected_seats.count("#") >= occupied_criteria:48 return "L"49 else:50 return seat_state51def check_seat_pt2(x, y, seats, occupied_criteria):52 seat_state = seats[y][x]53 connected_seats = []54 dseat = 155 #Get Horizontals, Verticals, and Diagonals56 if check_exists(x+dseat, y, seats):57 while seats[y][x+dseat] == "." and check_exists(x+dseat+1, y, seats):58 dseat += 159 connected_seats.append(seats[y][x+dseat])60 dseat = 161 if check_exists(x-dseat, y, seats) and x-dseat >= 0:62 while seats[y][x-dseat] == "." and check_exists(x-dseat-1, y, seats) and x-dseat-1>=0:63 dseat += 164 connected_seats.append(seats[y][x-dseat])65 dseat = 166 #Verticals67 if check_exists(x, y+dseat, seats):68 while seats[y+dseat][x] == "." and check_exists(x, y+dseat+1, seats):69 dseat += 170 connected_seats.append(seats[y+dseat][x])71 dseat = 172 if check_exists(x, y-dseat, seats) and y-dseat >= 0:73 while seats[y-dseat][x] == "." and check_exists(x, y-dseat-1, seats) and y - dseat-1 >=0:74 dseat += 175 connected_seats.append(seats[y-dseat][x])76 dseat = 177 #Diagonals78 if check_exists(x+dseat, y+dseat, seats):79 while seats[y+dseat][x+dseat] == "." and check_exists(x+dseat+1, y+dseat+1, seats):80 dseat += 181 connected_seats.append(seats[y+dseat][x+dseat])82 dseat = 183 if check_exists(x-dseat, y-dseat, seats) and y-dseat >= 0 and x-dseat >= 0:84 while seats[y - dseat][x - dseat] == "." and check_exists(x - dseat - 1, y - dseat - 1, seats) and y-dseat-1 >= 0 and x-dseat-1 >= 0:85 dseat += 186 connected_seats.append(seats[y-dseat][x-dseat])87 dseat = 188 if check_exists(x-dseat, y+dseat, seats) and x-dseat >= 0:89 while seats[y + dseat][x - dseat] == "." and check_exists(x - dseat - 1, y + dseat + 1, seats) and x-dseat-1 >= 0:90 dseat += 191 connected_seats.append(seats[y+dseat][x-dseat])92 dseat = 193 if check_exists(x+dseat, y-dseat, seats) and y-dseat >= 0:94 while seats[y - dseat][x + dseat] == "." and check_exists(x + dseat + 1, y - dseat - 1, seats) and y-dseat-1 >= 0:95 dseat += 196 connected_seats.append(seats[y-dseat][x+dseat])97 if seat_state == "L" and connected_seats.count("#") == 0:98 return "#"99 elif seat_state == "#" and connected_seats.count("#") >= occupied_criteria:100 return "L"101 else:102 return seat_state103def part1():104 seats = get_seats()105 while seats != play_round(seats, 4, 1):106 seats = play_round(seats, 4, 1)107 num_occupied = 0108 for line in seats:...

Full Screen

Full Screen

test_graph.py

Source:test_graph.py Github

copy

Full Screen

1from optrees import Edge, Graph, Vertex2def test_default_initial_graph():3 graph = Graph('G')4 assert graph.label == 'G'5 assert graph.vertices == dict()6 assert graph.edges == dict()7 assert graph.vertices_count == 08 assert graph.edges_count == 09def test_delete_graph():10 graph = Graph('G')11 del graph12 try:13 graph14 check_exists = True15 except NameError:16 check_exists = False17 assert check_exists is False18def test_repr():19 graph = Graph('G')20 assert graph.__repr__() == f'Graph({graph.label})'21def test_label():22 graph = Graph('G')23 assert graph.label == 'G'24def test_add_vertex():25 graph = Graph('G')26 vertex_a = Vertex('a')27 graph.add_vertex(vertex_a)28 assert graph.vertices == {'a': vertex_a}29 assert graph.vertices_count == 130 try:31 graph.add_vertex(vertex_a)32 check_exists = True33 except ValueError:34 check_exists = False35 assert check_exists is False36def test_add_vertices():37 graph = Graph('G')38 vertex_a = Vertex('a')39 vertex_b = Vertex('b')40 graph.add_vertices([vertex_a, vertex_b])41 assert graph.vertices == {'a': vertex_a, 'b': vertex_b}42 assert graph.vertices_count == 243 try:44 graph.add_vertices([vertex_a, vertex_b])45 check_exists = True46 except ValueError:47 check_exists = False48 assert check_exists is False49def test_add_edge():50 graph = Graph('G')51 vertex_a = Vertex('a')52 vertex_b = Vertex('b')53 edge_ab = Edge(vertex_a, vertex_b)54 graph.add_edge(edge_ab)55 assert graph.edges == {'a - b': edge_ab}56 assert graph.edges_count == 157 try:58 graph.add_edge(edge_ab)59 check_exists = True60 except ValueError:61 check_exists = False62 assert check_exists is False63def test_add_edges():64 graph = Graph('G')65 vertex_a = Vertex('a')66 vertex_b = Vertex('b')67 vertex_c = Vertex('c')68 edge_ab = Edge(vertex_a, vertex_b)69 edge_bc = Edge(vertex_b, vertex_c)70 graph.add_edges([edge_ab, edge_bc])71 assert graph.edges == {'a - b': edge_ab, 'b - c': edge_bc}72 assert graph.edges_count == 273 try:74 graph.add_edges([edge_ab, edge_bc])75 check_exists = True76 except ValueError:77 check_exists = False78 assert check_exists is False79def remove_vertex():80 graph = Graph('G')81 vertex_a = Vertex('a')82 vertex_b = Vertex('b')83 vertex_c = Vertex('c')84 edge_ab = Edge(vertex_a, vertex_b)85 edge_bc = Edge(vertex_b, vertex_c)86 graph.add_edges([edge_ab, edge_bc])87 graph.remove_vertex(vertex_b)88 assert graph.vertices == {'a': vertex_a, 'c': vertex_c}89 assert graph.vertices_count == 290 try:91 graph.remove_vertex(vertex_b)92 check_exists = True93 except ValueError:94 check_exists = False95 assert check_exists is False96def remove_vertices():97 graph = Graph('G')98 vertex_a = Vertex('a')99 vertex_b = Vertex('b')100 vertex_c = Vertex('c')101 edge_ab = Edge(vertex_a, vertex_b)102 edge_bc = Edge(vertex_b, vertex_c)103 graph.add_edges([edge_ab, edge_bc])104 graph.remove_vertices([vertex_b, vertex_c])105 assert graph.vertices == {'a': vertex_a}106 assert graph.vertices_count == 1107 try:108 graph.remove_vertices([vertex_b, vertex_c])109 check_exists = True110 except ValueError:111 check_exists = False112 assert check_exists is False113def remove_edge():114 graph = Graph('G')115 vertex_a = Vertex('a')116 vertex_b = Vertex('b')117 vertex_c = Vertex('c')118 edge_ab = Edge(vertex_a, vertex_b)119 edge_bc = Edge(vertex_b, vertex_c)120 graph.add_edges([edge_ab, edge_bc])121 graph.remove_edge(edge_bc)122 assert graph.edges == {'a - b': edge_ab}123 assert graph.edges_count == 1124 try:125 graph.remove_edge(edge_bc)126 check_exists = True127 except ValueError:128 check_exists = False129 assert check_exists is False130def remove_edges():131 graph = Graph('G')132 vertex_a = Vertex('a')133 vertex_b = Vertex('b')134 vertex_c = Vertex('c')135 edge_ab = Edge(vertex_a, vertex_b)136 edge_bc = Edge(vertex_b, vertex_c)137 graph.add_edges([edge_ab, edge_bc])138 graph.remove_edges([edge_bc, edge_ab])139 assert graph.edges == dict()140 assert graph.edges_count == 0141 try:142 graph.remove_edges([edge_bc, edge_ab])143 check_exists = True144 except ValueError:145 check_exists = False146 assert check_exists is False147def test_from_list():148 graph = Graph('G')149 edges_tuples = [('a', 'b'), ('b', 'c'), ('c', 'a')]150 graph.from_list(edges_tuples)151 assert graph.edges_count == 3...

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 autotest 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