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)
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)
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)
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)
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)
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)
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()
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)