Ejemplo n.º 1
0
def test_basic_contract(user):
    contract = Contract(user=user, number=9911222777, regional_direction=10)

    assert contract.number == 9911222777
    assert contract.regional_direction.number == 10
    assert contract.posting_cards == []
    assert str(contract) == "9911222777"
    assert repr(contract) == "<Contract number=9911222777>"
Ejemplo n.º 2
0
def test_sanitize_contract_data(user):
    contract = Contract(
        user=user,
        number="9911222777  ",
        regional_direction="   10",
    )
    contract.customer_code = "279311"
    contract.status_code = "A"
    contract.start_date = "2014-05-09 00:00:00-03:00"
    contract.end_date = "2018-05-16 00:00:00-03:00"

    assert contract.number == 9911222777
    assert contract.regional_direction.number == 10
    assert contract.customer_code == 279311
    assert contract.status_code == "A"
    assert contract.start_date == datetime(2014, 5, 9, 0, 0, tzinfo=timezone(timedelta(hours=-3)))
    assert contract.end_date == datetime(2018, 5, 16, 0, 0, tzinfo=timezone(timedelta(hours=-3)))
Ejemplo n.º 3
0
def test_sanitize_contract_data(user):
    contract = Contract(user=user,
                        number="9911222777  ",
                        regional_direction="   10")
    contract.customer_code = "279311"
    contract.status_code = "A"
    contract.start_date = "2014-05-09 00:00:00-03:00"
    contract.end_date = "2018-05-16 00:00:00-03:00"

    assert contract.number == 9911222777
    assert contract.regional_direction.number == 10
    assert contract.customer_code == 279311
    assert contract.status_code == "A"
    assert contract.start_date == datetime(2014,
                                           5,
                                           9,
                                           0,
                                           0,
                                           tzinfo=timezone(
                                               timedelta(hours=-3)))
    assert contract.end_date == datetime(2018,
                                         5,
                                         16,
                                         0,
                                         0,
                                         tzinfo=timezone(timedelta(hours=-3)))
Ejemplo n.º 4
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)