Exemplo n.º 1
0
    def test_previous_slots_with_valid_details_results_list_of_avilable_slots(
            self):
        washing_machine = WashingMachineFactory()
        UserSlotFactory(user_slot_start_time=datetime.time(6, 00, 33, 174867),
                        user_slot_end_time=datetime.time(7, 00, 33, 174878),
                        washing_machine_id=washing_machine,
                        user_slot_date=datetime.date(2020, 6, 25),
                        user_slot_status="BOOKED",
                        slot_username="******")
        UserSlotFactory(user_slot_start_time=datetime.time(7, 30, 33, 175177),
                        user_slot_end_time=datetime.time(8, 30, 33, 174878),
                        washing_machine_id=washing_machine,
                        user_slot_date=datetime.date(2020, 7, 2),
                        user_slot_status="BOOKED",
                        slot_username="******")

        username = "******"
        date = datetime.date(2020, 7, 25)
        expected_slot_dtos = [
            UserSlotDto(user_slot_date=datetime.date(2020, 6, 25),
                        user_slot_start_time=datetime.time(6, 0, 33, 174867),
                        user_slot_end_time=datetime.time(7, 0, 33, 174878),
                        washing_machine_id='washing_machine_1'),
            UserSlotDto(user_slot_date=datetime.date(2020, 7, 2),
                        user_slot_start_time=datetime.time(7, 30, 33, 175177),
                        user_slot_end_time=datetime.time(8, 30, 33, 174878),
                        washing_machine_id='washing_machine_1')
        ]

        storage = SlotStorageImplementation()
        # storage.validate_washing_machine_number.return_value = True
        response_slot_dto = storage.list_of_previous_slot_dtos(
            username=username, date=date)
        # Assert
        assert expected_slot_dtos == response_slot_dto
 def test_get_allocated_slots_with_valid_details_results_list_of_allocated_slots(
         self):
     washing_machine = WashingMachineFactory()
     SlotFactory(slot_start_time=datetime.time(6, 00, 33, 174867),
                 slot_end_time=datetime.time(7, 00, 33, 174878),
                 washing_machine_id=washing_machine,
                 slot_day="SUNDAY")
     SlotFactory(slot_start_time=datetime.time(7, 30, 33, 175177),
                 slot_end_time=datetime.time(8, 30, 33, 174878),
                 washing_machine_id=washing_machine,
                 slot_day="SUNDAY")
     slot_day = "SUNDAY"
     expected_slot_dtos = [
         SlotDto(slot_start_time=datetime.time(6, 0, 33, 174867),
                 slot_end_time=datetime.time(7, 0, 33, 174878),
                 slot_day='SUNDAY',
                 washing_machine_id='washing_machine_1'),
         SlotDto(slot_start_time=datetime.time(7, 30, 33, 175177),
                 slot_end_time=datetime.time(8, 30, 33, 174878),
                 slot_day='SUNDAY',
                 washing_machine_id='washing_machine_1')
     ]
     storage = SlotStorageImplementation()
     response_allocated_slot_dtos = storage.allocated_slot_dtos(
         washing_machine.washing_machine_id, slot_day)
     assert response_allocated_slot_dtos == expected_slot_dtos
Exemplo n.º 3
0
 def test_avilable_slots_raises_error_when_invalid_date_is_given(self):
     username = "******"
     date = "2000-07-25"
     expected_slot_dtos = False
     storage = SlotStorageImplementation()
     # storage.validate_washing_machine_number.return_value = True
     response_slot_dto = storage.validate_date(date)
     # Assert
     assert expected_slot_dtos == response_slot_dto
Exemplo n.º 4
0
 def test_previous_slots_raises_error_when_invalid_date_is_given(self):
     # username = "******"
     date = datetime.date(2000, 7, 2)
     expected_slot_dtos = False
     storage = SlotStorageImplementation()
     # storage.validate_washing_machine_number.return_value = True
     response_slot_dto = storage.validate_date(date)
     # Assert
     assert expected_slot_dtos == response_slot_dto
 def test_get_allocated_slots_with_invalid_machine_id_raises_exception(
         self, slots, washing_machines):
     washing_machine_id = "washing_machine_10"
     day = "SUNDAY"
     expected = False
     storage = SlotStorageImplementation()
     response = storage.validate_washing_machine_id(washing_machine_id)
     # Assert
     assert expected == response
Exemplo n.º 6
0
 def test_add_update_slots_for_w_m_with_invalid_machine_id_raises_exception(
         self, slots, washing_machines):
     # username = "******"
     washing_machine_id = "washing_machine_10"
     day = "SUNDAY"
     expected = False
     storage = SlotStorageImplementation()
     # storage.validate_washing_machine_id.return_value = False
     response = storage.validate_washing_machine_id(washing_machine_id)
     # Assert
     assert expected == response