def test_add_del_road(self): self.assertEqual(Road.objects.all().count(), 2) self.r2.exists = False self.r2.save() r3 = RoadPrototype.create(point_1=self.p1, point_2=self.p3) self.assertEqual(Road.objects.all().count(), 3) self.assertEqual(Road.objects.filter(exists=False).count(), 1) self.assertEqual(Road.objects.filter(exists=True).count(), 2) self.assertEqual(Waymark.objects.all().count(), 9) waymark = waymarks_storage.look_for_road(point_from=self.p1.id, point_to=self.p3.id) self.assertEqual(waymark.road.id, self.r1.id) update_waymarks() self.assertEqual(Waymark.objects.all().count(), 9) waymark = waymarks_storage.look_for_road(point_from=self.p1.id, point_to=self.p3.id) self.assertEqual(waymark.road.id, r3.id) self.assertNotEqual(r3.id, self.r1.id)
def run(self, *args, **kwargs): # to sync map size and do other unpredictable operations run_django_command(['map_update_map']) self.INITIAL_PERSON_POWER = persons_storage.get_medium_power_for_person( ) with transaction.atomic(): p35 = places_storage[35] p35._model.is_frontier = False p35.save() p8x13 = self._create_place( x=8, y=13, roads_to=[p35], name_forms=noun( forms=(u'Сольвейг', u'Сольвейга', u'Сольвейгу', u'Сольвейг', u'Сольвейгом', u'Сольвейге', u'Сольвейги', u'Сольвейгов', u'Сольвейгам', u'Сольвейги', u'Сольвейгами', u'Сольвейгах'), properties=(u'мр,но'))) p39 = places_storage[39] p39._model.is_frontier = False p39.save() p52x26 = self._create_place( x=52, y=26, roads_to=[p39, places_storage[40]], name_forms=noun(forms=(u'Аматир', u'Аматира', u'Аматиру', u'Аматир', u'Аматиром', u'Аматире', u'Аматиры', u'Аматиров', u'Аматирам', u'Аматиры', u'Аматирами', u'Аматирах'), properties=(u'мр,но'))) p36 = places_storage[36] p36._model.is_frontier = False p36.save() p22x8 = self._create_place( x=22, y=8, roads_to=[p36], name_forms=noun(forms=(u'Залесье', u'Залесья', u'Залесью', u'Залесье', u'Залесьем', u'Залесье', u'Залесьи', u'Залесьев', u'Залесьям', u'Залесьи', u'Залесьями', u'Залесьях'), properties=(u'ср,но'))) update_waymarks() persons_logic.sync_social_connections() # update map with new places run_django_command(['map_update_map'])
def run(self, *args, **kwargs): # to sync map size and do other unpredictable operations run_django_command(['map_update_map']) self.INITIAL_PERSON_POWER = persons_storage.get_medium_power_for_person() with transaction.atomic(): p35 = places_storage[35] p35._model.is_frontier = False p35.save() p8x13 = self._create_place(x=8, y=13, roads_to=[p35], name_forms=noun(forms=(u'Сольвейг', u'Сольвейга', u'Сольвейгу', u'Сольвейг', u'Сольвейгом', u'Сольвейге', u'Сольвейги', u'Сольвейгов', u'Сольвейгам', u'Сольвейги', u'Сольвейгами', u'Сольвейгах'), properties=(u'мр,но'))) p39 = places_storage[39] p39._model.is_frontier = False p39.save() p52x26 = self._create_place(x=52, y=26, roads_to=[p39, places_storage[40]], name_forms=noun(forms=(u'Аматир', u'Аматира', u'Аматиру', u'Аматир', u'Аматиром', u'Аматире', u'Аматиры', u'Аматиров', u'Аматирам', u'Аматиры', u'Аматирами', u'Аматирах'), properties=(u'мр,но'))) p36 = places_storage[36] p36._model.is_frontier = False p36.save() p22x8 = self._create_place(x=22, y=8, roads_to=[p36], name_forms=noun(forms=(u'Залесье', u'Залесья', u'Залесью', u'Залесье', u'Залесьем', u'Залесье', u'Залесьи', u'Залесьев', u'Залесьям', u'Залесьи', u'Залесьями', u'Залесьях'), properties=(u'ср,но'))) update_waymarks() persons_logic.sync_social_connections() # update map with new places run_django_command(['map_update_map'])
def create_test_map(): linguistics_logic.sync_static_restrictions() map_logic.create_test_my_info() p1 = PlacePrototype.create( x=1, y=1, size=1, utg_name=names.generator.get_test_name(name='1x1')) p2 = PlacePrototype.create( x=3, y=3, size=3, utg_name=names.generator.get_test_name(name='10x10')) p3 = PlacePrototype.create( x=1, y=3, size=3, utg_name=names.generator.get_test_name(name='1x10')) for place in places_storage.all(): place.sync_persons(force_add=True) RoadPrototype.create(point_1=p1, point_2=p2).update() RoadPrototype.create(point_1=p2, point_2=p3).update() update_waymarks() update_nearest_cells() mob_1 = MobRecordPrototype.create_random('mob_1') mob_2 = MobRecordPrototype.create_random('mob_2') mob_3 = MobRecordPrototype.create_random('mob_3') ArtifactRecordPrototype.create_random('loot_1', mob=mob_1) ArtifactRecordPrototype.create_random('loot_2', mob=mob_2) ArtifactRecordPrototype.create_random('loot_3', mob=mob_3) ArtifactRecordPrototype.create_random('helmet_1', type_=ARTIFACT_TYPE.HELMET, mob=mob_1) ArtifactRecordPrototype.create_random('plate_1', type_=ARTIFACT_TYPE.PLATE, mob=mob_2) ArtifactRecordPrototype.create_random('boots_1', type_=ARTIFACT_TYPE.BOOTS, mob=mob_3) ArtifactRecordPrototype.create_random(DEFAULT_HERO_EQUIPMENT.PANTS, type_=ARTIFACT_TYPE.PANTS) ArtifactRecordPrototype.create_random(DEFAULT_HERO_EQUIPMENT.BOOTS, type_=ARTIFACT_TYPE.BOOTS) ArtifactRecordPrototype.create_random(DEFAULT_HERO_EQUIPMENT.PLATE, type_=ARTIFACT_TYPE.PLATE) ArtifactRecordPrototype.create_random(DEFAULT_HERO_EQUIPMENT.GLOVES, type_=ARTIFACT_TYPE.GLOVES) ArtifactRecordPrototype.create_random(DEFAULT_HERO_EQUIPMENT.WEAPON, type_=ARTIFACT_TYPE.MAIN_HAND) companions_logic.create_random_companion_record('companion_1', dedication=companions_relations.DEDICATION.HEROIC, state=companions_relations.STATE.ENABLED) companions_logic.create_random_companion_record('companion_2', dedication=companions_relations.DEDICATION.BOLD, state=companions_relations.STATE.ENABLED) companions_logic.create_random_companion_record('companion_3', dedication=companions_relations.DEDICATION.BOLD, state=companions_relations.STATE.DISABLED) return p1, p2, p3
def handle(self, *args, **options): update_waymarks()
def create_test_map(): linguistics_logic.sync_static_restrictions() map_logic.create_test_my_info() p1 = PlacePrototype.create( x=1, y=1, size=1, utg_name=names.generator.get_test_name(name='1x1')) p2 = PlacePrototype.create( x=3, y=3, size=3, utg_name=names.generator.get_test_name(name='10x10')) p3 = PlacePrototype.create( x=1, y=3, size=3, utg_name=names.generator.get_test_name(name='1x10')) for place in places_storage.all(): place.sync_persons(force_add=True) RoadPrototype.create(point_1=p1, point_2=p2).update() RoadPrototype.create(point_1=p2, point_2=p3).update() update_waymarks() update_nearest_cells() mob_1 = MobRecordPrototype.create_random('mob_1') mob_2 = MobRecordPrototype.create_random('mob_2') mob_3 = MobRecordPrototype.create_random('mob_3') ArtifactRecordPrototype.create_random('loot_1', mob=mob_1) ArtifactRecordPrototype.create_random('loot_2', mob=mob_2) ArtifactRecordPrototype.create_random('loot_3', mob=mob_3) ArtifactRecordPrototype.create_random('helmet_1', type_=ARTIFACT_TYPE.HELMET, mob=mob_1) ArtifactRecordPrototype.create_random('plate_1', type_=ARTIFACT_TYPE.PLATE, mob=mob_2) ArtifactRecordPrototype.create_random('boots_1', type_=ARTIFACT_TYPE.BOOTS, mob=mob_3) ArtifactRecordPrototype.create_random(DEFAULT_HERO_EQUIPMENT.PANTS, type_=ARTIFACT_TYPE.PANTS) ArtifactRecordPrototype.create_random(DEFAULT_HERO_EQUIPMENT.BOOTS, type_=ARTIFACT_TYPE.BOOTS) ArtifactRecordPrototype.create_random(DEFAULT_HERO_EQUIPMENT.PLATE, type_=ARTIFACT_TYPE.PLATE) ArtifactRecordPrototype.create_random(DEFAULT_HERO_EQUIPMENT.GLOVES, type_=ARTIFACT_TYPE.GLOVES) ArtifactRecordPrototype.create_random(DEFAULT_HERO_EQUIPMENT.WEAPON, type_=ARTIFACT_TYPE.MAIN_HAND) companions_logic.create_random_companion_record( 'companion_1', dedication=companions_relations.DEDICATION.HEROIC, state=companions_relations.STATE.ENABLED) companions_logic.create_random_companion_record( 'companion_2', dedication=companions_relations.DEDICATION.BOLD, state=companions_relations.STATE.ENABLED) companions_logic.create_random_companion_record( 'companion_3', dedication=companions_relations.DEDICATION.BOLD, state=companions_relations.STATE.DISABLED) return p1, p2, p3