mise à jours du test avec date_start et date_stop

This commit is contained in:
eloyoussef 2018-03-12 15:34:43 +01:00
parent 41876e19c0
commit 0dda362d78
2 changed files with 27 additions and 6 deletions

View File

@ -217,7 +217,7 @@ class GolemResourceReservation(models.Model):
if is_day_allowed and (hour_start < timetable.time_start or \
hour_stop > timetable.time_stop):
verr = _('Not allowed, the resource is not available '
'during this schedule, please choose another '
'during this period, please choose another '
'time before confirming.')
raise ValidationError(verr)
if not is_day_allowed:

View File

@ -170,3 +170,24 @@ class TestGolemResourceReservation(TransactionCase):
with self.assertRaises(ValidationError) as err:
reservation.state_confirm()
self.assertIn(u'merci de choisir d\'autres horaires', err.exception.args[0])
def test_confirmed_other_res(self):
""" Test if there are other reservations in conflict """
reservation = self.res_obj.create(self.data)
reservation.state_confirm()
reservation2 = self.res_obj.create({
'resource_id': self.resource.id,
'date_start': '2018-02-05 10:00:00',
'date_stop': '2018-02-05 11:00:00',
'partner_id': self.partner.id
})
reservation2.state_confirm()
reservation3 = self.res_obj.create({
'resource_id': self.resource.id,
'date_start': '2018-02-05 11:20:00',
'date_stop': '2018-02-05 11:40:00',# Conflict with 2nd res
'partner_id': self.partner.id
})
with self.assertRaises(ValidationError) as err:
reservation3.state_confirm()
self.assertIn(u'déjà réservée durant cette période', err.exception.args[0])