Exemplo n.º 1
0
    def create(self, callback):
        assert self._callback is None
        self._callback = callback

        fruit = Fruit(fruit_id=uuid.uuid4().hex,
                      fruit=Fruit.get_random_fruit())

        ap = AsyncFruitPersister(fruit)
        ap.persist(self._on_persist_done)
Exemplo n.º 2
0
def post(payload: Payload):
    try:
        if REDIS.get(f"{payload.name}"):
            raise Exception(f"Fruit {payload.name} already exists!")
        Fruit(**{"name": payload.name, "count": payload.count}).add()
        Fruit.commit()
        REDIS.set(f"{payload.name}", f"{payload.count}")
        return EnumResponse.OK.value.response
    except Exception as error:
        logger.warning(error)
        return EnumResponse.BAD_REQUEST.value.response
Exemplo n.º 3
0
 def create_model_from_doc(self, doc):
     return Fruit(doc=doc)
Exemplo n.º 4
0
def init_db():
    Fruit(**{"name": "apple", "count": 1}).add()
    Fruit.commit()
Exemplo n.º 5
0
def _random_item():
    ITEMS = (
        Shirt(
            name='Polo',
            description=
            'Bacon ipsum dolor sit amet ham hock brisket ground round sirloin pork loin corned beef, pastrami ball tip venison pancetta filet mignon capicola tri-tip chuck. Ground round meatloaf prosciutto sausage, strip steak ball tip tenderloin andouille frankfurter pork ham short ribs hamburger bresaola. Hamburger rump filet mignon venison swine pork chop fatback. Capicola drumstick short loin, venison strip steak turkey chicken biltong turducken pork chop prosciutto pork jerky. Bacon sirloin flank, hamburger tri-tip drumstick ham hock pork loin pork chop.',
            price=49.99,
            size=Shirt.SMALL),
        Shirt(
            name='Oxford',
            description=
            'Boudin beef meatloaf ham hock shank short loin sirloin salami filet mignon hamburger pig biltong spare ribs pork. Short ribs pork chop leberkas cow tail tongue strip steak capicola chuck andouille t-bone. Tenderloin brisket ham hock, strip steak pig tri-tip pastrami beef ham prosciutto turkey filet mignon. Jerky swine beef, frankfurter ribeye prosciutto sirloin sausage cow leberkas andouille chuck tongue ball tip. Shankle turkey boudin ball tip, hamburger rump biltong pork belly flank short ribs bresaola sirloin chicken kielbasa. Swine pancetta pastrami meatball frankfurter, chicken flank. Drumstick beef ribs pork filet mignon.',
            price=59.99,
            size=Shirt.SMALL),
        Shirt(
            name='Graphic T',
            description=
            'Pork loin kielbasa leberkas tongue ribeye meatball. Pancetta leberkas shoulder boudin shankle tongue. Pastrami shoulder strip steak fatback andouille rump flank pork chop drumstick jerky leberkas shankle. Pork loin cow pork chop ground round frankfurter, ham boudin ribeye turkey beef ribs prosciutto shankle meatball sirloin meatloaf.',
            price=69.99,
            size=Shirt.SMALL),
        Shirt(
            name='Pocket T',
            description=
            'Swine ball tip frankfurter, pancetta shankle flank spare ribs ribeye capicola cow pork chop fatback kielbasa andouille t-bone. Spare ribs ball tip leberkas, pastrami salami turducken andouille hamburger. Bresaola beef ribs filet mignon, sausage t-bone shoulder venison ribeye pancetta chuck. Andouille kielbasa tenderloin, spare ribs short ribs biltong jerky fatback.',
            price=100,
            size=Shirt.MEDIUM),
        Shirt(
            name='Muscle T',
            description=
            'Turducken shoulder tail, bresaola kielbasa shank pork tri-tip flank brisket. Prosciutto chicken ground round, short loin brisket corned beef boudin cow. Fatback tail meatball spare ribs chicken. Salami cow strip steak tri-tip shankle shoulder tenderloin drumstick pig sirloin pork chop rump biltong hamburger ball tip.',
            price=150,
            size=Shirt.LARGE),
        Fruit(
            name='Apple',
            description=
            'Bacon ipsum dolor sit amet ham hock brisket ground round sirloin pork loin corned beef, pastrami ball tip venison pancetta filet mignon capicola tri-tip chuck. Ground round meatloaf prosciutto sausage, strip steak ball tip tenderloin andouille frankfurter pork ham short ribs hamburger bresaola. Hamburger rump filet mignon venison swine pork chop fatback. Capicola drumstick short loin, venison strip steak turkey chicken biltong turducken pork chop prosciutto pork jerky. Bacon sirloin flank, hamburger tri-tip drumstick ham hock pork loin pork chop.',
            price=1),
        Fruit(
            name='Banana',
            description=
            'Boudin beef meatloaf ham hock shank short loin sirloin salami filet mignon hamburger pig biltong spare ribs pork. Short ribs pork chop leberkas cow tail tongue strip steak capicola chuck andouille t-bone. Tenderloin brisket ham hock, strip steak pig tri-tip pastrami beef ham prosciutto turkey filet mignon. Jerky swine beef, frankfurter ribeye prosciutto sirloin sausage cow leberkas andouille chuck tongue ball tip. Shankle turkey boudin ball tip, hamburger rump biltong pork belly flank short ribs bresaola sirloin chicken kielbasa. Swine pancetta pastrami meatball frankfurter, chicken flank. Drumstick beef ribs pork filet mignon.',
            price=2),
        Fruit(
            name='Grape',
            description=
            'Pork loin kielbasa leberkas tongue ribeye meatball. Pancetta leberkas shoulder boudin shankle tongue. Pastrami shoulder strip steak fatback andouille rump flank pork chop drumstick jerky leberkas shankle. Pork loin cow pork chop ground round frankfurter, ham boudin ribeye turkey beef ribs prosciutto shankle meatball sirloin meatloaf.',
            price=3),
        Fruit(
            name='Orange',
            description=
            'Swine ball tip frankfurter, pancetta shankle flank spare ribs ribeye capicola cow pork chop fatback kielbasa andouille t-bone. Spare ribs ball tip leberkas, pastrami salami turducken andouille hamburger. Bresaola beef ribs filet mignon, sausage t-bone shoulder venison ribeye pancetta chuck. Andouille kielbasa tenderloin, spare ribs short ribs biltong jerky fatback.',
            price=4),
        Fruit(
            name='Strawberry',
            description=
            'Turducken shoulder tail, bresaola kielbasa shank pork tri-tip flank brisket. Prosciutto chicken ground round, short loin brisket corned beef boudin cow. Fatback tail meatball spare ribs chicken. Salami cow strip steak tri-tip shankle shoulder tenderloin drumstick pig sirloin pork chop rump biltong hamburger ball tip.',
            price=5),
    )

    from random import choice

    return choice(ITEMS)