add docseal
This commit is contained in:
@@ -14,6 +14,7 @@ def pytest_configure():
|
||||
os.environ['TZ'] = 'America/Sao_Paulo'
|
||||
os.environ['DYNAMODB_PARTITION_KEY'] = PK
|
||||
os.environ['DYNAMODB_SORT_KEY'] = SK
|
||||
os.environ['DOCSEAL_KEY'] = 'gUWhWtYBgTaP8fc1q5GZ6JuUHaZzMgZna6KFBHz3Gzk'
|
||||
os.environ['USER_TABLE'] = PYTEST_TABLE_NAME
|
||||
os.environ['COURSE_TABLE'] = PYTEST_TABLE_NAME
|
||||
os.environ['ORDER_TABLE'] = PYTEST_TABLE_NAME
|
||||
|
||||
24
enrollments-events/tests/events/test_ask_to_sign.py
Normal file
24
enrollments-events/tests/events/test_ask_to_sign.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from aws_lambda_powertools.utilities.typing import LambdaContext
|
||||
|
||||
import events.ask_to_sign as app
|
||||
|
||||
|
||||
def test_ask_to_sign(
|
||||
lambda_context: LambdaContext,
|
||||
):
|
||||
event = {
|
||||
'detail': {
|
||||
'new_image': {
|
||||
'id': 'e249c51b-3e68-42eb-bb4b-20659263ce1c',
|
||||
'cert': {
|
||||
's3_uri': 's3://saladeaula.digital/certs/samples/nr11-operador-de-munck.pdf'
|
||||
},
|
||||
'user': {
|
||||
'name': 'Sérgio R Siqueira',
|
||||
'email': 'sergio@somosbeta.com.br',
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
assert app.lambda_handler(event, lambda_context) # type: ignore
|
||||
BIN
enrollments-events/tests/sample.pdf
Normal file
BIN
enrollments-events/tests/sample.pdf
Normal file
Binary file not shown.
36
enrollments-events/tests/test_docseal.py
Normal file
36
enrollments-events/tests/test_docseal.py
Normal file
@@ -0,0 +1,36 @@
|
||||
import base64
|
||||
import uuid
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from docseal import create_submission_from_pdf
|
||||
|
||||
SUBJECT = '{first_name}, assine seu certificado agora!'
|
||||
MESSAGE = """
|
||||
{first_name},
|
||||
Seu certificado já está pronto e aguardando apenas a sua assinatura digital.
|
||||
|
||||
[👉 Assinar agora.]({{submitter.link}})
|
||||
"""
|
||||
|
||||
|
||||
def test_create_submission_from_pdf():
|
||||
r = MagicMock()
|
||||
|
||||
with patch('docseal.requests.post', r):
|
||||
with open('tests/sample.pdf', 'rb') as f:
|
||||
file = base64.b64encode(f.read())
|
||||
create_submission_from_pdf(
|
||||
str(uuid.uuid4()),
|
||||
file=file.decode('utf-8'),
|
||||
email_message={
|
||||
'subject': SUBJECT.format(first_name='Tiago'),
|
||||
'body': MESSAGE.format(first_name='Tiago'),
|
||||
},
|
||||
submitters=[
|
||||
{
|
||||
'role': 'Aluno',
|
||||
'name': 'Sérgio R Siqueira',
|
||||
'email': 'sergio@somosbeta.com.br',
|
||||
},
|
||||
],
|
||||
)
|
||||
Reference in New Issue
Block a user