From 0dda362d787762ea58e83eb3abc7e7035da0a5f0 Mon Sep 17 00:00:00 2001 From: eloyoussef Date: Mon, 12 Mar 2018 15:34:43 +0100 Subject: [PATCH] =?UTF-8?q?mise=20=C3=A0=20jours=20du=20test=20avec=20date?= =?UTF-8?q?=5Fstart=20et=20date=5Fstop?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../models/golem_resource_reservation.py | 2 +- .../tests/test_golem_resource_reservation.py | 31 ++++++++++++++++--- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/golem_resource/models/golem_resource_reservation.py b/golem_resource/models/golem_resource_reservation.py index e098dad..0944819 100644 --- a/golem_resource/models/golem_resource_reservation.py +++ b/golem_resource/models/golem_resource_reservation.py @@ -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: diff --git a/golem_resource/tests/test_golem_resource_reservation.py b/golem_resource/tests/test_golem_resource_reservation.py index a5f18a3..f110882 100644 --- a/golem_resource/tests/test_golem_resource_reservation.py +++ b/golem_resource/tests/test_golem_resource_reservation.py @@ -138,7 +138,7 @@ class TestGolemResourceReservation(TransactionCase): self.env.user.groups_id = [(2, group_manager.id, False)] with self.assertRaises(ValidationError) as err: reservation.state_validated() - self.assertIn(u'autorisations nécessaires pour valider', err.exception.args[0]) + self.assertIn(u'autorisations nécessaires pour valider', err.exception.args[0]) def test_confirmed_period(self): """ Test allowed period """ @@ -146,7 +146,7 @@ class TestGolemResourceReservation(TransactionCase): reservation = self.res_obj.create(self.data) with self.assertRaises(ValidationError) as err: reservation.state_confirm() - self.assertIn(u'pas disponible durant cette période', err.exception.args[0]) + self.assertIn(u'pas disponible durant cette période', err.exception.args[0]) def test_confirmed_allowed_day(self): """ Test allowed day """ @@ -154,7 +154,7 @@ class TestGolemResourceReservation(TransactionCase): reservation = self.res_obj.create(self.data) with self.assertRaises(ValidationError) as err: reservation.state_confirm() - self.assertIn('pas disponible ce jour', err.exception.args[0]) + self.assertIn('pas disponible ce jour', err.exception.args[0]) def test_confirmed_allowed_hours(self): """ Test allowed hours """ @@ -162,11 +162,32 @@ class TestGolemResourceReservation(TransactionCase): reservation = self.res_obj.create(self.data) with self.assertRaises(ValidationError) as err: reservation.state_confirm() - self.assertIn(u'merci de choisir d\'autres horaires', err.exception.args[0]) + self.assertIn(u'merci de choisir d\'autres horaires', err.exception.args[0]) reservation = self.res_obj.create({'resource_id': self.resource.id, 'date_start': '2018-02-05 05:00:00',# Out of range start hour 'date_stop': '2018-02-05 12:00:00', 'partner_id': self.partner.id}) with self.assertRaises(ValidationError) as err: - reservation.state_confirm() + 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])