How to use _delete_nodes method in lisa

Best Python code snippet using lisa_python

tests.py

Source:tests.py Github

copy

Full Screen

...15 # setUp and tearDown are called before and after each test function16 def setUp(self):17 pass18 def tearDown(self):19 self._delete_nodes(label=constants.AD_PROFILE_LABELS[0])20 self._delete_nodes(label=constants.PERSON_LABELS[0])21 self._delete_nodes(label=constants.COMPANY_LABELS[0])22 def __init__(self, *args, **kwargs):23 super(ADOnboardTest, self).__init__(*args, **kwargs)24 with open(os.getcwd() + '/ad_secrets.yaml') as stream:25 secrets = yaml.load(stream)26 self.ad_url = secrets['AD_URL']27 self.ad_username = secrets['AD_USERNAME']28 self.ad_password = secrets['AD_PASSWORD']29 self.ad_search_base = secrets['AD_SEARCH_BASE']30 self.url = "/api/ad_integration/"31 self.group_id = 132 self.graph = Graph(constants.TEST_GRAPH_URL, bolt=constants.GRAPH_BOLT)33 self.test_ad_integration = ADIntegration('test', 'test', 'test', 'test', constants.TEST_GRAPH_URL,34 constants.TEST_QUEUE_URL + 'v2/', self.group_id)35 self.client = Client()36 self.entry = {37 constants.AD_TITLE: ADValue('title'),38 constants.AD_USERNAME: ADValue('sAMAccountName'),39 constants.AD_PRINCIPAL_NAME: ADValue('userPrincipalName'),40 constants.AD_GUID: ADValue('objectGUID'),41 constants.AD_COMPANY: ADValue('company'),42 constants.AD_PHONE_NUMBER: ADValue('mobile'),43 constants.AD_COUNTRY: ADValue('UAE'),44 constants.AD_CITY: ADValue('Dubai'),45 constants.AD_DISTINGUISHED_NAME: ADValue('distinguishedName'),46 constants.AD_EMAIL: ADValue('test@test.com'),47 constants.AD_FIRST_NAME: ADValue(''),48 constants.AD_LAST_NAME: ADValue('surname '),49 constants.AD_NAME: ADValue('first last'),50 constants.AD_MANAGER: ADValue('manager'),51 constants.AD_DIRECT_REPORTS: ADValue(['1', '2']),52 constants.AD_MEMBER_OF: ADValue('memberOf'),53 constants.AD_WHEN_CREATED: ADValue('whenCreated'),54 }55 self._delete_nodes(label=constants.AD_PROFILE_LABELS[0])56 self._delete_nodes(label=constants.PERSON_LABELS[0])57 self._delete_nodes(label=constants.COMPANY_LABELS[0])58 def _delete_nodes(self, label):59 query = "match (n:{0}) detach delete n".format(label)60 self.graph.run(query)61 def _get_all_nodes(self, label):62 query = "match (n:{0}) return n".format(label)63 nodes = []64 for record in self.graph.run(query):65 nodes.append(record[0])66 return nodes67 def _get_all_relations(self, from_label, to_label, relation_name):68 query = "match (n:{0})-[r:{1}]->(m:{2}) return r".format(from_label, relation_name, to_label)69 relation = []70 for record in self.graph.run(query):71 relation.append(record[0])72 return relation...

Full Screen

Full Screen

binary_tree.py

Source:binary_tree.py Github

copy

Full Screen

...85 def __str__(self):86 # Display the tree as a string87 return self._pretty_print(self.root)88 89 def _delete_nodes(self, node):90 if not node:91 return92 self._delete_nodes(node.left)93 self._delete_nodes(node.right)94 del node95 96 def __del__(self):97 # Delete each node recursively98 self._delete_nodes(self.root)99 def get_height(self):100 return self.height101 def get_num_nodes(self):102 return self.num_nodes103 def insert(self, node):104 log.debug("Inserting node {} into tree {}".format(node, self.name))105 cur = self.root106 while cur and (cur.left or cur.right):107 if node < cur and cur.left:108 log.debug("Going left from node {}".format(cur))109 cur = cur.left110 elif cur.right:111 log.debug("Going right from node {}".format(cur))112 cur = cur.right...

Full Screen

Full Screen

crossover.py

Source:crossover.py Github

copy

Full Screen

...43 _insert_node(nodes, new_ch2, L2)44 return new_ch1, new_ch245#===</Route Crossover>===#46#===<Best Cost Route Crossover>===#47def _delete_nodes(chromosome, route):48 remove_index_list = []49 chromosome_deleated = []50 for rt in chromosome:51 route_deleated = [node for node in rt if node not in route]52 chromosome_deleated.append(route_deleated)53 return chromosome_deleated54def _best_cost_route_crossover(nodes, ch1, ch2):55 route1 = random.choice(ch1)56 route2 = random.choice(ch2)57 ch1 = _delete_nodes(ch1, route2)58 ch2 = _delete_nodes(ch2, route1)59 _insert_node(nodes, ch1, route2)60 _insert_node(nodes, ch2, route1)61 return ch1, ch262#===</Best Cost Route Crossover>===#63##########64# Public #65##########66def route_crossover(offsprings, nodes, rate=0.5):67 new_offsprings = []68 half = len(offsprings)/269 for (indv1, indv2) in zip (offsprings[0:half], offsprings[half:]):70 tmp1 = copy.deepcopy(indv1)71 tmp2 = copy.deepcopy(indv2)72 if random.random() < rate:...

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