def create_large_educatives_and_seminar(cls): NUMBER_OF_KENS = 50 NUMBER_OF_EDUCATIVES = 900 NUMBER_OF_HUGS = 45 NUMBER_OF_VEGETARIAN_HUGS = 8 kens = [] for i in xrange(NUMBER_OF_KENS): ken = Ken() ken.name = "Ken " + str(i) kens.append(ken) cls.session.add(ken) educatives = [] for i in xrange(NUMBER_OF_EDUCATIVES): educative = Educative() if random.randint(0, 2) == 0: educative.gender = MALE else: educative.gender = FEMALE if random.randint(0, 9) == 0: educative.food = VEGETARIAN else: educative.food = MEAT educative.first_name = "Educative" educative.last_name = str(i) educative.ken = kens[random.randint(0, NUMBER_OF_KENS - 1)] educatives.append(educative) cls.session.add(educative) seminar = Seminar() seminar.name = 'Seminar' cls.session.add(seminar) camp1, camp2, camp3 = Camp(), Camp(), Camp() camp1.name = 'Camp 1' camp2.name = 'Camp 2' camp3.name = 'Camp3' seminar.camps += [camp1, camp2, camp3] [cls.session.add(c) for c in seminar.camps] hugs = [] for i in xrange(NUMBER_OF_HUGS): hug = Hug() hug.name = "Hug " + str(i) hug.camp = seminar.camps[i % 3] if i < NUMBER_OF_VEGETARIAN_HUGS: hug.food = VEGETARIAN hugs.append(hug) cls.session.add(hug) for j in xrange(random.randint(1, 2)): madrich = Madrich() madrich.first_name = "Madrich" madrich.last_name = str(j) madrich.ken = kens[random.randint(0, NUMBER_OF_KENS - 1)] hug.madrichim.append(madrich) cls.session.add(madrich) return educatives, seminar
def create_small_educatives_and_seminar(cls): misgav = Ken() misgav.name = 'Misgav' cls.session.add(misgav) karmiel = Ken() karmiel.name = 'Karmiel' cls.session.add(karmiel) aviad = Educative() aviad.gender = MALE aviad.first_name = "Aviad" aviad.ken = misgav cls.session.add(aviad) naama = Educative() naama.gender = FEMALE naama.first_name = "Naama" naama.ken = karmiel cls.session.add(naama) inbar = Educative() inbar.gender = FEMALE inbar.first_name = "Inbar" inbar.ken = misgav cls.session.add(inbar) alon = Educative() alon.gender = MALE alon.first_name = "Alon" alon.ken = karmiel cls.session.add(alon) seminar = Seminar() cls.session.add(seminar) camp = Camp() camp.seminar = seminar cls.session.add(camp) hug1 = Hug() hug1.name = "Hug1" hug1.camp = camp cls.session.add(hug1) hug2 = Hug() hug2.name = "Hug2" hug2.camp = camp cls.session.add(hug2) return [aviad, naama, inbar, alon], seminar
def test_gender_constant(self): constraint = GenderRandomSoftConstraint(10, 10, 10) seminar = self.create_seminar(1, 2) hugs = seminar.camps[0].hugs educative1 = Educative() educative1.gender = MALE educative1.hug = hugs[0] educative2 = Educative() educative2.gender = FEMALE educative2.hug = hugs[0] educative3 = Educative() educative3.gender = FEMALE educative3.hug = hugs[1] score = constraint.calculate_score([educative1, educative2, educative3], seminar) self.assertEquals(score, 30)