Exemplo n.º 1
0
    def test_geocode_with_citycode(self):

        self.person.location_citycode = "21058"
        self.person.save()
        geocode_france(self.person)

        self.assertIsNotNone(self.person.coordinates)
        self.assertEqual(self.person.coordinates_type,
                         LocationMixin.COORDINATES_CITY)
        self.assertEqual(self.person.location_city, "Belan-sur-Ource")
Exemplo n.º 2
0
    def test_geocode_with_citycode(self):

        self.person.location_citycode = "00002"
        self.person.save()
        geocode_france(self.person)

        self.assertIsNotNone(self.person.coordinates)
        self.assertEqual(self.person.coordinates_type,
                         LocationMixin.COORDINATES_CITY)
        self.assertEqual(self.person.location_city, "la Seconde")
Exemplo n.º 3
0
 def test_geocode_invalide_postcode(self):
     """
         Test le fonctionement avec un seulement un code postale invalide
     :return:
     """
     self.person.location_zip = "45621"
     self.person.save()
     geocode_france(self.person)
     self.assertIsNone(self.person.coordinates)
     self.assertEqual(self.person.coordinates_type,
                      LocationMixin.COORDINATES_NOT_FOUND)
Exemplo n.º 4
0
    def test_geocode_ban_district_post_code(self):
        """
            Test le fonctionement avec les arrondissement des grande ville qui ont un code INSEE pour chaque arrondissement
        :return:
        """
        self.person.location_zip = "13005"
        self.person.save()

        geocode_france(self.person)
        self.assertEqual(self.person.location_citycode, "13205")
        self.assertIsNotNone(self.person.coordinates)
        self.assertEqual(self.person.coordinates_type,
                         LocationMixin.COORDINATES_DISTRICT)
Exemplo n.º 5
0
    def test_geocode_ban_only_zip_one_result(self):
        """
            Test le fonctionement avec seulement un code postale mais un seul resultat de commune
        :return:
        """
        self.person.location_zip = "21000"
        self.person.save()

        geocode_france(self.person)
        self.assert_(self.person.location_citycode, "21231")
        self.assertIsNotNone(self.person.coordinates)
        self.assert_(self.person.coordinates_type,
                     LocationMixin.COORDINATES_EXACT)
Exemplo n.º 6
0
    def test_geocode_ban_only_zip(self):
        """
            On a une requête avec de multiples municipalités. On ne peut pas determiner de citycode
        :return:
        """

        self.person.location_zip = "21570"
        self.person.save()

        geocode_france(self.person)
        self.assertEqual(self.person.location_citycode, "")
        self.assertIsNotNone(self.person.coordinates)
        self.assertEqual(self.person.coordinates_type,
                         LocationMixin.COORDINATES_UNKNOWN_PRECISION)
Exemplo n.º 7
0
    def test_geocode_ban_complete_address(self):
        """
            Test le fonctionnement avec une adresse complète
        :return:
        """
        self.person.location_address1 = "14 rue du lavoir de la grande pierre"
        self.person.location_city = "Antony"
        self.person.location_zip = "92160"
        self.person.save()

        geocode_france(self.person)
        self.assertEqual(self.person.location_citycode, "92002")
        self.assertIsNotNone(self.person.coordinates)
        self.assertEqual(self.person.coordinates_type,
                         LocationMixin.COORDINATES_EXACT)