Ejemplo n.º 1
0
    def test_update_work(self):
        data = self.build_data(True, True)

        tagType = TagType(label='one')
        db.session.add(tagType)

        tagType = TagType(label='two')
        db.session.add(tagType)
        

        tag_one = Tag(tag_type_id=1, text='one')
        tag_two = Tag(tag_type_id=2, text='two')

        workObj = Work()
        workObj.title = "Beginning Title"
        workObj.user_id = 1
        db.session.add(workObj)
        

        work.add_chapters(workObj, data["chapters"])   
        db.session.commit()

        data['work_id'] = workObj.id
        data['chapters'][0]['id'] = workObj.chapters[0].id
        work.update_work(data)
        workObj = Work.query.filter_by(id=workObj.id).first()
        self.assertTrue(workObj.title == "A Tale of Two Poor Students")
Ejemplo n.º 2
0
    def test_delete_work(self):

        self.build_data(False, False)
        
        workObj = Work()
        workObj.user_id = 1
        db.session.add(workObj)
        db.session.commit()

        work.delete_work(1, 1)
        works = Work.query.all()
        self.assertTrue(len(works) == 0)