Skip to content

Commit fbd0770

Browse files
fixed some tests
1 parent 7dd640c commit fbd0770

1 file changed

Lines changed: 40 additions & 48 deletions

File tree

app/tests/tests.py

Lines changed: 40 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919

2020
class Testing(unittest.TestCase):
21+
TEMPLATE_ID = ""
22+
2123
@classmethod
2224
def setUpClass(cls):
2325
results = TestHelper.authenticate()
@@ -64,8 +66,8 @@ def test_embedded_signing_make_envelope(self):
6466
signers=[Signer(
6567
email=DS_CONFIG["signer_email"],
6668
name=DS_CONFIG["signer_name"],
67-
recipient_id=1,
68-
routing_order=1,
69+
recipient_id='1',
70+
routing_order='1',
6971
client_user_id=DATA["signer_client_id"],
7072
tabs=Tabs(
7173
sign_here_tabs=[SignHere(
@@ -85,7 +87,6 @@ def test_embedded_signing_make_envelope(self):
8587
)]
8688
)
8789

88-
8990
expected = {
9091
"emailSubject": "Please sign this document",
9192
"documents": [
@@ -123,7 +124,6 @@ def test_embedded_signing_make_envelope(self):
123124

124125
self.assertIsNotNone(results)
125126
self.assertEqual(results, envelope)
126-
# self.assertEqual(results, expected)
127127

128128
def test_sign_via_email(self):
129129
envelope_args = {
@@ -155,31 +155,31 @@ def test_sign_via_email_make_envelope(self):
155155
}
156156

157157
html_document = f"""
158-
<!DOCTYPE html>
159-
<html>
160-
<head>
161-
<meta charset="UTF-8">
162-
</head>
163-
<body style="font-family:sans-serif;margin-left:2em;">
164-
<h1 style="font-family: "Trebuchet MS", Helvetica, sans-serif;
165-
color: darkblue;margin-bottom: 0;">World Wide Corp</h1>
166-
<h2 style="font-family: "Trebuchet MS", Helvetica, sans-serif;
167-
margin-top: 0px;margin-bottom: 3.5em;font-size: 1em;
168-
color: darkblue;">Order Processing Division</h2>
169-
<h4>Ordered by {DS_CONFIG["signer_name"]}</h4>
170-
<p style="margin-top:0em; margin-bottom:0em;">Email: {DS_CONFIG["signer_email"]}</p>
171-
<p style="margin-top:0em; margin-bottom:0em;">Copy to: {DATA["cc_name"]}, {DATA["cc_email"]}</p>
172-
<p style="margin-top:3em;">
173-
Candy bonbon pastry jujubes lollipop wafer biscuit biscuit. Topping brownie sesame snaps sweet roll pie.
174-
Croissant danish biscuit soufflé caramels jujubes jelly. Dragée danish caramels lemon drops dragée.
175-
Gummi bears cupcake biscuit tiramisu sugar plum pastry. Dragée gummies applicake pudding liquorice.
176-
Donut jujubes oat cake jelly-o.
177-
Dessert bear claw chocolate cake gummies lollipop sugar plum ice cream gummies cheesecake.
178-
</p>
179-
<!-- Note the anchor tag for the signature field is in white. -->
180-
<h3 style="margin-top:3em;">Agreed: <span style="color:white;">**signature_1**/</span></h3>
181-
</body>
182-
</html>
158+
<!DOCTYPE html>
159+
<html>
160+
<head>
161+
<meta charset="UTF-8">
162+
</head>
163+
<body style="font-family:sans-serif;margin-left:2em;">
164+
<h1 style="font-family: "Trebuchet MS", Helvetica, sans-serif;
165+
color: darkblue;margin-bottom: 0;">World Wide Corp</h1>
166+
<h2 style="font-family: "Trebuchet MS", Helvetica, sans-serif;
167+
margin-top: 0px;margin-bottom: 3.5em;font-size: 1em;
168+
color: darkblue;">Order Processing Division</h2>
169+
<h4>Ordered by {DS_CONFIG["signer_name"]}</h4>
170+
<p style="margin-top:0em; margin-bottom:0em;">Email: {DS_CONFIG["signer_email"]}</p>
171+
<p style="margin-top:0em; margin-bottom:0em;">Copy to: {DATA["cc_name"]}, {DATA["cc_email"]}</p>
172+
<p style="margin-top:3em;">
173+
Candy bonbon pastry jujubes lollipop wafer biscuit biscuit. Topping brownie sesame snaps sweet roll pie.
174+
Croissant danish biscuit soufflé caramels jujubes jelly. Dragée danish caramels lemon drops dragée.
175+
Gummi bears cupcake biscuit tiramisu sugar plum pastry. Dragée gummies applicake pudding liquorice.
176+
Donut jujubes oat cake jelly-o.
177+
Dessert bear claw chocolate cake gummies lollipop sugar plum ice cream gummies cheesecake.
178+
</p>
179+
<!-- Note the anchor tag for the signature field is in white. -->
180+
<h3 style="margin-top:3em;">Agreed: <span style="color:white;">**signature_1**/</span></h3>
181+
</body>
182+
</html>
183183
"""
184184

185185
expected = EnvelopeDefinition(
@@ -193,13 +193,13 @@ def test_sign_via_email_make_envelope(self):
193193
document_id="1"
194194
),
195195
Document(
196-
document_base64=TestHelper.read_as_base64(DATA["test_docx_file"]),
196+
document_base64=TestHelper.read_as_base64(os.path.abspath(DATA["test_docx_file"])),
197197
name="Battle Plan",
198198
file_extension="docx",
199199
document_id="2"
200200
),
201201
Document(
202-
document_base64=TestHelper.read_as_base64(DATA["test_pdf_file"]),
202+
document_base64=TestHelper.read_as_base64(os.path.abspath(DATA["test_pdf_file"])),
203203
name="Lorem Ipsum",
204204
file_extension="pdf",
205205
document_id="3"
@@ -235,17 +235,10 @@ def test_sign_via_email_make_envelope(self):
235235
)
236236
)
237237

238-
self.test_helper = TestHelper()
239-
240-
envelope = Eg002SigningViaEmailController.make_envelope(envelope_args, DATA["test_docx_file"], DATA["test_pdf_file"])
238+
envelope = Eg002SigningViaEmailController.make_envelope(envelope_args, os.path.abspath(DATA["test_docx_file"]), os.path.abspath(DATA["test_pdf_file"]))
241239

242240
self.assertIsNotNone(envelope)
243-
self.assertEquals(envelope.email_subject, expected.email_subject)
244-
self.assertEquals(envelope.status, expected.status)
245-
self.assertEquals(len(envelope.documents), len(expected.documents))
246-
self.assertEquals(envelope.documents, expected.documents)
247-
self.assertEquals(envelope.recipients, expected.recipients)
248-
# self.assertEquals(self.test_helper.delete_none(vars(envelope)), self.test_helper.delete_none(vars(expected)))
241+
self.assertEquals(envelope, expected)
249242

250243
def test_sign_via_email_html_doc(self):
251244
envelope_args = {
@@ -289,7 +282,6 @@ def test_sign_via_email_html_doc(self):
289282
self.assertEqual(document, expected)
290283

291284
def test_create_template(self):
292-
new_template_name = f"{DATA['template_name']}_{int(datetime.datetime.utcnow().timestamp())}"
293285
args = {
294286
"account_id": self.account_id,
295287
"base_path": self.base_path,
@@ -298,7 +290,7 @@ def test_create_template(self):
298290
}
299291

300292
result = Eg008CreateTemplateController.worker(args)
301-
self.template_id = result["template_id"]
293+
Testing.TEMPLATE_ID = result["template_id"]
302294

303295
self.assertIsNotNone(result)
304296
self.assertIsNotNone(result["template_id"])
@@ -441,7 +433,7 @@ def test_use_template(self):
441433
"signer_name": DS_CONFIG["signer_name"],
442434
"cc_email": DATA["cc_email"],
443435
"cc_name": DATA["cc_name"],
444-
"template_id": self.template_id
436+
"template_id": Testing.TEMPLATE_ID
445437
}
446438
args = {
447439
"account_id": self.account_id,
@@ -462,12 +454,12 @@ def test_use_template_make_envelope(self):
462454
"signer_name": DS_CONFIG["signer_name"],
463455
"cc_email": DATA["cc_email"],
464456
"cc_name": DATA["cc_name"],
465-
"template_id": self.template_id
457+
"template_id": Testing.TEMPLATE_ID
466458
}
467459

468460
expected = EnvelopeDefinition(
469461
status="sent",
470-
template_id=self.template_id,
462+
template_id=Testing.TEMPLATE_ID,
471463
template_roles=[
472464
TemplateRole(
473465
email=DS_CONFIG["signer_email"],
@@ -493,7 +485,7 @@ def test_add_doc_to_template(self):
493485
"signer_name": DS_CONFIG["signer_name"],
494486
"cc_email": DATA["cc_email"],
495487
"cc_name": DATA["cc_name"],
496-
"template_id": self.template_id,
488+
"template_id": Testing.TEMPLATE_ID,
497489
"signer_client_id": DATA["signer_client_id"],
498490
"item": DATA["item"],
499491
"quantity": DATA["quantity"],
@@ -518,7 +510,7 @@ def test_add_doc_to_template_make_envelope(self):
518510
"signer_name": DS_CONFIG["signer_name"],
519511
"cc_email": DATA["cc_email"],
520512
"cc_name": DATA["cc_name"],
521-
"template_id": self.template_id,
513+
"template_id": Testing.TEMPLATE_ID,
522514
"signer_client_id": DATA["signer_client_id"],
523515
"item": DATA["item"],
524516
"quantity": DATA["quantity"],
@@ -556,7 +548,7 @@ def test_add_doc_to_template_make_envelope(self):
556548
CompositeTemplate(
557549
composite_template_id="1",
558550
server_templates=[
559-
ServerTemplate(sequence="1", template_id=self.template_id)
551+
ServerTemplate(sequence="1", template_id=Testing.TEMPLATE_ID)
560552
],
561553
inline_templates=[
562554
InlineTemplate(

0 commit comments

Comments
 (0)