Example #1
0
    def test_create_missing_connections__restore_connections(self):
        logic.create_missing_connections()

        out_gamed_person = random.choice(storage.persons_storage.filter(state=relations.PERSON_STATE.IN_GAME))

        out_gamed_person.move_out_game()
        logic.out_game_obsolete_connections()

        logic.create_missing_connections()

        for person in storage.persons_storage.filter(state=relations.PERSON_STATE.IN_GAME):
            self.assertTrue(len(storage.social_connections.get_connected_persons_ids(person)) >= conf.settings.SOCIAL_CONNECTIONS_MINIMUM)
Example #2
0
    def test_out_game_obsolete_connections(self):
        logic.create_missing_connections()

        out_gamed_person = random.choice(storage.persons_storage.filter(state=relations.PERSON_STATE.IN_GAME))

        out_gamed_connections_number = len(storage.social_connections.get_connected_persons_ids(out_gamed_person))

        with self.check_delta(lambda: len(storage.social_connections.all()), -out_gamed_connections_number):
            out_gamed_person.move_out_game()
            logic.out_game_obsolete_connections()

        self.assertEqual(models.SocialConnection.objects.filter(state=relations.SOCIAL_CONNECTION_STATE.OUT_GAME).count(),
                         out_gamed_connections_number)
Example #3
0
    def test_create_missing_connections__restore_connections(self):
        logic.create_missing_connections()

        out_gamed_person = random.choice(
            storage.persons_storage.filter(
                state=relations.PERSON_STATE.IN_GAME))

        out_gamed_person.move_out_game()
        logic.out_game_obsolete_connections()

        logic.create_missing_connections()

        for person in storage.persons_storage.filter(
                state=relations.PERSON_STATE.IN_GAME):
            self.assertTrue(
                len(
                    storage.social_connections.get_connected_persons_ids(
                        person)) >= conf.settings.SOCIAL_CONNECTIONS_MINIMUM)
Example #4
0
    def test_out_game_obsolete_connections(self):
        logic.create_missing_connections()

        out_gamed_person = random.choice(
            storage.persons_storage.filter(
                state=relations.PERSON_STATE.IN_GAME))

        out_gamed_connections_number = len(
            storage.social_connections.get_connected_persons_ids(
                out_gamed_person))

        with self.check_delta(lambda: len(storage.social_connections.all()),
                              -out_gamed_connections_number):
            out_gamed_person.move_out_game()
            logic.out_game_obsolete_connections()

        self.assertEqual(
            models.SocialConnection.objects.filter(
                state=relations.SOCIAL_CONNECTION_STATE.OUT_GAME).count(),
            out_gamed_connections_number)