def test_confirm_quatation_error(service: AcceptHoldReservation, context: Context, house, reservation): context.house = house context.reservation = attr.evolve(reservation, quotation_id=123) context.api = Mock(confirm_quotation=Mock(side_effect=RuntimeError('ERR'))) result = service.confirm_quotation(context) assert not is_successful(result) assert result.failure().failure == ReservationErrors.error assert str(result.failure().exc) == 'ERR'
def test_confirm_quatation_ok(service: AcceptHoldReservation, context: Context, house, reservation): context.house = house context.reservation = attr.evolve(reservation, quotation_id=123) context.api = Mock(confirm_quotation=Mock(return_value=None)) result = service.confirm_quotation(context) assert is_successful(result) context.api.confirm_quotation.assert_called_once_with(123)
def test_confirm_quatation_no_quatation_id(service: AcceptHoldReservation, context: Context, house, reservation): context.house = house context.reservation = attr.evolve(reservation, quotation_id=None) context.api = Mock(confirm_quotation=Mock(side_effect=RuntimeError('ERR'))) result = service.confirm_quotation(context) assert is_successful(result) context.api.confirm_quotation.assert_not_called()