Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions certified_builder/build_url_tech_floripa.py

This file was deleted.

9 changes: 3 additions & 6 deletions certified_builder/certified_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from certified_builder.utils.fetch_file_certificate import fetch_file_certificate
from certified_builder.certificates_on_solana import CertificatesOnSolana
from certified_builder.make_qrcode import MakeQRCode
from certified_builder.build_url_tech_floripa import build_url_tech_floripa
from certified_builder.solana_explorer_url import extract_solana_explorer_url

FONT_NAME = os.path.join(os.path.dirname(__file__), "fonts/PinyonScript/PinyonScript-Regular.ttf")
VALIDATION_CODE = os.path.join(os.path.dirname(__file__), "fonts/ChakraPetch/ChakraPetch-SemiBold.ttf")
Expand Down Expand Up @@ -58,11 +58,8 @@ def build_certificates(self, participants: List[Participant]):
}
)

participant.authenticity_verification_url = build_url_tech_floripa(
solana_response=solana_response,
validation_code=participant.formated_validation_code(),
order_id=participant.event.order_id
)
# alteração: agora usamos a função renomeada que apenas extrai o explorer_url
participant.authenticity_verification_url = extract_solana_explorer_url(solana_response=solana_response)

if not participant.authenticity_verification_url:
raise RuntimeError("Failed to get authenticity verification URL from Solana response")
Expand Down
6 changes: 6 additions & 0 deletions certified_builder/solana_explorer_url.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
def extract_solana_explorer_url(solana_response: dict) -> str:
# alteração: função isolada para extrair a URL do explorer da resposta do serviço
explorer_url = solana_response.get("blockchain", {}).get("explorer_url", "")
return explorer_url


14 changes: 14 additions & 0 deletions tests/test_certified_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from models.certificate import Certificate
from models.event import Event
from datetime import datetime
from unittest.mock import patch

@pytest.fixture
def mock_certificate():
Expand Down Expand Up @@ -80,7 +81,20 @@ def test_create_validation_code_image(certified_builder, mock_participant, mock_
def test_build_certificates(certified_builder, mock_participant, mock_certificate_template, mock_logo):
participants = [mock_participant]

# comentário: mock do download de imagens e da resposta do serviço Solana para evitar chamada externa
with patch('certified_builder.utils.fetch_file_certificate.fetch_file_certificate', side_effect=[mock_certificate_template, mock_logo]), \
patch('certified_builder.certified_builder.CertificatesOnSolana.register_certificate_on_solana', return_value={
"status": "encontrado",
"explorer_url": "https://explorer.solana.com/tx/abc123?cluster=devnet",
"certificado": {
"event": "evento de teste",
"uuid": "uuid-123",
"name": "user test",
"email": "user@test.com",
"certificate_code": "ABC-123-XYZ",
"time": "2025-10-31 12:05:38"
}
}), \
patch.object(certified_builder, 'save_certificate') as mock_save:

certified_builder.build_certificates(participants)
Expand Down
Loading