12
12
import django .test
13
13
from django .test .utils import override_settings
14
14
15
- import pydocusign
16
- import pydocusign .test
17
15
from django_docusign import api as django_docusign
18
16
19
17
from django_docusign_demo import models , views
@@ -107,7 +105,6 @@ def create_signature(self):
107
105
'signers-1-email' : u'paul@example.com' ,
108
106
'document' : document_file ,
109
107
'title' : u'A very simple PDF document' ,
110
- 'callback_url' : u'http://tech.novapost.fr' ,
111
108
}
112
109
response = self .client .post (url , data )
113
110
self .assertEqual (response .status_code , 302 )
@@ -118,19 +115,7 @@ def test_form_valid(self):
118
115
"""Can create a signature using 'create_signature' URL."""
119
116
self .assertTrue (self .signature .signature_backend_id )
120
117
121
- def test_create_signature_callback_enabled (self ):
122
- session = self .client .session
123
- session ['use_callback' ] = True
124
- session .save ()
125
-
126
- with mock .patch (self .pydocusign_create_envelope_method ) \
127
- as mock_envelope :
128
- mock_envelope .return_value = str (uuid .uuid4 ())
129
- self .assertTrue (self .signature .signature_backend_id )
130
- envelope = mock_envelope .call_args_list [0 ][0 ][0 ]
131
- self .assertIsNotNone (envelope .eventNotification )
132
-
133
- def test_create_signature_callback_disabled (self ):
118
+ def test_create_signature_no_event (self ):
134
119
with mock .patch (self .pydocusign_create_envelope_method ) \
135
120
as mock_envelope :
136
121
mock_envelope .return_value = str (uuid .uuid4 ())
@@ -147,27 +132,6 @@ def test_signer_view(self):
147
132
self .assertTrue (
148
133
response ['Location' ].startswith ('https://demo.docusign.net' ))
149
134
150
- @mock .patch ('pydocusign.DocuSignClient.get_envelope_recipients' )
151
- def test_signer_return_view_callback_enabled (self , mock_recipients ):
152
- session = self .client .session
153
- session ['use_callback' ] = True
154
- session .save ()
155
-
156
- signature = self .create_signature ()
157
- signer = signature .signers .all ()[0 ]
158
-
159
- url = reverse ('anysign:signer_return' , args = [signer .pk ])
160
- response = self .client .get (url )
161
- self .assertFalse (mock_recipients .called )
162
- self .assertEqual (response .status_code , 302 )
163
- self .assertRedirects (
164
- response ,
165
- reverse ('anysign:signer_return_with_callback' , args = [signer .pk ]))
166
- signature .refresh_from_db ()
167
- signer .refresh_from_db ()
168
- self .assertEqual (signature .status , 'draft' )
169
- self .assertEqual (signer .status , 'draft' )
170
-
171
135
@mock .patch ('pydocusign.DocuSignClient.get_envelope_recipients' )
172
136
def test_signer_return_canceled (self , mock_recipients ):
173
137
signature = self .create_signature ()
@@ -363,112 +327,6 @@ def test_signer_all_signed(self, mock_recipients):
363
327
self .assertEqual (signer1 .status , 'completed' )
364
328
self .assertEqual (signer2 .status , 'completed' )
365
329
366
- def send_signature_callback (self , data ):
367
- url = reverse ('anysign:signature_callback' )
368
- request_body = pydocusign .test .generate_notification_callback_body (
369
- data = data ,
370
- template_url = 'http://diecutter.io/github/'
371
- 'novafloss/pydocusign/master/'
372
- 'pydocusign/templates/callback.xml' )
373
- response = self .client .post (
374
- url ,
375
- content_type = 'text/xml' ,
376
- data = request_body ,
377
- )
378
- self .assertEqual (response .status_code , 200 )
379
- return response
380
-
381
- def test_signature_callback (self ):
382
- """Callback view handles DocuSign's 'sent' status."""
383
- signature = self .create_signature ()
384
- self .assertEqual (signature .signers .get (signing_order = 1 ).status ,
385
- 'draft' )
386
- self .assertEqual (signature .signers .get (signing_order = 2 ).status ,
387
- 'draft' )
388
- signers = signature .signers .all ().order_by ('signing_order' )
389
- data = {
390
- "RecipientStatuses" : [
391
- {
392
- "Email" : signer .email ,
393
- "UserName" : signer .full_name ,
394
- "ClientUserId" : signer .pk ,
395
- "Status" : pydocusign .Recipient .STATUS_SENT ,
396
- "Sent" : "2014-10-06T01:10:01.000012" ,
397
- } for signer in signers
398
-
399
- ],
400
- "EnvelopeId" : signature .signature_backend_id ,
401
- "Subject" : signature .document_title ,
402
- "UserName" : "Bob" ,
403
- "Created" : "2014-10-06T01:10:00.000012" ,
404
- "Sent" : "2014-10-06T01:10:01.000012" ,
405
- }
406
- # First, we receive "sent" callback.
407
- self .send_signature_callback (data )
408
- signature .refresh_from_db ()
409
- self .assertEqual (signature .signers .get (signing_order = 1 ).status ,
410
- 'sent' )
411
- self .assertEqual (signature .signers .get (signing_order = 2 ).status ,
412
- 'sent' )
413
- # Then, envelope is "delivered" to recipients.
414
- data ['RecipientStatuses' ][0 ]['Status' ] = "Delivered"
415
- data ['RecipientStatuses' ][0 ]['Delivered' ] = "2014-10-06" \
416
- "T01:10:02.000012"
417
- self .send_signature_callback (data )
418
- signature .refresh_from_db ()
419
- self .assertEqual (signature .signers .get (signing_order = 1 ).status ,
420
- 'delivered' )
421
- self .assertEqual (signature .signers .get (signing_order = 2 ).status ,
422
- 'sent' )
423
- # A recipient signs.
424
- data ['RecipientStatuses' ][0 ]['Status' ] = "Signed"
425
- data ['RecipientStatuses' ][0 ]['Signed' ] = "2014-10-06" \
426
- "T01:10:03.000012"
427
- self .send_signature_callback (data )
428
- signature .refresh_from_db ()
429
- self .assertEqual (signature .status , 'sent' )
430
- self .assertEqual (signature .signers .get (signing_order = 1 ).status ,
431
- 'completed' )
432
- self .assertEqual (signature .signers .get (signing_order = 2 ).status ,
433
- 'sent' )
434
- # Last recipient signs.
435
- data ['RecipientStatuses' ][1 ]['Status' ] = "Signed"
436
- data ['RecipientStatuses' ][1 ]['Signed' ] = "2014-10-06" \
437
- "T01:10:04.000012"
438
- data ['Status' ] = "Completed"
439
- data ['Completed' ] = "2014-10-06T01:10:04.000012"
440
- self .send_signature_callback (data )
441
- signature .refresh_from_db ()
442
- self .assertEqual (signature .status , 'completed' )
443
- self .assertEqual (signature .signers .get (signing_order = 1 ).status ,
444
- 'completed' )
445
- self .assertEqual (signature .signers .get (signing_order = 2 ).status ,
446
- 'completed' )
447
- # But we could also have received "decline" callback.
448
- del data ['Completed' ]
449
- del data ['RecipientStatuses' ][1 ]['Signed' ]
450
- data ['RecipientStatuses' ][1 ]['Status' ] = "Declined"
451
- data ['RecipientStatuses' ][1 ]['Declined' ] = "2014-10-06" \
452
- "T01:10:05.000012"
453
- data ['Status' ] = "Declined"
454
- data ['Declined' ] = "2014-10-06T01:10:05.000012"
455
- self .send_signature_callback (data )
456
- signature .refresh_from_db ()
457
- self .assertEqual (signature .status , 'declined' )
458
- self .assertEqual (signature .signers .get (signing_order = 1 ).status ,
459
- 'completed' )
460
- self .assertEqual (signature .signers .get (signing_order = 2 ).status ,
461
- 'declined' )
462
- self .assertEqual (signature .signers .get (signing_order = 2 ).status_details ,
463
- u'' )
464
- # Make sure we handle optional "decline reason" as well.
465
- data ['RecipientStatuses' ][1 ]['DeclineReason' ] = "Do not sign a test!"
466
- self .send_signature_callback (data )
467
- signature .refresh_from_db ()
468
- self .assertEqual (signature .status , 'declined' )
469
- self .assertEqual (signature .signers .get (signing_order = 2 ).status_details ,
470
- u'Do not sign a test!' )
471
-
472
330
473
331
class SignatureTemplateFunctionalTestCase (SignatureFunctionalTestCase ):
474
332
"""Functional test suite for signature template workflow."""
@@ -491,7 +349,6 @@ def create_signature(self):
491
349
'signers-1-email' : u'paul@example.com' ,
492
350
'template_id' : template_id ,
493
351
'title' : u'A very simple PDF document' ,
494
- 'callback_url' : u'http://tech.novapost.fr' ,
495
352
}
496
353
response = self .client .post (url , data )
497
354
self .assertEqual (response .status_code , 302 )
@@ -517,11 +374,9 @@ def test_setup_explicit(self):
517
374
'app_token' : 'some-token' ,
518
375
'timeout' : 300.0 ,
519
376
}
520
- backend = django_docusign .DocuSignBackend (
521
- use_callback = True , ** explicit_options )
377
+ backend = django_docusign .DocuSignBackend (** explicit_options )
522
378
for key , value in explicit_options .items ():
523
379
self .assertEqual (getattr (backend .docusign_client , key ), value )
524
- self .assertTrue (backend .use_callback )
525
380
526
381
def test_setup_settings (self ):
527
382
"""DocuSignBackend uses settings.DOCUSIGN_*."""
@@ -539,7 +394,6 @@ def test_setup_settings(self):
539
394
for key , value in overrides .items ():
540
395
key = key .lower ()[len ('DOCUSIGN_' ):]
541
396
self .assertEqual (getattr (backend .docusign_client , key ), value )
542
- self .assertFalse (backend .use_callback )
543
397
544
398
def test_setup_priority (self ):
545
399
"""Explicit arguments have priority over settings."""
0 commit comments