import pytest
import json

from get_all_tramites import lambda_function
from lambda_handlers.response.wrapper import APIGatewayProxyResult
from lambda_handlers.handlers.http_handler import CORSHeaders

class TestGetTramites:
    @pytest.fixture
    def event(self):
        # Return JSON configuration file
        PATH = r"C:\Users\matia\Desktop\Matias A. Vallejos\Github\Github.Work\miregistro-serverless-app\backend\src\services\tramites-service\src\get-tramites\test\event.json"
        with open(PATH) as f:
            event = json.load(f)
        return json.loads(event["event_get_all"])
    
    @pytest.fixture
    def context(self):
        return {}

    @pytest.fixture
    def headers(self):
        return CORSHeaders('aws-us-east-2', True)
    
    def test_lambda_function_success(self, event, context, headers: CORSHeaders):
        response = lambda_function(event, context)
        assert type(response) == str
        
        response = json.loads(response)
        print(json.dumps(response, indent=4))
        assert response['HTTPStatus'] == 200
        assert response['Headers'] == headers.buildHeaders()