import cv2
from face_matcher.preprocessing import face_detector, face_aligner, preprocessor


def testFaceDetector():
    """ "Tests FaceDetector class"""
    image = cv2.imread("test_data/highfi_image.png")
    detector = face_detector.FaceDetector()
    assert detector.testSelf(image)


def testFaceAlignment():
    """ "Tests FaceAlignment class"""
    aligner = face_aligner.FaceAligner()
    image = cv2.imread("test_data/left_tilt.png")
    assert aligner.testSelf(
        image,
        keypoints=[
            [0.5631144, 0.34028644],
            [0.70840387, 0.47436738],
            [0.52618527, 0.51158406],
            [0.47044936, 0.58288305],
            [0.50345159, 0.30345638],
            [0.8063499, 0.57370494],
        ],
        precomputed_hash=-6511886545410846223,
    )

    image = cv2.imread("test_data/right_tilt.png")
    assert aligner.testSelf(
        image,
        keypoints=[
            [0.37647969, 0.50739978],
            [0.53684009, 0.33649413],
            [0.55076222, 0.46186412],
            [0.63473238, 0.57365344],
            [0.31919399, 0.6733335],
            [0.63431779, 0.3471874],
        ],
        precomputed_hash=-7149088185215506427,
    )


def test_preprocessor():
    prepro = preprocessor.Preprocessor()
    assert prepro.testSelf()
