def test_create_to_dict(self): """ test to verified if the dic is created """ review = Review() dict_new = review.to_dict() self.assertEqual(type(dict_new), dict)
def return_review(review_id): """return single place object""" review = storage.get('Review', place_id) if review is None: abort(404) else: return jsonify(review.to_dict())
def test_values_to_dict(self): """test to verified de values in a dic""" review = Review() dict_new = review.to_dict() self.assertEqual(dict_new["__class__"], "Review") self.assertEqual(type(dict_new["created_at"]), str) self.assertEqual(type(dict_new["updated_at"]), str) self.assertEqual(type(dict_new["id"]), str)
def test_to_dict_values(self): """test the values in dict""" time = "%Y-%m-%dT%H:%M:%S.%f" review = Review() new_dict = review.to_dict() self.assertEqual(new_dict["__class__"], "Review") self.assertEqual(type(new_dict[c]), str) self.assertEqual(type(new_dict[u]), str) self.assertEqual(new_dict[c], review.created_at.strftime(time)) self.assertEqual(new_dict[u], review.updated_at.strftime(time))
def update_review(review_id): """update a review""" review = {} review = storage.get('Review', review_id) if review is None: abort(404) data = request.get_json(silent=True) if data is None: abort(400, "Not a JSON") for k, v in data.items(): setattr(review, k, v) storage.save() return jsonify(review.to_dict()), 200
def test_str(self): """test that the str method has the correct output""" review = Review() string = "[Review] ({}) {}".format(review.id, review.to_dict()) self.assertEqual(string, str(review))