Ejemplo n.º 1
0
    def test_json_export(self):
        profile = UserProfile("*****@*****.**", "parent", "123", "password")
        car_seat = CarSeat("123ABC", "Graco - Extend to Fit")
        car_seat.set_gps_location("29.760427", "-95.369804")
        car_seat.set_weight(6.5, "lbs")
        car_seat.set_temperature(72.1, "Fahrenheit")
        car_seat.car.set_car("Toyota", "Highlander", "2019", "vin_number_goes_here")
        profile.add_car_seat(car_seat)

        data = [profile.to_json()]
        DataHandler.export_to_json(os.getcwd() + "/resources/userprofiles.json", data)
Ejemplo n.º 2
0
 def convert_json_to_profiles(data):
     profiles = []
     for obj in data:
         profile = UserProfile(obj["email"], obj["first_name"],
                               obj["last_name"], obj["password"])
         for seat in obj["car_seats"]:
             car_seat = CarSeat(seat["serial_number"], seat["model"])
             car_seat.set_gps_location(seat["latitude"], seat["longitude"])
             car_seat.set_weight(seat["weight"], seat["weight_unit"])
             car_seat.set_temperature(seat["temperature"],
                                      seat["temperature_unit"])
             profile.add_car_seat(car_seat)
         profiles.append(profile)
     return profiles
Ejemplo n.º 3
0
 def test_update_weight(self):
     car_seat = CarSeat("123ABC", "Graco - Extend to Fit")
     car_seat.set_gps_location("29.760427", "-95.369804")
     car_seat.set_weight(6.5, "lbs")
     self.assertEqual(car_seat.weight, 6.5)
     self.assertEqual(car_seat.weight_unit, "lbs")