@@ -207,10 +207,11 @@ def test_composer_numbers_no_model(self):
207
207
208
208
209
209
class TestSMSComposerBatch (TestMailFullCommon ):
210
+
210
211
@classmethod
211
212
def setUpClass (cls ):
212
213
super (TestSMSComposerBatch , cls ).setUpClass ()
213
- cls ._test_body = 'Zizisse an SMS.'
214
+ cls ._test_body = 'Hello ${object.name} zizisse an SMS.'
214
215
215
216
cls ._create_records_for_batch ('mail.test.sms' , 3 )
216
217
cls .sms_template = cls ._create_sms_template ('mail.test.sms' )
@@ -229,8 +230,12 @@ def test_composer_batch_active_domain(self):
229
230
with self .mockSMSGateway ():
230
231
messages = composer ._action_send_sms ()
231
232
232
- for record in self .records :
233
- self .assertSMSNotification ([{'partner' : r .customer_id } for r in self .records ], 'Zizisse an SMS.' , messages )
233
+ for record , message in zip (self .records , messages ):
234
+ self .assertSMSNotification (
235
+ [{'partner' : record .customer_id }],
236
+ 'Hello %s zizisse an SMS.' % record .name ,
237
+ message
238
+ )
234
239
235
240
def test_composer_batch_active_ids (self ):
236
241
with self .with_user ('employee' ):
@@ -245,8 +250,12 @@ def test_composer_batch_active_ids(self):
245
250
with self .mockSMSGateway ():
246
251
messages = composer ._action_send_sms ()
247
252
248
- for record in self .records :
249
- self .assertSMSNotification ([{'partner' : r .customer_id } for r in self .records ], 'Zizisse an SMS.' , messages )
253
+ for record , message in zip (self .records , messages ):
254
+ self .assertSMSNotification (
255
+ [{'partner' : record .customer_id }],
256
+ 'Hello %s zizisse an SMS.' % record .name ,
257
+ message
258
+ )
250
259
251
260
def test_composer_batch_domain (self ):
252
261
with self .with_user ('employee' ):
@@ -262,8 +271,12 @@ def test_composer_batch_domain(self):
262
271
with self .mockSMSGateway ():
263
272
messages = composer ._action_send_sms ()
264
273
265
- for record in self .records :
266
- self .assertSMSNotification ([{'partner' : r .customer_id } for r in self .records ], 'Zizisse an SMS.' , messages )
274
+ for record , message in zip (self .records , messages ):
275
+ self .assertSMSNotification (
276
+ [{'partner' : record .customer_id }],
277
+ 'Hello %s zizisse an SMS.' % record .name ,
278
+ message
279
+ )
267
280
268
281
def test_composer_batch_res_ids (self ):
269
282
with self .with_user ('employee' ):
@@ -278,18 +291,22 @@ def test_composer_batch_res_ids(self):
278
291
with self .mockSMSGateway ():
279
292
messages = composer ._action_send_sms ()
280
293
281
- for record in self .records :
282
- self .assertSMSNotification ([{'partner' : r .customer_id } for r in self .records ], 'Zizisse an SMS.' , messages )
294
+ for record , message in zip (self .records , messages ):
295
+ self .assertSMSNotification (
296
+ [{'partner' : record .customer_id }],
297
+ 'Hello %s zizisse an SMS.' % record .name ,
298
+ message
299
+ )
283
300
284
301
285
302
class TestSMSComposerMass (TestMailFullCommon ):
286
303
287
304
@classmethod
288
305
def setUpClass (cls ):
289
306
super (TestSMSComposerMass , cls ).setUpClass ()
290
- cls ._test_body = 'Zizisse an SMS.'
307
+ cls ._test_body = 'Hello ${object.name} zizisse an SMS.'
291
308
292
- cls ._create_records_for_batch ('mail.test.sms' , 3 )
309
+ cls ._create_records_for_batch ('mail.test.sms' , 10 )
293
310
cls .sms_template = cls ._create_sms_template ('mail.test.sms' )
294
311
295
312
def test_composer_mass_active_domain (self ):
@@ -308,7 +325,10 @@ def test_composer_mass_active_domain(self):
308
325
composer .action_send_sms ()
309
326
310
327
for record in self .records :
311
- self .assertSMSOutgoing (record .customer_id , None , content = self ._test_body )
328
+ self .assertSMSOutgoing (
329
+ record .customer_id , None ,
330
+ content = 'Hello %s zizisse an SMS.' % record .name
331
+ )
312
332
313
333
def test_composer_mass_active_domain_w_template (self ):
314
334
with self .with_user ('employee' ):
@@ -326,7 +346,10 @@ def test_composer_mass_active_domain_w_template(self):
326
346
composer .action_send_sms ()
327
347
328
348
for record in self .records :
329
- self .assertSMSOutgoing (record .customer_id , None , content = 'Dear %s this is an SMS.' % record .display_name )
349
+ self .assertSMSOutgoing (
350
+ record .customer_id , None ,
351
+ content = 'Dear %s this is an SMS.' % record .display_name
352
+ )
330
353
331
354
def test_composer_mass_active_ids (self ):
332
355
with self .with_user ('employee' ):
@@ -342,8 +365,11 @@ def test_composer_mass_active_ids(self):
342
365
with self .mockSMSGateway ():
343
366
composer .action_send_sms ()
344
367
345
- for partner in self .partners :
346
- self .assertSMSOutgoing (partner , None , content = self ._test_body )
368
+ for partner , record in zip (self .partners , self .records ):
369
+ self .assertSMSOutgoing (
370
+ partner , None ,
371
+ content = 'Hello %s zizisse an SMS.' % record .name
372
+ )
347
373
348
374
def test_composer_mass_active_ids_w_blacklist (self ):
349
375
self .env ['phone.blacklist' ].create ([{
@@ -365,10 +391,17 @@ def test_composer_mass_active_ids_w_blacklist(self):
365
391
with self .mockSMSGateway ():
366
392
composer .action_send_sms ()
367
393
368
- for partner in self .partners [5 :]:
369
- self .assertSMSOutgoing (partner , partner .phone_sanitized , content = self ._test_body )
370
- for partner in self .partners [:5 ]:
371
- self .assertSMSCanceled (partner , partner .phone_sanitized , error_code = 'sms_blacklist' , content = self ._test_body )
394
+ for partner , record in zip (self .partners [5 :], self .records [5 :]):
395
+ self .assertSMSOutgoing (
396
+ partner , partner .phone_sanitized ,
397
+ content = 'Hello %s zizisse an SMS.' % record .name
398
+ )
399
+ for partner , record in zip (self .partners [:5 ], self .records [:5 ]):
400
+ self .assertSMSCanceled (
401
+ partner , partner .phone_sanitized ,
402
+ error_code = 'sms_blacklist' ,
403
+ content = 'Hello %s zizisse an SMS.' % record .name
404
+ )
372
405
373
406
def test_composer_mass_active_ids_wo_blacklist (self ):
374
407
self .env ['phone.blacklist' ].create ([{
@@ -390,17 +423,22 @@ def test_composer_mass_active_ids_wo_blacklist(self):
390
423
with self .mockSMSGateway ():
391
424
composer .action_send_sms ()
392
425
393
- for partner in self .partners :
394
- self .assertSMSOutgoing (partner , partner .phone_sanitized , content = self ._test_body )
426
+ for partner , record in zip (self .partners , self .records ):
427
+ self .assertSMSOutgoing (
428
+ partner , partner .phone_sanitized ,
429
+ content = 'Hello %s zizisse an SMS.' % record .name
430
+ )
395
431
396
432
def test_composer_mass_active_ids_w_blacklist_and_done (self ):
433
+ """ Create some duplicates + blacklist. record[5] will have duplicated
434
+ number on 6 and 7. """
397
435
self .env ['phone.blacklist' ].create ([{
398
436
'number' : p .phone_sanitized ,
399
437
'active' : True ,
400
438
} for p in self .partners [:5 ]])
401
- for p in self .partners [8 : ]:
402
- p .mobile = self .partners [8 ].mobile
403
- self .assertEqual (p .phone_sanitized , self .partners [8 ].phone_sanitized )
439
+ for p in self .partners [5 : 8 ]:
440
+ p .mobile = self .partners [5 ].mobile
441
+ self .assertEqual (p .phone_sanitized , self .partners [5 ].phone_sanitized )
404
442
405
443
with self .with_user ('employee' ):
406
444
composer = self .env ['sms.composer' ].with_context (
@@ -416,12 +454,29 @@ def test_composer_mass_active_ids_w_blacklist_and_done(self):
416
454
with self .mockSMSGateway ():
417
455
composer .action_send_sms ()
418
456
419
- for partner in self .partners [8 :]:
420
- self .assertSMSOutgoing (partner , partner .phone_sanitized , content = self ._test_body )
421
- for partner in self .partners [5 :8 ]:
422
- self .assertSMSCanceled (partner , partner .phone_sanitized , error_code = 'sms_duplicate' , content = self ._test_body )
423
- for partner in self .partners [:5 ]:
424
- self .assertSMSCanceled (partner , partner .phone_sanitized , error_code = 'sms_blacklist' , content = self ._test_body )
457
+ self .assertSMSOutgoing (
458
+ self .partners [5 ], self .partners [5 ].phone_sanitized ,
459
+ content = 'Hello %s zizisse an SMS.' % self .records [5 ].name
460
+ )
461
+ for partner , record in zip (self .partners [8 :], self .records [8 :]):
462
+ self .assertSMSOutgoing (
463
+ partner , partner .phone_sanitized ,
464
+ content = 'Hello %s zizisse an SMS.' % record .name
465
+ )
466
+ # duplicates
467
+ for partner , record in zip (self .partners [6 :8 ], self .records [6 :8 ]):
468
+ self .assertSMSCanceled (
469
+ partner , partner .phone_sanitized ,
470
+ error_code = 'sms_duplicate' ,
471
+ content = 'Hello %s zizisse an SMS.' % record .name
472
+ )
473
+ # blacklist
474
+ for partner , record in zip (self .partners [:5 ], self .records [:5 ]):
475
+ self .assertSMSCanceled (
476
+ partner , partner .phone_sanitized ,
477
+ error_code = 'sms_blacklist' ,
478
+ content = 'Hello %s zizisse an SMS.' % record .name
479
+ )
425
480
426
481
def test_composer_mass_active_ids_w_template (self ):
427
482
with self .with_user ('employee' ):
@@ -438,7 +493,10 @@ def test_composer_mass_active_ids_w_template(self):
438
493
composer .action_send_sms ()
439
494
440
495
for record in self .records :
441
- self .assertSMSOutgoing (record .customer_id , None , content = 'Dear %s this is an SMS.' % record .display_name )
496
+ self .assertSMSOutgoing (
497
+ record .customer_id , None ,
498
+ content = 'Dear %s this is an SMS.' % record .display_name
499
+ )
442
500
443
501
def test_composer_mass_active_ids_w_template_and_lang (self ):
444
502
self .env ['res.lang' ]._activate_lang ('fr_FR' )
@@ -472,9 +530,15 @@ def test_composer_mass_active_ids_w_template_and_lang(self):
472
530
473
531
for record in self .records :
474
532
if record .customer_id == self .partners [2 ]:
475
- self .assertSMSOutgoing (record .customer_id , None , content = 'Cher·e· %s ceci est un SMS.' % record .display_name )
533
+ self .assertSMSOutgoing (
534
+ record .customer_id , None ,
535
+ content = 'Cher·e· %s ceci est un SMS.' % record .display_name
536
+ )
476
537
else :
477
- self .assertSMSOutgoing (record .customer_id , None , content = 'Dear %s this is an SMS.' % record .display_name )
538
+ self .assertSMSOutgoing (
539
+ record .customer_id , None ,
540
+ content = 'Dear %s this is an SMS.' % record .display_name
541
+ )
478
542
479
543
def test_composer_mass_active_ids_w_template_and_log (self ):
480
544
with self .with_user ('employee' ):
@@ -491,7 +555,10 @@ def test_composer_mass_active_ids_w_template_and_log(self):
491
555
composer .action_send_sms ()
492
556
493
557
for record in self .records :
494
- self .assertSMSOutgoing (record .customer_id , None , content = 'Dear %s this is an SMS.' % record .display_name )
558
+ self .assertSMSOutgoing (
559
+ record .customer_id , None ,
560
+ content = 'Dear %s this is an SMS.' % record .display_name
561
+ )
495
562
self .assertSMSLogged (record , 'Dear %s this is an SMS.' % record .display_name )
496
563
497
564
def test_composer_template_context_action (self ):
@@ -541,7 +608,10 @@ def test_composer_template_context_action(self):
541
608
messages = composer ._action_send_sms ()
542
609
543
610
number = self .partners [2 ].phone_get_sanitized_number ()
544
- self .assertSMSNotification ([{'partner' : test_record_2 .customer_id , 'number' : number }], "Hello %s ceci est en français." % test_record_2 .display_name , messages )
611
+ self .assertSMSNotification (
612
+ [{'partner' : test_record_2 .customer_id , 'number' : number }],
613
+ "Hello %s ceci est en français." % test_record_2 .display_name , messages
614
+ )
545
615
546
616
# Composer creation with context from a template context action (simulate) - mass (multiple recipient)
547
617
with self .with_user ('employee' ):
@@ -563,5 +633,11 @@ def test_composer_template_context_action(self):
563
633
with self .mockSMSGateway ():
564
634
composer .action_send_sms ()
565
635
566
- self .assertSMSOutgoing (test_record_1 .customer_id , None , content = 'Dear %s this is an SMS.' % test_record_1 .display_name )
567
- self .assertSMSOutgoing (test_record_2 .customer_id , None , content = "Hello %s ceci est en français." % test_record_2 .display_name )
636
+ self .assertSMSOutgoing (
637
+ test_record_1 .customer_id , None ,
638
+ content = 'Dear %s this is an SMS.' % test_record_1 .display_name
639
+ )
640
+ self .assertSMSOutgoing (
641
+ test_record_2 .customer_id , None ,
642
+ content = "Hello %s ceci est en français." % test_record_2 .display_name
643
+ )
0 commit comments