def test_lazy_cookies(client, site): response = client.post("/wtm/lazy/", json.dumps({}), content_type="application/json") data = response.json() assert response.status_code == 200 assert "tags" in data assert "wtm" in response.cookies consent_state = get_consent(response) assert consent_state.get("necessary", "") == "true" assert consent_state.get("preferences", "") == "unset" assert consent_state.get("statistics", "") == "unset" assert consent_state.get("marketing", "") == "false"
def test_required_lazy_cookies(client, site): tag_lazy_necessary() response = client.post("/wtm/lazy/", json.dumps({}), content_type="application/json") data = response.json() assert response.status_code == 200 assert "tags" in data assert len(data["tags"]) == 1 assert "wtm" in response.cookies consent_state = get_consent(response) assert consent_state.get("necessary", "") == "true"
def __init__(self, request, payload=None): self._request = request self._context = Tag.create_context(request) self._payload = payload or {} self._config = TagTypeSettings.all() self._tags = [] from wagtail_tag_manager.utils import get_consent self.consent_state = get_consent(request) self.consent = {} if request: self.define_strategy()
def test_statistics_lazy_cookies(client, site): tag_instant_statistics() tag_lazy_statistics() client.cookies = SimpleCookie({"wtm": ""}) response = client.post("/wtm/lazy/", json.dumps({}), content_type="application/json") data = response.json() assert response.status_code == 200 assert "tags" in data assert len(data["tags"]) == 0 assert "wtm" in response.cookies consent_state = get_consent(response) assert consent_state.get("statistics", "") == "unset"
def get_value(self, request): consent_state = get_consent(request) return consent_state.get(self.key[8:])