Skip to content

Commit

Permalink
Changes to send S/N on sender number
Browse files Browse the repository at this point in the history
  • Loading branch information
francielly.silva authored and lucaspolo committed Dec 18, 2020
1 parent 06b9b00 commit 942e77d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
12 changes: 6 additions & 6 deletions correios/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,17 +421,17 @@ def _get_sender_info_element(self, posting_list):
xml_utils.SubElement(sender_info, "numero_contrato", text=str(contract.number))
xml_utils.SubElement(sender_info, "numero_diretoria", text=str(contract.regional_direction_number))
xml_utils.SubElement(sender_info, "codigo_administrativo", text=str(posting_card.administrative_code))
xml_utils.SubElement(sender_info, "nome_remetente", cdata=sender.name)
xml_utils.SubElement(sender_info, "logradouro_remetente", cdata=sender.street)
xml_utils.SubElement(sender_info, "numero_remetente", cdata=sender.number)
xml_utils.SubElement(sender_info, "complemento_remetente", cdata=sender.complement)
xml_utils.SubElement(sender_info, "bairro_remetente", cdata=sender.neighborhood)
xml_utils.SubElement(sender_info, "nome_remetente", cdata=str(sender.name))
xml_utils.SubElement(sender_info, "logradouro_remetente", cdata=str(sender.street))
xml_utils.SubElement(sender_info, "numero_remetente", cdata=str(sender.number) or 'S/n')
xml_utils.SubElement(sender_info, "complemento_remetente", cdata=str(sender.complement))
xml_utils.SubElement(sender_info, "bairro_remetente", cdata=str(sender.neighborhood))
xml_utils.SubElement(sender_info, "cep_remetente", cdata=str(sender.zip_code))
xml_utils.SubElement(sender_info, "cidade_remetente", cdata=str(sender.city)[:30])
xml_utils.SubElement(sender_info, "uf_remetente", cdata=str(sender.state))
xml_utils.SubElement(sender_info, "telefone_remetente", cdata=sender.phone.short)
xml_utils.SubElement(sender_info, "fax_remetente", cdata="")
xml_utils.SubElement(sender_info, "email_remetente", cdata=sender.email)
xml_utils.SubElement(sender_info, "email_remetente", cdata=str(sender.email))
return sender_info

def _get_shipping_label_element(self, shipping_label: ShippingLabel):
Expand Down
11 changes: 11 additions & 0 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,17 @@ def test_sn_informed_on_receiver_number(posting_list, shipping_label):
assert b"<numero_end_destinatario>S/N</numero_end_destinatario>" in xml


@pytest.mark.skipif(not correios, reason="API Client support disabled")
def test_sn_informed_on_sender_number(posting_list, shipping_label):
shipping_label.sender.raw_number = ''
posting_list.add_shipping_label(shipping_label)
serializer = correios.PostingListSerializer()
document = serializer.get_document(posting_list)
serializer.validate(document)
xml = serializer.get_xml(document)
assert b"<numero_remetente><![CDATA[S/N]]></numero_remetente>" in xml


@pytest.mark.skipif(not correios, reason="API Client support disabled")
def test_fail_empty_posting_list_serialization(posting_list):
serializer = correios.PostingListSerializer()
Expand Down

0 comments on commit 942e77d

Please sign in to comment.