예제 #1
0
    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)
예제 #2
0
    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)
예제 #3
0
    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=[])
예제 #4
0
    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)
예제 #5
0
    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=[])
예제 #6
0
    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)