def setUp(self):
        self.connection = get_test_conn()
        ep.set_context(self.connection)
        ep.start_session()

        class Ingredient(ep.Object):
            name = ep.f.CharacterVarying(20)

        class Meal(ep.Object):
            name = ep.f.CharacterVarying(20)
            ingredients = ep.rel.OneToMany(Ingredient, dependent=False)

        for meal_name, ingredient_set in [
            ('meal1', ['spam', 'bacon']),
            ('meal2', ['spam', 'eggs', 'bacon']),
            ('meal3', ['spam', 'bacon', 'sausage']),
        ]:
            ingredients = [
                Ingredient(name = ing) for ing in ingredient_set
            ]
            ep.add(*ingredients)
            new_meal = Meal(name = meal_name, ingredients = ingredients)
            ep.add(new_meal)

        ep.commit()

        self.Ingredient = Ingredient
        self.Meal = Meal
Example #2
0
    def setUp(self):
        class Skit(ep.Object):
            title = ep.f.CharacterVarying(length=16)
            content = ep.f.FileField()

        class Jpeg(ep.Object):
            title = ep.f.CharacterVarying(length=16)
            content = ep.f.FileField(mimetype='image/jpeg')

        self.Skit = Skit
        self.Jpeg = Jpeg
        self.conn = get_test_conn()
        ep.set_context(self.conn)
        ep.start_session()
        parrot = Skit(title='parrot')
        ep.add(parrot)
        parrot.content.filename='parrot.txt'
        parrot.content.write(CONTENT_PARROT)
        hungarian = Skit(title='hungarian')
        ep.add(hungarian)
        hungarian.content.filename='hungarian.txt'
        hungarian.content.mimetype='text/x-rst'
        hungarian.content.write(CONTENT_HUNGARIAN)
        img = Jpeg(title='pythons')
        ep.add(img)
        img.content.import_(os.path.join(HERE, 'pythons.yotpeg'))
        inquisition = Skit(title='inquisition')
        ep.add(inquisition)
        inquisition.content.filename='inquisition'
        inquisition.content.write(CONTENT_INQUISITION)
        ep.commit()
    def setUp(self):
        class Image(ep.Object):
            image = ep.f.Image()
            thumb = ep.f.Thumb(origin=image, size=(100, 100))

        self.Image = Image
        self.conn = get_test_conn()
        ep.set_context(self.conn)
        ep.start_session()
        img = pystacia.read(os.path.join(HERE, 'pythons.yotpeg'))
        img.filename = 'pythons.jpeg'
        pythons = Image(image=img)
        ep.add(pythons)
        ep.commit()
Example #4
0
    def setUp(self):
        @ep.object.tree
        class Thing(Object):
            name = ep.field.CharacterVarying(30)

        self.connection = get_test_conn()
        ep.set_context(self.connection)
        animals = Thing(name='Animals')
        birds = Thing(name = 'Birds', parent=animals)
        mammals = Thing(name = 'Mammals', parent=animals)
        tiger = Thing(name = 'Tiger', parent=mammals)
        swallow = Thing(name = 'Swallow', parent=birds)
        european = Thing(name = 'European Swallow', parent=swallow)
        african = Thing(name = 'African Swallow', parent=swallow)
        ep.start_session()
        ep.add(animals, birds, mammals, tiger, swallow, european, african)
        ep.commit() 
        self.Thing = Thing
    def setUp(self):
        self.connection = get_test_conn()
        ep.set_context(self.connection)
        ep.start_session()
        class Food(ep.Object):
            name = ep.f.CharacterVarying(20)
            ingredients = ep.rel.ManyToMany()

        spam = Food(name='spam')
        eggs = Food(name='eggs')
        bacon = Food(name='bacon')
        sausage = Food(name='sausage')

        meal1 = Food(name='meal1', ingredients=[spam, bacon])
        meal2 = Food(name='meal2', ingredients=[spam, eggs, bacon])
        meal3 = Food(name='meal3', ingredients=[spam, bacon, sausage])
        ep.add(spam, eggs, bacon, sausage, meal1, meal2, meal3)
        self.Food = Food
        ep.commit()
    def test_eaft_relation(self):
        """
        This is a special test to create a related table when object depending
        on it (but with foreign key = NULL) is flushed
        """

        class Movie(ep.Object):
            title = ep.f.CharacterVarying(30)

        class Character(ep.Object):
            name = ep.f.CharacterVarying(30)
            movie = ep.rel.ManyToOne(Movie)

        c = Character(name="Nobody important", movie = None)

        self.connection = get_test_conn()
        ep.set_context(self.connection)
        ep.start_session()

        ep.add(c)
        ep.commit()
    def setUp(self):
        class Knight(ep.Object):
            title = f.CharacterVarying(length=5, null=False, default="Sir")
            name = f.CharacterVarying(length=20, null=False)
            nickname = f.CharacterVarying(length=20, null=True)
            score = f.Integer()

        self.Knight = Knight
        ep.set_context(get_test_conn())
        ep.start_session()

        for ktup in [
            ("Sir", "Galahad", "The Pure", 10),
            ("King", "Arthur", None, 20),
            ("Sir", "Robin", "The Brave", 30),
            ("Sir", "Lancelot", None, 40),
        ]:
            title, name, nickname, score = ktup
            k = Knight(title=title, name=name, nickname=nickname, score=score)
            ep.add(k)

        ep.commit()
    def setUp(self):
        class Ingredient(ep.Object):
            name = ep.f.CharacterVarying(20)

        class Meal(ep.Object):
            name = ep.f.CharacterVarying(20)
            ingredients = ep.rel.ManyToMany(Ingredient)

        self.connection = get_test_conn()
        ep.set_context(self.connection)

        spam = Ingredient(name='spam')
        eggs = Ingredient(name='eggs')
        bacon = Ingredient(name='bacon')
        sausage = Ingredient(name='sausage')
        ep.start_session()
        ep.add(spam, eggs, bacon, sausage)
        meal1 = Meal(name='meal1', ingredients=[spam, bacon])
        meal2 = Meal(name='meal2', ingredients=[spam, eggs, bacon])
        meal3 = Meal(name='meal3', ingredients=[spam, bacon, sausage])
        ep.add(meal1, meal2, meal3)
        self.Meal = Meal
        self.Ingredient = Ingredient
        ep.commit()
 def setUp(self):
     class Character(Object):
         name = f.CharacterVarying(length = 20)
         
     class Knight(Character):
         nickname = f.CharacterVarying(length = 20)
         
     
     self.connection = get_test_conn()
     ep.set_context(self.connection)
     ep.start_session()
     
     ep.add(Character(name = 'Arthur'))
     ep.add(Character(name = 'Patsy'))
     ep.add(Knight(name = 'Robin', nickname = 'The Brave'))
     ep.add(Knight(name = 'Galahad', nickname = 'The Pure'))
     ep.commit()
     
     self.Character = Character
     self.Knight = Knight