def test_car_wash_getters(): car_wash = CarWash(1, "BOB") car = Car(1, "IAN", "ION") car_wash.add_car(car.get_id()) assert car_wash.get_id() == 1 assert car_wash.get_name() == "BOB" assert car_wash.get_cars() == [car.get_id()]
def test_car_getters(): car = Car(1, "BOB", "Jhon") assert str(car.get_id()).isdecimal() assert car.get_owner().isalpha() assert car.get_number().isalpha() assert car.get_id() == 1 assert car.get_number() == "BOB" assert car.get_owner() == "Jhon"
def test_functions(): repo_car = FileCarRepo("test_car.txt") repo_car_wash = FileCarWashRepo("test_car_wash.txt") service = Service(repo_car, repo_car_wash) # TEST CAR FUNCTIONS car1 = Car(1, "AG 25 DMG", "Ian") service.create_car(car1) file = open("test_car.txt", "r") read_car_line = file.readline() file.close() read_car = read_car_line.split(",") car2 = Car(int(read_car[0]), read_car[1], read_car[2].strip("\n")) assert car2 == car1 car3 = Car(1, "AG 65 DYN", "Ionel") service.modify_car(1, car3) file = open("test_car.txt", "r+") read_car_line = file.readline() read_car = read_car_line.split(",") car4 = Car(int(read_car[0]), read_car[1], read_car[2].strip("\n")) assert car4 == car3 service.delete_car(car3.get_id()) assert service.get_all_car() is not None # TEST CAR WASH FUNCTIONS car_wash1 = CarWash(1, "At Bob") service.create_car_wash(car_wash1) assert service.get_car_wash(1) == car_wash1 car_wash2 = CarWash(1, "La Geani") service.modify_car_wash(car_wash2) assert service.get_car_wash(1) == car_wash2 service.delete_car_wash(1) assert service.get_all_car_wash() == [] # TEST ADD AND REMOVE FUNCTIONS service.create_car_wash(car_wash1) service.create_car(car1) service.add_to_car_wash(1, 1) assert service.get_cars_in_car_wash(1) assert service.filter_by_number("AG") car_wash2 = service.get_car_wash(1) assert car_wash2.get_cars() == [car1.get_id()] service.remove_from_car_wash(car_wash1.get_id(), car1.get_id()) car_wash2 = service.get_car_wash(1) assert car_wash2.get_cars() == [] file2 = open("test_car_wash.txt", "w") file.truncate(0) file2.truncate(0) file.close() try: service.test_input("2", 12) assert True except ValidationError: assert False
def test_observer(): car_list = RepoCar() car_wash_list = RepoCarWash() car = Car(1, "AG 67 NIG", "Radu") car_wash = CarWash(1, "Geani's") car.add_observer(car_wash) car_list.store(car) assert len(car_list.get_all()) == 1 car_wash_list.store(car_wash) car_wash_list.get(1).add_car(car.get_id()) assert len(car_wash_list.get(1).get_cars()) == 1 car_list.delete(car.get_id()) assert len(car_list.get_all()) == 0 assert len(car_wash_list.get(1).get_cars()) == 0
def test_car_wash_str(): car_wash1 = CarWash(1, "Bob") car_wash2 = CarWash(1, "Bob") car1 = Car(1, "AG 67 NIG", "Ion") car_wash1.add_car(car1.get_id()) car_wash2.add_car(car1.get_id()) assert str(car_wash1) == str(car_wash2)
def test_car_setters(): car = Car(1, "BOB", "Jhon") car.set_owner("IAN") car.set_number("NIG") car.set_id(2) assert car.get_id() == 2 assert car.get_owner() == "IAN" assert car.get_number() == "NIG"
def test_car_wash_eq(): car_wash1 = CarWash(1, "Bob") car_wash2 = CarWash(1, "Bobul") car_wash3 = CarWash(1, "Bob") car_wash4 = CarWash(2, "Bob") car1 = Car(1, "AG 67 NIG", "Ion") car_wash3.add_car(car1.get_id()) assert not car_wash1 == car_wash2 assert not car_wash1 == car_wash3 assert not car_wash1 == car_wash4
def test_load(): car_repo = FileCarRepo("test_car.txt") car_wash_repo = FileCarWashRepo("test_car_wash.txt") car = Car(1, "AG 67 DYC", "Radu") car_wash = CarWash(1, "La Bob") car_wash.add_car(1) car_wash.add_car(2) car_repo.store(car) car_wash.add_car(car.get_id()) car_wash_repo.store(car_wash) test_car_repo = FileCarRepo("test_car.txt") test_car_wash_repo = FileCarWashRepo("test_car_wash.txt") assert test_car_repo.get(1) == car assert test_car_wash_repo.get(1) == car_wash file1 = open("test_car.txt", "w") file2 = open("test_car_wash.txt", "w") file1.truncate(0) file2.truncate(0) file1.close() file2.close()