"""
Tests for the mock of the target summary endpoint.
"""

from urllib.parse import urljoin

import pytest
import requests
from requests import codes
from requests_mock import GET

from common.constants import ResultCodes
from tests.mock_vws.utils import assert_vws_response
from tests.utils import VuforiaServerCredentials
from vws._request_utils import authorization_header, rfc_1123_date


@pytest.mark.usefixtures('verify_mock_vuforia')
class TestTargetSummary:
    """
    Tests for the target summary endpoint.
    """

    def test_target_summary(
        self,
        vuforia_server_credentials: VuforiaServerCredentials,
        target_id: str,
    ) -> None:
        """
        A target summary is returned.
        """
        content_type = 'application/json'
        date = rfc_1123_date()
        request_path = '/summary/' + target_id

        authorization_string = authorization_header(
            access_key=vuforia_server_credentials.access_key,
            secret_key=vuforia_server_credentials.secret_key,
            method=GET,
            content=b'',
            content_type=content_type,
            date=date,
            request_path=request_path,
        )

        headers = {
            "Authorization": authorization_string,
            "Date": date,
            'Content-Type': content_type,
        }

        response = requests.request(
            method=GET,
            url=urljoin('https://vws.vuforia.com/', request_path),
            headers=headers,
            data='',
        )

        assert_vws_response(
            response=response,
            status_code=codes.OK,
            result_code=ResultCodes.SUCCESS,
        )

        expected_keys = {
            'status',
            'result_code',
            'transaction_id',
            'database_name',
            'target_name',
            'upload_date',
            'active_flag',
            'tracking_rating',
            'total_recos',
            'current_month_recos',
            'previous_month_recos',
        }

        assert response.json().keys() == expected_keys

        assert response.json()['status'] == 'processing'

@@ -353,43 +353,26 @@
 ort 
-authorization_header, rfc_1123_date
+target_api_request
 %0A%0A%0A@
@@ -713,81 +713,8 @@
 %22%22%22%0A
-        content_type = 'application/json'%0A        date = rfc_1123_date()%0A
     
@@ -769,51 +769,37 @@
     
-authorization_string = authorization_header
+response = target_api_request
 (%0A  
@@ -985,434 +985,33 @@
     
-content_type=content_type,%0A            date=date,%0A            request_path=request_path,%0A        )%0A%0A        headers = %7B%0A            %22Authorization%22: authorization_string,%0A            %22Date%22: date,%0A            'Content-Type': content_type,%0A        %7D%0A%0A        response = requests.request(%0A            method=GET,%0A            url=urljoin('https://vws.vuforia.com/', request_path),%0A            headers=headers,%0A            data=''
+request_path=request_path
 ,%0A  
@@ -1637,8 +1637,245 @@
 essing'%0A
+%0A    @pytest.mark.parametrize('active_flag', %5BTrue, False%5D)%0A    def test_active_flag(%0A        self,%0A        vuforia_server_credentials: VuforiaServerCredentials,%0A        target_id: str,%0A    ) -%3E None:%0A        %22%22%22%0A        XXX%0A        %22%22%22%0A

Simplify request