Example #1
0
def get_items():
    pages = (
        OLXPages.parse(settings.OLX_URL),
        AllegroPages.parse(settings.ALEGRO_URL),
    )

    items = []

    for site_pages in pages:
        for page in site_pages.pages:
            for item in page.items:
                if settings.PRICE_FROM <= item.price:
                    items.append(Item.parse(item))
    print(len(items))
    return items
    def setUp(self):
        self.app = create_app('testing')
        self.test_app = self.app.test_client()
        with self.app.app_context():
            db.create_all()

        user = User(first_name="Johnny",
                    last_name="McSellingstuff",
                    email="*****@*****.**",
                    password="******")
        with self.app.app_context():
            db.session.add(user)
            db.session.commit()

        user = User(first_name="Jose",
                    last_name="De Los Buyingstuff",
                    email="*****@*****.**",
                    password="******")
        with self.app.app_context():
            db.session.add(user)
            db.session.commit()

        user = User(first_name="Jacques",
                    last_name="Du Purchaser",
                    email="*****@*****.**",
                    password="******")
        with self.app.app_context():
            db.session.add(user)
            db.session.commit()

        item = Item(
            user_id=1,
            title="Tea Set",
            description="Antique Tea set",
            price=140.00,
            category="furniture",
            charity="Big Cat Rescue",
            charity_url="http://www.thisisatotallyligiturl.com",
            charity_score=4,
            charity_score_image=
            "https://d20umu42aunjpx.cloudfront.net/_gfx_/icons/stars/4stars.png",
            image="img.ul",
            auction_length=5)
        with self.app.app_context():
            db.session.add(item)
            db.session.commit()

        item = Item(
            user_id=1,
            title="Rocking Chair",
            description="Vintage wood rocking chair",
            price=40.00,
            category='furniture',
            charity='Big Cat Rescue',
            charity_url="http://www.thisisatotallyligiturl.com",
            charity_score=4,
            charity_score_image=
            "https://d20umu42aunjpx.cloudfront.net/_gfx_/icons/stars/4stars.png",
            image='img.ul',
            auction_length=5)
        with self.app.app_context():
            db.session.add(item)
            db.session.commit()

        bid = Bid(item_id=1, user_id=2, amount=300.00)
        with self.app.app_context():
            db.session.add(bid)
            db.session.commit()

        bid = Bid(
            item_id=1,
            user_id=3,
            amount=400.00,
        )
        with self.app.app_context():
            db.session.add(bid)
            db.session.commit()
Example #3
0
    def setUp(self):
        self.app = create_app('testing')
        self.test_app = self.app.test_client()
        with self.app.app_context():
            db.create_all()

        user = User(first_name="Jimmy",
                    last_name="Cocopuff",
                    email="*****@*****.**",
                    password="******")
        with self.app.app_context():
            db.session.add(user)
            db.session.commit()

        user = User(first_name="Jimmy",
                    last_name="Cocobeans",
                    email="*****@*****.**",
                    password="******")
        with self.app.app_context():
            db.session.add(user)
            db.session.commit()

        user = User(first_name="Jimmy",
                    last_name="Jimmy",
                    email="*****@*****.**",
                    password="******")
        with self.app.app_context():
            db.session.add(user)
            db.session.commit()

        item = Item(
            user_id=1,
            title="Tea Set",
            description="Antique Tea set",
            price=140.00,
            category="furniture",
            charity="Big Cat Rescue",
            charity_url="http://www.thisisatotallyligiturl.com",
            charity_score=4,
            charity_score_image=
            "https://d20umu42aunjpx.cloudfront.net/_gfx_/icons/stars/4stars.png",
            image="img.ul",
            auction_end=trunc(datetime.now().timestamp()) - 5)
        with self.app.app_context():
            db.session.add(item)
            db.session.commit()

        item = Item(
            user_id=1,
            title="Rocking Chair",
            description="Vintage wood rocking chair",
            price=40.00,
            category='furniture',
            charity='Big Cat Rescue',
            charity_url="http://www.thisisatotallyligiturl.com",
            charity_score=4,
            charity_score_image=
            "https://d20umu42aunjpx.cloudfront.net/_gfx_/icons/stars/4stars.png",
            image='img.ul',
            auction_end=trunc(datetime.now().timestamp()) - 5)
        with self.app.app_context():
            db.session.add(item)
            db.session.commit()

        bid = Bid(item_id=1, user_id=2, amount=300.00)
        with self.app.app_context():
            db.session.add(bid)
            db.session.commit()

        bid = Bid(item_id=1, user_id=3, amount=350.00)
        with self.app.app_context():
            db.session.add(bid)
            db.session.commit()
Example #4
0
 def _fetch_all(sql, data):
     cursor.execute(sql, data)
     result = []
     for data in cursor.fetchall():
         result.append(Item.db_parse(data))
     return result