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)
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
def test_update_temp(self): car_seat = CarSeat("123ABC", "Graco - Extend to Fit") car_seat.set_gps_location("29.760427", "-95.369804") car_seat.set_temperature(72.1, "Fahrenheit") self.assertEqual(car_seat.temperature, 72.1) self.assertEqual(car_seat.temperature_unit, "Fahrenheit")
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")
def test_gps_location(self): car_seat = CarSeat("123ABC", "Graco - Extend to Fit") car_seat.set_gps_location("29.760427", "-95.369804") self.assertEqual(car_seat.latitude, "29.760427") self.assertEqual(car_seat.longitude, "-95.369804")