def test_create(self): user1 = { "id_user": 1, "id_book": 3, "date": "2020-12-09", "price": 45000 } self.assertTrue(Borrowbook.createInfo(**user1))
def test_create2(self): user2 = { "id_user": 5, "id_book": 7, "date": "2019-05-17", "price": 34000 } self.assertTrue(Borrowbook.createInfo(**user2))
def post(self): query = request.get_json() try: id_ = Borrowbook.createInfo(**query) if id_: res = Borrowbook.get_detail(id_) return make_response(jsonify({"data": res}), 201) return make_response(jsonify({"message": "Book not found"}), 404) except Exception as e: return make_response(jsonify({"message": str(e)}), 400)
def test_create(self): self.assertTrue(Borrowbook.createInfo(**user12)) self.assertTrue(Borrowbook.createInfo(**user13))
def test_create(self): with library_mysql.atomic() as txn: Borrowbook.createInfo(**user12) Borrowbook.createInfo(**user13) txn.rollback()