def test_create_new_book_when_input_empty_form_should_have_error(): data = { "bookname": "", "author": "", "description": "", "picture_url": "", "extern_url": "" } form = NewBookValidate(data=data) assert form.validate() is False assert len(form.errors) == 5
def post(self): """ Add new Book to DB @RequestForm - bookname - authorname - """ form = NewBookValidate(data=self.json) if form.validate(): bookModel = BookModel() bookModel.save_new_book(form.data) self.set_status(201) self.write({ "msg": "New Book Saved", "id": 1 }) self.write({ "msg": "Not Good", "errors": form.errors })