def test_social_connections(self): persons_1 = self.place_1.persons persons_2 = self.place_2.persons persons_3 = self.place_3.persons persons_logic.create_social_connection(persons_relations.SOCIAL_CONNECTION_TYPE.random(), persons_1[0], persons_2[0]) persons_logic.create_social_connection(persons_relations.SOCIAL_CONNECTION_TYPE.random(), persons_1[1], persons_3[0]) persons_logic.create_social_connection(persons_relations.SOCIAL_CONNECTION_TYPE.random(), persons_2[0], persons_3[0]) persons_logic.create_social_connection(persons_relations.SOCIAL_CONNECTION_TYPE.random(), persons_2[1], persons_3[1]) self.hero.position.set_place(self.place_1) logic.fill_places(self.knowledge_base, self.get_hero_info(), waymarks_storage.look_for_road(self.place_1, self.place_2).length) logic.setup_persons(self.knowledge_base, self.get_hero_info()) logic.setup_social_connections(self.knowledge_base) expected_connections = [] for person in persons_storage.persons.all(): if person.place_id == self.place_3.id: continue for connection_type, connected_person_id in persons_storage.social_connections.get_person_connections(person): connected_person = persons_storage.persons[connected_person_id] if connected_person.place_id == self.place_3.id: continue expected_connections.append(logic.fact_social_connection(connection_type, uids.person(person.id), uids.person(connected_person.id))) self.check_facts(places=[logic.fact_place(self.place_1), logic.fact_place(self.place_2)], persons=[logic.fact_person(person) for person in persons_storage.persons.all() if person.place_id != self.place_3.id], locations=[logic.fact_located_in(person) for person in persons_storage.persons.all() if person.place_id != self.place_3.id], social_connections=expected_connections)
def test_diameter(self): self.hero.position.set_place(self.place_2) f_place_2 = logic.fact_place(self.place_2) f_place_3 = logic.fact_place(self.place_3) logic.fill_places(self.knowledge_base, self.get_hero_info(), waymarks_storage.look_for_road(self.place_1, self.place_3).length - 1) self.check_facts(places=[f_place_2, f_place_3])
def test_second_fill(self): self.hero.position.set_place(self.place_1) f_place_1 = logic.fact_place(self.place_1) f_place_2 = logic.fact_place(self.place_2) logic.fill_places(self.knowledge_base, self.get_hero_info(), waymarks_storage.look_for_road(self.place_1, self.place_2).length) self.check_facts(places=[f_place_1, f_place_2])
def test_social_connections(self): persons_1 = self.place_1.persons persons_2 = self.place_2.persons persons_3 = self.place_3.persons persons_logic.create_social_connection( persons_relations.SOCIAL_CONNECTION_TYPE.random(), persons_1[0], persons_2[0]) persons_logic.create_social_connection( persons_relations.SOCIAL_CONNECTION_TYPE.random(), persons_1[1], persons_3[0]) persons_logic.create_social_connection( persons_relations.SOCIAL_CONNECTION_TYPE.random(), persons_2[0], persons_3[0]) persons_logic.create_social_connection( persons_relations.SOCIAL_CONNECTION_TYPE.random(), persons_2[1], persons_3[1]) self.hero.position.set_place(self.place_1) logic.fill_places( self.knowledge_base, self.get_hero_info(), waymarks_storage.look_for_road(self.place_1, self.place_2).length) logic.setup_persons(self.knowledge_base, self.get_hero_info()) logic.setup_social_connections(self.knowledge_base) expected_connections = [] for person in persons_storage.persons.all(): if person.place_id == self.place_3.id: continue for connection_type, connected_person_id in persons_storage.social_connections.get_person_connections( person): connected_person = persons_storage.persons[connected_person_id] if connected_person.place_id == self.place_3.id: continue expected_connections.append( logic.fact_social_connection( connection_type, uids.person(person.id), uids.person(connected_person.id))) self.check_facts(places=[ logic.fact_place(self.place_1), logic.fact_place(self.place_2) ], persons=[ logic.fact_person(person) for person in persons_storage.persons.all() if person.place_id != self.place_3.id ], locations=[ logic.fact_located_in(person) for person in persons_storage.persons.all() if person.place_id != self.place_3.id ], social_connections=expected_connections)
def test_second_fill(self): self.hero.position.set_place(self.place_1) f_place_1 = logic.fact_place(self.place_1) f_place_2 = logic.fact_place(self.place_2) logic.fill_places( self.knowledge_base, self.get_hero_info(), waymarks_storage.look_for_road(self.place_1, self.place_2).length) self.check_facts(places=[f_place_1, f_place_2])
def test_radius(self): self.hero.position.set_place(self.place_1) logic.fill_places( self.knowledge_base, self.get_hero_info(), waymarks_storage.look_for_road(self.place_1, self.place_2).length) self.check_facts(places=[ logic.fact_place(self.place_1), logic.fact_place(self.place_2) ])
def test_no_social_connections(self): self.hero.position.set_place(self.place_1) logic.fill_places(self.knowledge_base, self.get_hero_info(), waymarks_storage.look_for_road(self.place_1, self.place_2).length) logic.setup_persons(self.knowledge_base, self.get_hero_info()) logic.setup_social_connections(self.knowledge_base) self.check_facts(places=[logic.fact_place(self.place_1), logic.fact_place(self.place_2)], persons=[logic.fact_person(person) for person in persons_storage.persons.all() if person.place_id != self.place_3.id], locations=[logic.fact_located_in(person) for person in persons_storage.persons.all() if person.place_id != self.place_3.id], social_connections=[])
def test_diameter(self): self.hero.position.set_place(self.place_2) f_place_2 = logic.fact_place(self.place_2) f_place_3 = logic.fact_place(self.place_3) logic.fill_places( self.knowledge_base, self.get_hero_info(), waymarks_storage.look_for_road(self.place_1, self.place_3).length - 1) self.check_facts(places=[f_place_2, f_place_3])
def test_place(self): place = self.place_1 self.hero.preferences.set_place(place) f_place = logic.fact_place(place) logic.setup_preferences(self.knowledge_base, self.get_hero_info()) self.check_facts(places=[f_place], hometowns=[facts.PreferenceHometown(object=self.hero_uid, place=f_place.uid)])
def test_social_connections(self): persons_logic.sync_social_connections() self.hero.position.set_place(self.place_1) logic.fill_places( self.knowledge_base, self.get_hero_info(), waymarks_storage.look_for_road(self.place_1, self.place_2).length) logic.setup_persons(self.knowledge_base, self.get_hero_info()) logic.setup_social_connections(self.knowledge_base) expected_connections = [] for person in persons_storage.persons.all(): if person.place_id == self.place_3.id: continue for connection_type, connected_person_id in persons_storage.social_connections.get_person_connections( person): connected_person = persons_storage.persons[connected_person_id] if connected_person.place_id == self.place_3.id: continue expected_connections.append( logic.fact_social_connection( connection_type, uids.person(person.id), uids.person(connected_person.id))) self.check_facts(places=[ logic.fact_place(self.place_1), logic.fact_place(self.place_2) ], persons=[ logic.fact_person(person) for person in persons_storage.persons.all() if person.place_id != self.place_3.id ], locations=[ logic.fact_located_in(person) for person in persons_storage.persons.all() if person.place_id != self.place_3.id ], social_connections=expected_connections)
def test_place(self): place = self.place_1 self.hero.preferences.set_place(place) f_place = logic.fact_place(place) logic.setup_preferences(self.knowledge_base, self.get_hero_info()) self.check_facts(places=[f_place], hometowns=[ facts.PreferenceHometown(object=self.hero_uid, place=f_place.uid) ])
def test_no_social_connections(self): self.hero.position.set_place(self.place_1) logic.fill_places( self.knowledge_base, self.get_hero_info(), waymarks_storage.look_for_road(self.place_1, self.place_2).length) logic.setup_persons(self.knowledge_base, self.get_hero_info()) logic.setup_social_connections(self.knowledge_base) self.check_facts(places=[ logic.fact_place(self.place_1), logic.fact_place(self.place_2) ], persons=[ logic.fact_person(person) for person in persons_storage.persons.all() if person.place_id != self.place_3.id ], locations=[ logic.fact_located_in(person) for person in persons_storage.persons.all() if person.place_id != self.place_3.id ], social_connections=[])
def test_friend(self): place = self.place_2 person = place.persons[0] self.hero.preferences.set_friend(person) f_place = logic.fact_place(place) f_person = logic.fact_person(person) logic.setup_preferences(self.knowledge_base, self.get_hero_info()) self.check_facts(places=[f_place], persons=[f_person], friends=[facts.PreferenceFriend(object=self.hero_uid, person=f_person.uid)], bad_branches=[facts.ExceptBadBranches(object=f_person.uid)])
def test_enemy(self): place = self.place_2 person = place.persons[0] self.hero.preferences.set_enemy(person) f_place = logic.fact_place(place) f_person = logic.fact_person(person) logic.setup_preferences(self.knowledge_base, self.get_hero_info()) self.check_facts(places=[f_place], persons=[f_person], enemies=[facts.PreferenceEnemy(object=self.hero_uid, person=f_person.uid)], good_branches=[facts.ExceptGoodBranches(object=f_person.uid)])
def test_social_connections(self): persons_logic.sync_social_connections() self.hero.position.set_place(self.place_1) logic.fill_places(self.knowledge_base, self.get_hero_info(), waymarks_storage.look_for_road(self.place_1, self.place_2).length) logic.setup_persons(self.knowledge_base, self.get_hero_info()) logic.setup_social_connections(self.knowledge_base) expected_connections = [] for person in persons_storage.persons.all(): if person.place_id == self.place_3.id: continue for connection_type, connected_person_id in persons_storage.social_connections.get_person_connections(person): connected_person = persons_storage.persons[connected_person_id] if connected_person.place_id == self.place_3.id: continue expected_connections.append(logic.fact_social_connection(connection_type, uids.person(person.id), uids.person(connected_person.id))) self.check_facts(places=[logic.fact_place(self.place_1), logic.fact_place(self.place_2)], persons=[logic.fact_person(person) for person in persons_storage.persons.all() if person.place_id != self.place_3.id], locations=[logic.fact_located_in(person) for person in persons_storage.persons.all() if person.place_id != self.place_3.id], social_connections=expected_connections)
def test_place__second_setup(self): place = self.place_1 self.hero.preferences.set(heroes_relations.PREFERENCE_TYPE.PLACE, place) f_place = logic.fact_place(place) self.knowledge_base += f_place logic.setup_preferences(self.knowledge_base, self.get_hero_info()) self.check_facts(places=[f_place], hometowns=[ facts.PreferenceHometown(object=self.hero_uid, place=f_place.uid) ])
def test_enemy(self): place = self.place_2 person = place.persons[0] self.hero.preferences.set_enemy(person) f_place = logic.fact_place(place) f_person = logic.fact_person(person) logic.setup_preferences(self.knowledge_base, self.get_hero_info()) self.check_facts( places=[f_place], persons=[f_person], enemies=[ facts.PreferenceEnemy(object=self.hero_uid, person=f_person.uid) ], good_branches=[facts.ExceptGoodBranches(object=f_person.uid)])
def test_friend(self): place = self.place_2 person = place.persons[0] self.hero.preferences.set_friend(person) f_place = logic.fact_place(place) f_person = logic.fact_person(person) logic.setup_preferences(self.knowledge_base, self.get_hero_info()) self.check_facts( places=[f_place], persons=[f_person], friends=[ facts.PreferenceFriend(object=self.hero_uid, person=f_person.uid) ], bad_branches=[facts.ExceptBadBranches(object=f_person.uid)])
def test_friend__second_setup(self): place = self.place_2 person = place.persons[0] self.hero.preferences.set(heroes_relations.PREFERENCE_TYPE.FRIEND, person) f_place = logic.fact_place(place) f_person = logic.fact_person(person) self.knowledge_base += f_place self.knowledge_base += f_person logic.setup_preferences(self.knowledge_base, self.get_hero_info()) self.check_facts( places=[f_place], persons=[f_person], friends=[ facts.PreferenceFriend(object=self.hero_uid, person=f_person.uid) ], bad_branches=[facts.ExceptBadBranches(object=f_person.uid)])
def test_enemy__second_setup(self): place = self.place_2 person = place.persons[0] self.hero.preferences.set(heroes_relations.PREFERENCE_TYPE.ENEMY, person) f_place = logic.fact_place(place) f_person = logic.fact_person(person) self.knowledge_base += f_place self.knowledge_base += f_person logic.setup_preferences(self.knowledge_base, self.get_hero_info()) self.check_facts( places=[f_place], persons=[f_person], enemies=[ facts.PreferenceEnemy(object=self.hero_uid, person=f_person.uid) ], good_branches=[facts.ExceptGoodBranches(object=f_person.uid)])
def test_maximum_radius(self): self.hero.position.set_place(self.place_1) logic.fill_places(self.knowledge_base, self.get_hero_info(), waymarks_storage.look_for_road(self.place_1, self.place_3).length) self.check_facts(places=[logic.fact_place(self.place_1), logic.fact_place(self.place_2), logic.fact_place(self.place_3)])