示例#1
0
    def test_api_call(self):
        """Assert Address calls google API and get address"""
        a = Address(raw="Rua Teçaindá, 81, SP", raw2="Casa")
        a.save()

        a = Address.objects.get(pk=a.pk)
        self.assertTrue(a.raw == "Rua Teçaindá, 81, SP")
        self.assertTrue(a.raw2 == "Casa")
        self.assertTrue(a.address_line ==
                        "Rua Teçaindá, 81, Pinheiros, São Paulo, SP, Brazil")
        self.assertTrue(a.__str__() ==
                        "Rua Teçaindá, 81, Pinheiros, São Paulo, SP, Brazil")
        self.assertTrue(a.lat)
        self.assertTrue(a.lng)

        a.raw = "Rua Capote Valente, 701, SP"
        a.save()
        a = Address.objects.get(pk=a.pk)
        self.assertTrue(a.raw == "Rua Capote Valente, 701, SP")
        self.assertTrue(a.raw2 == "Casa")
        self.assertTrue(
            a.address_line ==
            "Rua Capote Valente, 701, Pinheiros, São Paulo, SP, Brazil")
        self.assertTrue(a.__str__(
        ) == "Rua Capote Valente, 701, Pinheiros, São Paulo, SP, Brazil")
        self.assertTrue(a.lat)
        self.assertTrue(a.lng)

        a.address_line = None
        self.assertTrue(a.__str__() == "")
示例#2
0
    def test_api_call_2(self):
        a = Address(raw2="Casa")
        a.raw = "Rua Capote Valente, 701, SP"
        a.save()
        a = Address.objects.get(pk=a.pk)
        self.assertTrue(a.raw == "Rua Capote Valente, 701, SP")
        self.assertTrue(a.raw2 == "Casa")
        self.assertTrue(
            a.address_line ==
            "Rua Capote Valente, 701, Pinheiros, São Paulo, SP, Brazil")
        self.assertTrue(a.__str__(
        ) == "Rua Capote Valente, 701, Pinheiros, São Paulo, SP, Brazil")
        self.assertTrue(a.lat)
        self.assertTrue(a.lng)

        a.address_line = None
        self.assertTrue(a.__str__() == "")