[TMP] Test if date_start date_end is required and vice-versa AND unit test
This commit is contained in:
parent
6bc231fd1e
commit
409cf1e04a
@ -54,11 +54,10 @@ class GolemSeason(models.Model):
|
|||||||
""" Check if end date if after start date and if there is no conflict
|
""" Check if end date if after start date and if there is no conflict
|
||||||
with existing periods """
|
with existing periods """
|
||||||
for season in self:
|
for season in self:
|
||||||
if season.date_start:
|
if season.date_start or season.date_end:
|
||||||
if not season.date_end:
|
if season.date_start and not season.date_end:
|
||||||
raise models.ValidationError(_('The date end is required'))
|
raise models.ValidationError(_('The date end is required'))
|
||||||
if season.date_end:
|
elif season.date_end and not season.date_start:
|
||||||
if not season.date_start:
|
|
||||||
raise models.ValidationError(_('The date start is required'))
|
raise models.ValidationError(_('The date start is required'))
|
||||||
|
|
||||||
if season.date_start > season.date_end:
|
if season.date_start > season.date_end:
|
||||||
|
@ -55,13 +55,18 @@ class TestGolemSeason(TransactionCase):
|
|||||||
'date_start': '2009-11-01',
|
'date_start': '2009-11-01',
|
||||||
'date_end': '2011-12-31'})
|
'date_end': '2011-12-31'})
|
||||||
|
|
||||||
|
|
||||||
|
self.assertTrue({'name': 'date_end and date_start is empty',
|
||||||
|
'date_start': False,
|
||||||
|
'date_end': False})
|
||||||
|
|
||||||
with self.assertRaises(ValidationError):
|
with self.assertRaises(ValidationError):
|
||||||
self.season_model.create({'name': 'date_end is nul',
|
self.season_model.create({'name': 'date_end is empty',
|
||||||
'date_start': '2009-11-01',
|
'date_start': '2009-11-01',
|
||||||
'date_end': False})
|
'date_end': False})
|
||||||
|
|
||||||
with self.assertRaises(ValidationError):
|
with self.assertRaises(ValidationError):
|
||||||
self.season_model.create({'name': 'date_start is nul',
|
self.season_model.create({'name': 'date_start is empty',
|
||||||
'date_start' : False,
|
'date_start' : False,
|
||||||
'date_end': '2009-11-01'})
|
'date_end': '2009-11-01'})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user