def test_should_not_update_cookie_if_cookie_is_none(self): self.request.COOKIES[ settings.GEOIP_COOKIE_NAME] = settings.GEOIP_LOCATION_EMPTY_VALUE storage = LocationCookieStorage(request=self.request, response=HttpResponse()) self.assertFalse( storage._should_update_cookie( new_value=settings.GEOIP_LOCATION_EMPTY_VALUE))
def test_should_update_cookie_if_cookie_is_empty_value(self): storage = LocationCookieStorage(request=self.request, response=HttpResponse()) self.assertTrue( storage._should_update_cookie( new_value=settings.GEOIP_LOCATION_EMPTY_VALUE))
def test_should_update_cookie_if_cookie_is_obsolete(self): self.request.COOKIES[settings.GEOIP_COOKIE_NAME] = 42 storage = LocationCookieStorage(request=self.request, response=HttpResponse()) self.assertTrue(storage._should_update_cookie(new_value=10))
def test_should_not_update_cookie_if_no_location_in_request(self): storage = LocationCookieStorage(request=HttpRequest(), response=HttpResponse()) self.assertFalse(storage._should_update_cookie(new_value=10))
def test_should_update_cookie_if_cookie_doesnt_exist(self): storage = LocationCookieStorage(request=self.request, response=HttpResponse()) self.assertTrue(storage._should_update_cookie(new_value=10))
def test_should_not_update_cookie_if_cookie_is_none(self): self.request.COOKIES[settings.GEOIP_COOKIE_NAME] = None storage = LocationCookieStorage(request=self.request, response=HttpResponse()) self.assertFalse(storage._should_update_cookie(new_value=None))
def test_should_update_cookie_if_cookie_is_empty_value(self): storage = LocationCookieStorage(request=self.request, response=HttpResponse()) self.assertTrue(storage._should_update_cookie(new_value=settings.GEOIP_LOCATION_EMPTY_VALUE))