Example #1
0
    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
Example #2
0
    def create_seminar(self, num_of_camps, num_of_hugs):
        seminar = Seminar()
        seminar.name = 'Seminar'
        self.session.add(seminar)
        for i in xrange(num_of_camps):
            camp = Camp()
            camp.name = 'Camp ' + str(i)
            camp.seminar = seminar
            self.session.add(camp)

        for i in xrange(num_of_hugs):
            hug = Hug()
            hug.name = 'Hug ' + str(i)
            hug.camp = seminar.camps[i % num_of_camps]
            self.session.add(hug)

        self.session.flush()
        return seminar