def test_includeSoftware(self): software = Software(1,"name","text","downloadUrl","applicationSubCategory") software.imageList = [Image("teste")] software.LinkList = [Link("teste")] software.screenshotList = [Screenshot("teste")] software.review = Review("teste",1) self.sDao.includeSoftware(software)
def readSoftware(self, id): ''' retorna o software pelo id carrega todos os relacionamento do software software_screenshot software_link software_image software_review ''' software=None try: self.cur = self.conn.cursor() stmt = 'SELECT *' stmt += "\nFROM software_software" stmt += "\nWHERE id=?" stmt += ';' self.cur.execute(stmt,[id]) data = self.cur.fetchone() if data: software= Software(data["id"],data["name"],data["text"],data["downloadUrl"],data["applicationSubCategory"]) stmt = 'select * from software_screenshot where software_id=?' self.cur.execute(stmt,[id]) rows = self.cur.fetchall() for row in rows: software.screenshotList.append(Screenshot(row["url_screenshot"])) stmt = 'select * from software_link where software_id=?' self.cur.execute(stmt,[id]) rows = self.cur.fetchall() for row in rows: software.linkList.append(Link(row["url_link"])) stmt = 'select * from software_image where software_id=?' self.cur.execute(stmt,[id]) rows = self.cur.fetchall() for row in rows: software.imageList.append(Image(row["url_image"])) stmt = 'select * from software_review where software_id=?' self.cur.execute(stmt,[id]) data = self.cur.fetchone() if data: software.review = Review(data["reviewBody"],data["ratingValue"]) return software finally: self.cur.close()
def parseHtmlToObject(item): software = Software(1,str(item.name), item.text, str(item.downloadUrl), str(item.applicationSubCategory)) images = [] for image in item.get_all('image') : images.append(Image(str(image))) software.imageList = images screenshots = [] for screenshot in item.get_all('screenshot') : screenshots.append(Screenshot(str(screenshot))) software.screenshotList=screenshots urls = [] for url in item.get_all('url') : urls.append(Link(str(url))) software.linkList=urls software.review = Review(item.review.reviewBody,item.review.ratingValue) return software