def test_ValidSignatureData(self): subject = HelloSignSignature(base_uri=self.test_uri, title='title', subject='My Subject', message='My Message') when(subject).create(auth=self.auth).then_return({}) subject.add_signer(HelloSigner(email='*****@*****.**', name='Bob Examplar')) subject.add_doc(HelloDoc(file_path='@filename.pdf')) json_data = json.dumps(subject.data()) self.assertEqual(json_data, '{"title": "title", "signers[0][name]": "Bob Examplar", "signers[0][email_address]": "*****@*****.**", "message": "My Message", "subject": "My Subject"}')
def test_SignatureExceptions(self): subject = HelloSignSignature(base_uri=self.test_uri, title='title', subject='My Subject', message='My Message') assert subject.base_uri == self.test_uri self.assertRaises(AttributeError, lambda: subject.create()) subject.add_signer(HelloSigner(**{'email':'*****@*****.**', 'name': 'Bob Examplar'})) self.assertRaises(AttributeError, lambda: subject.create()) subject.add_doc(HelloDoc(file_path='@filename.pdf'))
def test_SignatureSend(self): subject = HelloSignSignature(base_uri=self.test_uri, title='title', subject='My Subject', message='My Message') when(subject).create(auth=self.auth).then_return({}) # Test basic params assert subject.base_uri == self.test_uri assert subject.params['title'] == 'title' assert subject.params['subject'] == 'My Subject' assert subject.params['message'] == 'My Message' # Test incorrect signers and doc types self.assertRaises(Exception, lambda: subject.add_signer({})) self.assertRaises(Exception, lambda: subject.add_doc({})) # add correct signers and doc types and test the lengths increase subject.add_signer(HelloSigner(**{'email':'*****@*****.**', 'name': 'Bob Examplar'})) subject.add_doc(HelloDoc(file_path='@filename.pdf')) self.assertEqual(len(subject.signers), 1) self.assertEqual(len(subject.docs), 1) response = subject.create(auth=self.auth) self.assertEqual(response, {})
def test_InValidSignatureData(self): subject = HelloSignSignature(base_uri=self.test_uri, title='title', subject='My Subject', message='My Message') when(subject).create(auth=self.auth).then_return({}) self.assertRaises(Exception, lambda: subject.add_signer(HelloSigner(**{'email':'bob_no_email'}))) self.assertRaises(Exception, lambda: subject.add_doc(HelloDoc(**{'noob': ''})))