<commit_before>"""
Tests for the `Date` header.
"""

from datetime import datetime, timedelta
from typing import Dict, Union
from urllib.parse import urlparse

import pytest
import pytz
import requests
from freezegun import freeze_time
from requests import codes

from mock_vws._constants import ResultCodes
from tests.mock_vws.utils import (
    TargetAPIEndpoint,
    assert_query_success,
    assert_vwq_failure,
    assert_vws_failure,
    assert_vws_response,
    authorization_header,
    rfc_1123_date,
)

_VWS_MAX_TIME_SKEW = timedelta(minutes=5)
_VWQ_MAX_TIME_SKEW = timedelta(minutes=64, seconds=51)
_LEEWAY = timedelta(seconds=10)


@pytest.mark.usefixtures('verify_mock_vuforia')
class TestMissing:
    """
    Tests for what happens when the `Date` header is missing.
    """

    def test_no_date_header(
        self,
        any_endpoint: TargetAPIEndpoint,
    ) -> None:
        """
        A `BAD_REQUEST` response is returned when no `Date` header is given.
        """
        endpoint = any_endpoint
        endpoint_headers = dict(endpoint.prepared_request.headers)
        content = endpoint.prepared_request.body or b''
        assert isinstance(content, bytes)<commit_msg>More sensible time skew<commit_after>"""
Tests for the `Date` header.
"""

from datetime import datetime, timedelta
from typing import Dict, Union
from urllib.parse import urlparse

import pytest
import pytz
import requests
from freezegun import freeze_time
from requests import codes

from mock_vws._constants import ResultCodes
from tests.mock_vws.utils import (
    TargetAPIEndpoint,
    assert_query_success,
    assert_vwq_failure,
    assert_vws_failure,
    assert_vws_response,
    authorization_header,
    rfc_1123_date,
)

_VWS_MAX_TIME_SKEW = timedelta(minutes=5)
_VWQ_MAX_TIME_SKEW = timedelta(minutes=65)
_LEEWAY = timedelta(seconds=10)


@pytest.mark.usefixtures('verify_mock_vuforia')
class TestMissing:
    """
    Tests for what happens when the `Date` header is missing.
    """

    def test_no_date_header(
        self,
        any_endpoint: TargetAPIEndpoint,
    ) -> None:
        """
        A `BAD_REQUEST` response is returned when no `Date` header is given.
        """
        endpoint = any_endpoint
        endpoint_headers = dict(endpoint.prepared_request.headers)
        content = endpoint.prepared_request.body or b''
        assert isinstance(content, bytes)
{'fraction_non_alphanumeric': 0.07518796992481203, 'fraction_numerical': 0.00835421888053467, 'mean_word_length': 3.742574257425743, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4421506', 'n_tokens_mistral': 764, 'n_tokens_neox': 744, 'n_words': 193}