Ejemplo n.º 1
0
def test_address_number_handling(raw, filtered, number, zip_complement):
    address = Address(
        name="John Doe", street="Rua dos Bobos", city="Vinicius de Moraes", state="RJ", zip_code="12345-678", number=raw
    )
    assert address.filtered_number == filtered
    assert address.number == number
    assert address.zip_complement == zip_complement
Ejemplo n.º 2
0
def test_basic_address():
    address = Address(
        name="John Doe",
        phone="+111555-12345",
        cellphone="+11155-54321",
        email="*****@*****.**",
        street="Rua dos Bobos",
        number="5",
        complement="apto. 3",
        neighborhood="Centro",
        city="Vinicius de Moraes",
        state="RJ",
        zip_code="12345-678",
        latitude="10.0",
        longitude="-10.0",
    )

    assert address.name == "John Doe"
    assert address.phone == "+111555-12345"
    assert address.cellphone == "+11155-54321"
    assert address.email == "*****@*****.**"
    assert address.street == "Rua dos Bobos"
    assert address.number == "5"
    assert address.complement == "apto. 3"
    assert address.neighborhood == "Centro"
    assert address.city == "Vinicius de Moraes"
    assert address.state == "RJ"
    assert address.zip_code == "12345-678"
    assert address.zip_code_display == "12345-678"
    assert address.basic_address == "Rua Dos Bobos, 5 - Apto. 3, Centro"
Ejemplo n.º 3
0
def test_basic_address_only_mandatory_args():
    address = Address(
        name="JOHN DOE",
        street="Rua dos Bobos",
        number="0",
        city="Vinicius de Moraes",
        state="RJ",
        zip_code="12345-678",
    )

    assert address.name == "JOHN DOE"
    assert address.street == "Rua dos Bobos"
    assert address.number == "0"
    assert address.city == "Vinicius de Moraes"
    assert address.state == "RJ"
    assert address.zip_code == "12345-678"
    assert address.email == ""
    assert address.complement == ""
    assert address.neighborhood == ""
    assert address.phone == ""
    assert address.cellphone == ""
    assert address.latitude == Decimal("0.0")
    assert address.longitude == Decimal("0.0")
    assert address.basic_address == "Rua Dos Bobos, 0"
    assert address.label_name == "John Doe"
Ejemplo n.º 4
0
 def converteEnderecoSelecionado (self):
     """ 
     Converte o objeto do model Endereco em um objeto Address compatível com a biblioteca
     do webservice.
     """
     addr = Address(name=self.remetente.nome, street=self.endSelecionado.logradouro, number=self.endSelecionado.numero, complement=self.endSelecionado.complemento, neighborhood=self.endSelecionado.bairro, city=self.endSelecionado.cidade, state=self.endSelecionado.uf, zip_code=self.endSelecionado.cep)
     return addr
Ejemplo n.º 5
0
def test_basic_address_with_neighborhood_without_complement():
    address = Address(
        name="John Doe",
        street="Rua dos Bobos",
        number="5",
        city="Vinicius de Moraes",
        state="RJ",
        zip_code="12345-678",
        neighborhood="Vila Nau",
    )

    assert address.basic_address == "Rua Dos Bobos, 5, Vila Nau"
Ejemplo n.º 6
0
def test_address_label_address():
    address = Address(
        name="John Doe",
        street="RUA dos Bobos",
        number="1234",
        city="Vinicius de Moraes",
        state="RJ",
        zip_code="12345-678",
        neighborhood="VILA Vileza",
        complement="AP 01",
    )

    with warnings.catch_warnings(record=True) as captured_warnings:
        warnings.simplefilter("always")

        assert "Rua" in address.label_address
        assert "Vila" in address.label_address
        assert "1234" in address.label_address
        assert "Ap 01" in address.label_address

        assert len(captured_warnings) == 4
        assert all(w.category == DeprecationWarning for w in captured_warnings)
        assert all("deprecated" in str(w.message) for w in captured_warnings)