Exemplo n.º 1
0
 def test_create_to_dict(self):
     """
     test to verified if the dic is created
     """
     place = Place()
     dict_new = place.to_dict()
     self.assertEqual(type(dict_new), dict)
Exemplo n.º 2
0
def retrieve_places():
    """ retrieve all places """
    places = []
    all_places = storage.all('Place').values()
    for place in all_places:
        places.append(place.to_dict())
    return jsonify(places)
Exemplo n.º 3
0
 def test_values_to_dict(self):
     """test to verified de values in a dic"""
     place = Place()
     dict_new = place.to_dict()
     self.assertEqual(dict_new["__class__"], "Place")
     self.assertEqual(type(dict_new["created_at"]), str)
     self.assertEqual(type(dict_new["updated_at"]), str)
     self.assertEqual(type(dict_new["id"]), str)
Exemplo n.º 4
0
 def test_to_dict_result(self):
     """ Tests the result of the dict """
     place = Place()
     new_dict = place.to_dict()
     self.assertEqual(new_dict["__class__"], "Place")
     self.assertEqual(type(new_dict["created_at"]), str)
     self.assertEqual(type(new_dict["updated_at"]), str)
     self.assertEqual(type(new_dict["id"]), str)
Exemplo n.º 5
0
def place_ret(city_id):
    """return json Place objects"""
    place_list = []
    city = storage.get("City", city_id)
    if city is None:
        abort(404)
    for place in city.places:
        place_list.append(place.to_dict())
    return jsonify(place_list)
Exemplo n.º 6
0
 def test_to_dict_values(self):
     """test the values in dict"""
     time = "%Y-%m-%dT%H:%M:%S.%f"
     place = Place()
     new_dict = place.to_dict()
     self.assertEqual(new_dict["__class__"], "Place")
     self.assertEqual(type(new_dict[c]), str)
     self.assertEqual(type(new_dict[u]), str)
     self.assertEqual(new_dict[c], place.created_at.strftime(time))
     self.assertEqual(new_dict[u], place.updated_at.strftime(time))
Exemplo n.º 7
0
 def test_to_dict_f(self):
     """ Tests the dictionary that comes from the father class """
     place = Place()
     new_dict = place.to_dict()
     self.assertEqual(type(new_dict), dict)
Exemplo n.º 8
0
 def test_str(self):
     """test that the str method has the correct output"""
     place = Place()
     string = "[Place] ({}) {}".format(place.id, place.to_dict())
     self.assertEqual(string, str(place))