|
@@ -170,7 +170,7 @@ class ComponentTestCase(TestCase):
|
170
|
170
|
elif vname in ['date_create', 'date_update']:
|
171
|
171
|
# Datetime comparison
|
172
|
172
|
if check_date:
|
173
|
|
- self.assertEqualDatetime(val[vname], getattr(test_comp, vname), msg)
|
|
173
|
+ self.assertEqualDatetime(val[vname], getattr(test_comp, vname), vname+" assertion error : "+msg)
|
174
|
174
|
else:
|
175
|
175
|
prop = vname
|
176
|
176
|
self.assertEqual(getattr(test_comp, prop), val[vname], msg+"Inconsistency for "+prop+" property")
|
|
@@ -203,9 +203,9 @@ class TestInit(ComponentTestCase):
|
203
|
203
|
|
204
|
204
|
def test_component_abstract_init(self):
|
205
|
205
|
""" Test not valid call (from EmComponent) of __init__ """
|
206
|
|
- with self.assertRaises(EnvironmentError):
|
|
206
|
+ with self.assertRaises(NotImplementedError):
|
207
|
207
|
test_comp = EmComponent(2)
|
208
|
|
- with self.assertRaises(EnvironmentError):
|
|
208
|
+ with self.assertRaises(NotImplementedError):
|
209
|
209
|
test_comp = EmComponent('name')
|
210
|
210
|
pass
|
211
|
211
|
|
|
@@ -294,12 +294,14 @@ class TestSave(ComponentTestCase):
|
294
|
294
|
for prop in ['name', 'help', 'string', 'date_update', 'date_create', 'rank' ]:
|
295
|
295
|
if prop in ['string', 'help']:
|
296
|
296
|
assertion = self.assertEqualMlString
|
297
|
|
- elif prop in ['date_update', 'date_create']:
|
|
297
|
+ elif prop == 'date_create':
|
298
|
298
|
assertion = self.assertEqualDatetime
|
|
299
|
+ elif prop == 'date_update':
|
|
300
|
+ assertion = self.assertLess
|
299
|
301
|
else:
|
300
|
302
|
assertion = self.assertEqual
|
301
|
303
|
|
302
|
|
- assertion(getattr(test_comp, prop), getattr(test_comp2, prop), "Save don't propagate modification properly. The '"+prop+"' property differs between the modified instance and a new one fetch from Db : ")
|
|
304
|
+ assertion(getattr(test_comp, prop), getattr(test_comp2, prop), "Save don't propagate modification properly. The '"+prop+"' property hasn't the exepted value in instance fetched from Db : ")
|
303
|
305
|
pass
|
304
|
306
|
|
305
|
307
|
def test_component_save_setattr(self):
|
|
@@ -352,32 +354,6 @@ class TestSave(ComponentTestCase):
|
352
|
354
|
|
353
|
355
|
pass
|
354
|
356
|
|
355
|
|
- @unittest.skip("Soon we will not use anymore the values argument of the savec method")
|
356
|
|
- def test_component_save(self):
|
357
|
|
- """ Checking save method after different changes using values arg of save method """
|
358
|
|
- val = self.test_values[0]
|
359
|
|
- test_comp = EmTestComp(val['name'])
|
360
|
|
- self.check_equals(val, test_comp)
|
361
|
|
-
|
362
|
|
- save_args = [
|
363
|
|
- { 'name': 'foonewname' },
|
364
|
|
- { 'name': 'foo new name'},
|
365
|
|
- { 'help': '{"fr": "strhelp fr", "en":"strhelp en", "es":"strhelp es"}'},
|
366
|
|
- { 'string': '{"fr": "helpstr fr", "en":"helpstr en", "es":"helpstr es"}'},
|
367
|
|
- { 'name': 'oldname', 'help':'{"fr": "help fra", "en":"help eng", "es":"help esp"}', 'string':'{"fr": "string FR", "en":"string EN", "es":"string ES", "foolang":"foofoobar"}'},
|
368
|
|
- { 'help': '{}', 'string':'{}'},
|
369
|
|
- ]
|
370
|
|
- for values in save_args:
|
371
|
|
- for vname in values:
|
372
|
|
- val[vname] = values[vname]
|
373
|
|
-
|
374
|
|
- v = values.copy()
|
375
|
|
- #WARNING : v is set by save
|
376
|
|
- test_comp.save(v)
|
377
|
|
-
|
378
|
|
- print(val,"\n" ,values)
|
379
|
|
- self._savecheck(test_comp, val)
|
380
|
|
-
|
381
|
357
|
def test_component_save_illegalchanges(self):
|
382
|
358
|
""" checking that the save method forbids some changes """
|
383
|
359
|
val = self.test_values[1]
|
|
@@ -385,11 +361,12 @@ class TestSave(ComponentTestCase):
|
385
|
361
|
changes = { 'date_create': datetime.datetime(1982,4,2,13,37), 'date_update': datetime.datetime(1982,4,2,22,43), 'rank': 42 }
|
386
|
362
|
|
387
|
363
|
for prop in changes:
|
388
|
|
- with self.subTest("Illega change of "+prop):
|
|
364
|
+ with self.subTest("Illegal change of "+prop):
|
389
|
365
|
test_comp = EmTestComp(val['name'])
|
390
|
|
- self.check_equals(val, test_comp)
|
|
366
|
+ self.check_equals(val, test_comp, False)
|
391
|
367
|
|
392
|
|
- setattr(test_comp, prop, changes[prop])
|
|
368
|
+ with self.assertRaises(TypeError):
|
|
369
|
+ setattr(test_comp, prop, changes[prop])
|
393
|
370
|
test_comp.save()
|
394
|
371
|
|
395
|
372
|
test_comp2 = EmTestComp(val['name'])
|
|
@@ -564,10 +541,10 @@ class TestModifyRank(ComponentTestCase):
|
564
|
541
|
|
565
|
542
|
for j in range(1,i+1):
|
566
|
543
|
test_comp2 = EmTestComp(names[j])
|
567
|
|
- self.assertEqual(test_comp2.rank, j-1)
|
|
544
|
+ self.assertEqual(test_comp2.rank, j-1, self.dump_ranks())
|
568
|
545
|
for j in range(i+1,nmax+1):
|
569
|
546
|
test_comp2 = EmTestComp(names[j])
|
570
|
|
- self.assertEqual(test_comp2.rank, j)
|
|
547
|
+ self.assertEqual(test_comp2.rank, j, self.dump_ranks())
|
571
|
548
|
|
572
|
549
|
test_comp.modify_rank(i,'-')
|
573
|
550
|
self.assertEqual(test_comp.rank, 0, "The instance on wich we applied the modify_rank -"+str(i)+" doesn't have excepted rank : excepted '0' but got '"+str(test_comp.rank)+"'")
|
|
@@ -576,7 +553,7 @@ class TestModifyRank(ComponentTestCase):
|
576
|
553
|
|
577
|
554
|
for j in range(1,nmax+1):
|
578
|
555
|
test_comp2 = EmTestComp(names[j])
|
579
|
|
- self.assertEqual(test_comp2.rank, j)
|
|
556
|
+ self.assertEqual(test_comp2.rank, j, self.dump_ranks())
|
580
|
557
|
|
581
|
558
|
test_comp = EmTestComp(names[3])
|
582
|
559
|
test_comp.modify_rank(2,'+')
|