Best Python code snippet using gherkin-python
bindingdb_merger.py
Source:bindingdb_merger.py
...28 id = int(possible_id)29 if id > max:30 max = id31 return max32def get_next_id(ndex_network):33 net_id = unicode( ndex_network['externalId'] )34 if net_id not in get_next_id.max_id:35 get_next_id.max_id[net_id] = find_max_id(ndex_network)36 get_next_id.max_id[net_id] += 137 return unicode( get_next_id.max_id[net_id] )38get_next_id.max_id = {}39def handle_namespace(source_network, source_object, destination_network):40 namespace_id_string = 'namespaceId'41 namespace_id = unicode( source_object[namespace_id_string] )42 if namespace_id == '-1':43 return44 if namespace_id in handle_namespace.map:45 new_namespace_id = handle_namespace.map[namespace_id]46 source_object[namespace_id_string] = int( new_namespace_id )47 return48 namespaces = source_network['namespaces']49 namespace = namespaces[namespace_id]50 n = copy.deepcopy(namespace)51 new_namespace_id = get_next_id(destination_network)52 handle_namespace.map[namespace_id] = new_namespace_id53 n['id'] = int( new_namespace_id )54 source_object[namespace_id_string] = int( new_namespace_id )55 clean_object_properties(source_network, n, destination_network)56 destination_network['namespaces'][new_namespace_id] = n57handle_namespace.map = {}58def handle_represents(source_network, source_object, destination_network):59 if 'predicateId' in source_object:60 represents_string = 'predicateId'61 else:62 represents_string = 'represents'63 term_id = unicode( source_object[represents_string] )64 if term_id in handle_represents.map:65 new_term_id = handle_represents.map[term_id]66 source_object[represents_string] = int( new_term_id )67 return68 # Does not handle represents unless it is a baseTerm for now.69 terms = source_network['baseTerms']70 term = terms[term_id]71 t = copy.deepcopy(term)72 new_term_id = get_next_id(destination_network)73 handle_represents.map[term_id] = new_term_id74 t['id'] = new_term_id75 source_object[represents_string] = new_term_id76 handle_namespace(source_network, t, destination_network)77 destination_network['baseTerms'][new_term_id] = t78handle_represents.map = {}79def add_node(source_network, source_edge, destination_network):80 subject_id = unicode( source_edge['subjectId'] )81 if subject_id in add_node.subject_id_map:82 new_subject_id = add_node.subject_id_map[subject_id]83 source_edge['subjectId'] = int( new_subject_id )84 return85 subject_node = source_network['nodes'][subject_id]86 n = copy.deepcopy(subject_node)87 new_subject_id = get_next_id(destination_network)88 add_node.subject_id_map[subject_id] = new_subject_id89 n['id'] = int( new_subject_id )90 source_edge['subjectId'] = int( new_subject_id )91 clean_object_properties(source_network, n, destination_network)92 handle_citations(source_network, n, destination_network)93 handle_represents(source_network, n, destination_network)94 destination_network['nodes'][new_subject_id] = n95add_node.subject_id_map = {}96def clean_object_properties(source_network, propertied_object, destination_network):97 properties = propertied_object['properties']98 for property in properties:99 handle_represents(source_network, property, destination_network)100def handle_citations(source_network, source_object, destination_network):101 # print json.dumps(source_network['citations'], sort_keys=True, indent=4, separators=(',', ': '))102 citation_ids = source_object['citationIds']103 new_citation_ids = []104 for id in citation_ids:105 id = unicode(id)106 if id in handle_citations.citation_map:107 new_citation_id = handle_citations.citation_map[id]108 new_citation_ids.append( int(new_citation_id) )109 # Later use citation_map. For now, assign each citation a unique ID and add it to the destination_network110 else:111 citation = source_network['citations'][id]112 new_citation_id = get_next_id(destination_network)113 # Copy citation into destination network114 citation['id'] = new_citation_id115 destination_network['citations'][new_citation_id] = citation116 new_citation_ids.append( int(new_citation_id) )117 handle_citations.citation_map[id] = new_citation_id118 # print citation119 source_object['citationIds'] = new_citation_ids120handle_citations.citation_map = {}121def merge_node_properties(source_network, source_node, destination_network, destination_node):122 source_node_id = unicode(source_node['id'])123 if source_node_id in merge_node_properties.map:124 return125 source_node_properties = source_node['properties']126 for property in source_node_properties:127 p = copy.deepcopy(property)128 handle_represents(source_network, p, destination_network)129 destination_node['properties'].append(p)130merge_node_properties.map = {}131def match(source_network, edge, destination_network):132 aliases = destination_network['aliases']133def merge_network(source_network, destination_network):134 result = copy.deepcopy(destination_network)135 network_alias_node_id_map = create_alias_node_id_map(result)136 # print network_name_node_id_map137 for edge_id in source_network['edges']:138 edge = source_network['edges'][edge_id]139 object_id = unicode(edge['objectId'])140 object_node = source_network['nodes'][object_id]141 base_term_id = unicode( object_node['represents'] )142 source_node_name = source_network['baseTerms'][base_term_id]['name']143 if source_node_name in network_alias_node_id_map:144 for node_id in network_alias_node_id_map[source_node_name]:145 e = copy.deepcopy(edge)146 new_edge_id = unicode( get_next_id(result) )147 e['id'] = new_edge_id148 e['objectId'] = node_id149 add_node(source_network, e, result)150 clean_object_properties(source_network, e, result)151 handle_citations(source_network, e, result)152 handle_represents(source_network, e, result)153 result['edges'][new_edge_id] = e154 result_node = result['nodes'][node_id]155 merge_node_properties(source_network, object_node, result, result_node)156 result['nodeCount'] = len(result['nodes'])157 result['edgeCount'] = len(result['edges'])158 return result159def merge_provenance(src1_prov, src2_prov, upload_prov):160 result = copy.deepcopy(upload_prov)...
test_judge.py
Source:test_judge.py
...120 self.assertEqual(g.subscription_info(1),121 "Subscription <1> on 10.02.2020\nCustomer <1> Pesho; Address: addr.; Email: pesho@gmail.com\nTrainer <1> Pesho\nEquipment <1> Pesho\nPlan <1> with duration 10 minutes")122 def test_customer_static_method(self):123 Customer.id = 1124 self.assertEqual(Customer.get_next_id(), 1)125 def test_equipment_static_method(self):126 Equipment.id = 1127 self.assertEqual(Equipment.get_next_id(), 1)128 def test_trainer_static_method(self):129 Trainer.id = 1130 self.assertEqual(Trainer.get_next_id(), 1)131 def test_subscription_static_method(self):132 Subscription.id = 1133 self.assertEqual(Subscription.get_next_id(), 1)134 def test_plan_static_method(self):135 ExercisePlan.id = 1136 self.assertEqual(ExercisePlan.get_next_id(), 1)137if __name__ == "__main__":...
loot_factory.py
Source:loot_factory.py
...31 return self._create(random.choice(drop_table.drops), position)32 return None33 def _create(self, name, position):34 if name == 'heart':35 return HeartPickup(self.id_generator.get_next_id(), position, self.config.heart.health_amount, self.config.heart.pickup_lifespan)36 elif name == 'mega_heart':37 return MegaHeartPickup(self.id_generator.get_next_id(), position, self.config.mega_heart.pickup_lifespan)38 elif name == 'shield':39 return ShieldPickup(self.id_generator.get_next_id(), position, self.config.shield.shield_amount, self.config.shield.pickup_lifespan)40 elif name == 'mega_shield':41 return MegaShieldPickup(self.id_generator.get_next_id(), position, self.config.mega_shield.pickup_lifespan)42 elif name == 'double_fire':43 return DoubleFirePickup(self.id_generator.get_next_id(), position, self.config.double_fire.pickup_lifespan)44 elif name == 'spread_fire':45 return SpreadFirePickup(self.id_generator.get_next_id(), position, self.config.spread_fire.pickup_lifespan)46 elif name == 'rapid_fire':47 return RapidFirePickup(self.id_generator.get_next_id(), position, self.config.rapid_fire.pickup_lifespan)48 elif name == 'rocket':49 return RocketPickup(self.id_generator.get_next_id(), position, self.config.rocket.pickup_lifespan)50 elif name == 'rocket_salvo':51 return RocketSalvoPickup(self.id_generator.get_next_id(), position, self.config.rocket_salvo.pickup_lifespan)52 elif name == 'proximity_mine':53 return ProximityMinePickup(self.id_generator.get_next_id(), position, self.config.proximity_mine.pickup_lifespan)54 elif name == 'time_bomb':55 return TimeBombPickup(self.id_generator.get_next_id(), position, self.config.time_bomb.pickup_lifespan)56 else:...
test_scene.py
Source:test_scene.py
...10@pytest.fixture11def s():12 return Scene()13def test_sequence(s):14 assert s.get_next_id("anchor") == "000001"15 assert s.get_next_id("slider") == "000001"16 assert s.get_next_id("anchor") == "000002"17 assert s.get_next_id("slider") == "000002"18 assert s.get_next_id("anchor") == "000003"19 assert s.get_next_id("anchor") == "000004"20def test_entity_factory(s):21 a = Anchor("anchor-000001", 1, (0.0, 0.0))22 b = s.create_entity(Anchor, (0.0, 0.0))23 c = s.create_entity(Anchor, (0.0, 0.0))24 assert a._rank == b._rank25 assert a._uid == b._uid26 assert a.get_coords(0.0) == b.get_coords(0.0)27 assert a._rank == c._rank28 assert a._uid != c._uid29 assert a.get_coords(0.0) == b.get_coords(0.0)30def test_entity_factory_2rank(s):31 a1 = s.create_entity(Anchor, (0.0, 0.0))32 a2 = s.create_entity(Anchor, (1.0, 1.0))33 l1 = s.create_entity(Line, (a1, a2))...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!