Esempio n. 1
0
    def test7_save_existing_location_add_country(self):
        print Colorizer.LightPurple(
            '\n[TEST PROFILE LOCATION] assert should add country aliases')

        Location.create(**self.location)

        location = Location.objects.filter(lat=self.location['lat'],
                                           lng=self.location['lng'])

        print location[0].country_alias

        self.assertEqual(
            len(location), 1,
            'Save Location with same lat an lng and different name, should update existing location'
        )
def add_location_to_user(user):
    try:
        if user.profile.place:
            place = json.loads(user.profile.place)

            location = Location.create(
                lat=repr(place['lat']),
                lng=repr(place['long']),
                city=place['city'],
                state=place['state'] if 'state' in place else '',
                country=place['country'],
                country_short=place['country_short'],
                post_code=place['post_code'] if 'post_code' in place else '',
                city_alias=place['city'] + ',')
            user.profile.location = location
            user.profile.latlong = ','.join(
                [format(place['lat'], '.6f'),
                 format(place['long'], '.6f')])
            user.profile.save()

    except Exception as e:
        print(Colorizer.Red('###############################'))
        print(Colorizer.Red('[ERROR Add location error]'))
        print(Logger.error(e))
        print(Colorizer.Red('###############################'))
    else:
        print(Colorizer.Green('LOCATION OK: ' + user.email))
Esempio n. 3
0
    def test5_add_location_to_profile(self):
        print Colorizer.LightPurple('\n[TEST PROFILE LOCATION] add location')

        location = Location.create(**self.location)

        self.user.profile.location = location
        self.user.profile.save()

        user = User.objects.filter(email=self.user.email)[0]

        self.assertIsNotNone(user.profile.location)
Esempio n. 4
0
 def setUpTestData(cls):
     user = testhelpers.create_test_user()
     cls.user = User.objects.filter(email=user.email)[0]
     cls.location = {
         "city": "Torino",
         "state": "Piemonte",
         "country_short": "IT",
         "country": "Italia",
         "lat": '45.07031200000001',
         "lng": '7.686856499999976'
     }
     location = Location.create(**cls.location)
     cls.user.profile.location = location
     cls.user.profile.save()
     cls.user = User.objects.filter(email=user.email)[0]
Esempio n. 5
0
def add_location_to_user(user):
    try:
        if user.profile.place:
            place = json.loads(user.profile.place)

            location = Location.create(
                lat=repr(place['lat']),
                lng=repr(place['long']),
                city=place['city'],
                state=place['state'],
                country=place['country'],
                country_short=place['country_short'],
                post_code=place['post_code'] if 'post_code' in place else '',
                city_alias=place['city'] + ',')
            user.profile.location = location
            user.profile.save()

    except Exception as e:
        print 'Error 2'
        print e