def test_value(self):
     coordinates = Coordinates(46.0748, 11.1217)
     self.assertEqual(
         {
             Coordinates.LAT_KEY: 46.0748,
             Coordinates.LON_KEY: 11.1217
         }, coordinates.value)
    def test_repr(self):
        place = Place("id", "type", "name", Coordinates(46.0748, 11.1217))
        self.assertEqual(place, Place.from_repr(place.to_repr()))

        raw_place = {
            Place.TYPE_KEY: "type",
            Place.NAME_KEY: "name",
            Place.COORDINATES_KEY: {
                Coordinates.LAT_KEY: 46.0748,
                Coordinates.LON_KEY: 11.1217
            }
        }
        self.assertIsInstance(Place.from_repr(raw_place), Place)
 def test_get_coordinates(self):
     place = Place("id", "type", "name", Coordinates(46.0748, 11.1217))
     self.assertEqual(Coordinates(46.0748, 11.1217), place.get_coordinates())
 def test_update(self):
     place = Place("id", "type", "name", Coordinates(46.0748, 11.1217))
     place_updated = Place("id", "type2", "name2", Coordinates(46.0750, 11.1220))
     self.assertEqual(place_updated, place.update(place_updated))
Beispiel #5
0
 def from_repr(raw_place: dict) -> Place:
     return Place(
         raw_place[Place.ID_KEY]
         if Place.ID_KEY in raw_place else str(uuid.uuid4()),
         raw_place[Place.TYPE_KEY], raw_place[Place.NAME_KEY],
         Coordinates.from_repr(raw_place[Place.COORDINATES_KEY]))
 def test_repr(self):
     coordinates = Coordinates(46.0748, 11.1217)
     self.assertEqual(coordinates,
                      Coordinates.from_repr(coordinates.to_repr()))