Exemplo n.º 1
0
    def test_create_missing_connections__minimum_connections(self):
        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)
Exemplo n.º 2
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)
Exemplo n.º 3
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)
Exemplo n.º 4
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)
Exemplo n.º 5
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)
Exemplo n.º 6
0
    def test_create_missing_connections__minimum_connections(self):
        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)
Exemplo n.º 7
0
 def test_create_missing_connections__success(self):
     with self.check_increased(models.SocialConnection.objects.count):
         with self.check_changed(lambda: storage.social_connections._version):
             logic.create_missing_connections()
Exemplo n.º 8
0
    def test_create_missing_connections__minimum_connections(self):
        logic.create_missing_connections()

        for person in storage.persons.all():
            self.assertTrue(len(storage.social_connections.get_connected_persons_ids(person)) >= conf.settings.SOCIAL_CONNECTIONS_MINIMUM)
Exemplo n.º 9
0
 def test_create_missing_connections__success(self):
     with self.check_increased(models.SocialConnection.objects.count):
         with self.check_changed(lambda: storage.social_connections._version):
             logic.create_missing_connections()