Пример #1
0
def test_close_posting_list(client, posting_card, posting_list: PostingList,
                            shipping_label: ShippingLabel):
    shipping_label.posting_card = posting_card
    posting_list.add_shipping_label(shipping_label)
    posting_list = client.close_posting_list(posting_list, posting_card)
    assert posting_list.number is not None
    assert posting_list.closed
Пример #2
0
def test_fail_closed_posting_list_serialization(posting_list: PostingList,
                                                shipping_label):
    posting_list.add_shipping_label(shipping_label)
    posting_list.close_with_id(number=12345)

    serializer = correios.PostingListSerializer()
    with pytest.raises(PostingListSerializerError):
        serializer.get_document(posting_list)
Пример #3
0
def test_render_all_posting_docs(posting_list: PostingList, posting_card: PostingCard):
    posting_list.close_with_id(number=12345)
    shipping_labels_renderer = PostingReportPDFRenderer()
    shipping_labels = [ShippingLabelFactory.build(posting_card=posting_card) for _ in range(35)]
    for shipping_label in shipping_labels:
        posting_list.add_shipping_label(shipping_label)
    shipping_labels_renderer.set_posting_list(posting_list)
    pdf = shipping_labels_renderer.render()
    assert bytes(pdf).startswith(b"%PDF-1.4")
Пример #4
0
def test_render_all_posting_docs(posting_list: PostingList, posting_card: PostingCard):
    posting_list.close_with_id(number=12345)
    shipping_labels_renderer = PostingReportPDFRenderer()
    shipping_labels = [ShippingLabelFactory.build(posting_card=posting_card) for _ in range(35)]
    for shipping_label in shipping_labels:
        posting_list.add_shipping_label(shipping_label)
    shipping_labels_renderer.set_posting_list(posting_list)
    pdf = shipping_labels_renderer.render()
    assert bytes(pdf).startswith(b"%PDF-1.4")
Пример #5
0
    def fecharPLP (self):
        """ Fecha a PLP e a envia para o servidor, tornando-a uma lista de postagem """
        # Conexão com o webservice
        env = SigepEnvironment.objects.get(ativo=True)
        cliente = correios.Correios(username=env.usuario, password=env.senha, environment=env.ambiente)

        # Cria os objetos necessários para o fechamento da PLP
        cartao = CartaoPostagem.objects.get(ativo=True)
        user = User(env.nomeEmpresa, env.cnpj)
        contract = Contract(user, cartao.nroContrato, cartao.codDR)
        postingCard = PostingCard(contract, cartao.nroCartao, cartao.codAdmin)
        senderAddr = self.converteEnderecoSelecionado()

        # Inicialização da PLP
        plp = PostingList(self.id)
        
        # Inclusão dos objetos postais 
        for op in self.objetosPostais.all():
            sl = ShippingLabel(postingCard, senderAddr, op.converteEnderecoSelecionado(), Servico.objects.first().codigo, op.codRastreamento, 1)
            sl.posting_card = postingCard
            plp.add_shipping_label(sl)
        
        # Fechamento da PLP.
        plp = cliente.close_posting_list(plp,cartao.nroCartao)