def test_move_person_to_place(self): person = self.place_1.persons[0] self.assertEqual(person.moved_at_turn, 0) game_time = TimePrototype.get_current_time() game_time.increment_turn() game_time.increment_turn() game_time.increment_turn() with self.check_changed(lambda: storage.persons.version): logic.move_person_to_place(person, self.place_3) self.assertEqual(person.moved_at_turn, 3) self.assertEqual(person.place.id, self.place_3.id)
def test_refresh_attributes__stability_penalty_for_masters_number(self): self.p1.refresh_attributes() with self.check_not_changed(lambda: self.p1.attrs.stability): while len(self.p1.persons) < c.PLACE_MAX_PERSONS: person = random.choice(list(persons_storage.persons.all())) persons_logic.move_person_to_place(person, self.p1) self.p1.refresh_attributes() with self.check_delta(lambda: self.p1.attrs.stability, -0.25): while len(self.p1.persons) <= c.PLACE_MAX_PERSONS: person = random.choice(list(persons_storage.persons.all())) persons_logic.move_person_to_place(person, self.p1) self.p1.refresh_attributes()
def test_refresh_attributes__stability_penalty_for_masters_number(self): self.p1.refresh_attributes() with self.check_not_changed(lambda: self.p1.attrs.stability): while len(self.p1.persons) < c.PLACE_MAX_PERSONS: person = random.choice(list(persons_storage.persons.all())) persons_logic.move_person_to_place(person, self.p1) self.p1.refresh_attributes() with self.check_delta(lambda: round(self.p1.attrs.stability, 2), -0.15000000000000002): while len(self.p1.persons) <= c.PLACE_MAX_PERSONS: person = random.choice(list(persons_storage.persons.all())) persons_logic.move_person_to_place(person, self.p1) self.p1.refresh_attributes()
def apply(self, bill=None): if not self.has_meaning(): return persons_logic.move_person_to_place(self.person, self.new_place)