# pylint: disable=too-many-locals


from risc_generator import Protections, FPQ1Contract
from tests.domain.contract.contract_base import ContractTestBase

include = "include"


class ContractCertificatesTest(ContractTestBase):
    def setUp(self) -> None:
        self.maxDiff = None

    def test_givenAFRContract_whenGenerateCertificatesText_thenReturnProperFRText(self):
        a_protections = Protections(protections=self.a_dict_of_protections.copy())

        fpq1_contract = FPQ1Contract(
            client_number=self.a_client_number,
            contract_start_date=self.a_contract_start_date,
            insuree=self.a_insuree,
            vehicle=self.a_vehicle,
            payment_method=self.a_pre_authorize_payment_method,
            protections=a_protections,
            premium=self.a_premium_mock,
            financing=self.a_creditor,
            locale=self.a_fr_locale,
        )

        actual = fpq1_contract.generate_certificates_text()

        a_start_date = "2022-02-01"  # See self.a_contract_start_date
        a_contract_end_date = "2023-02-01"  # 1 year later
        a_claims_phone_number = "098 765-4321"
        a_claims_phone_number_1_800 = "1 800 765-4321"
        a_general_phone_number_1_800 = "1 800 123-4567"
        a_policy_number = "1234567-001"
        a_insuree_name = "A Name"
        a_insuree_address = "An address\nA city, QC, A1A 1A1"
        an_insured_car = "AMaker AModel 2020 1234567890"
        a_website = "assureur.ca"
        a_insurer_name = "Assureur"
        a_new_page = "<###NEW_PAGE###>"

        expected = (
            "Les certiﬁcats d'assurance du véhicule assuré peuvent maintenant être téléchargés dans l'application "
            "Wallet de Apple. Détails au verso.\n"
            f"VOICI VOS DEUX CERTIFICATS D'ASSURANCE POUR LE VÉHICULE ASSURÉ\n"
            f"NUMÉRO DE POLICE / POLICY NUMBER\n\n"
            f"{a_policy_number}\n"
            f"{a_insuree_name}\n"
            f"{a_insuree_address}\n"
            f"VÉHICULE ASSURÉ / INSURED VEHICLE\n"
            f"{an_insured_car}\n"
            f"DURÉE DU CONTRAT DU "
            f"{a_start_date} AU {a_contract_end_date}\n"
            f"POLICY PERIOD FROM An/Yr M J/D TO An/Yr M J/D\n"
            f"Vous voulez déclarer un sinistre?\n"
            f"Communiquez avec nous.\n"
            f"Service des sinistres 7 jours/24h :\n"
            f"Local: {a_claims_phone_number}\n"
            f"Sans frais : {a_claims_phone_number_1_800}\n"
            f"Service à la clientèle\n"
            f"Sans frais :{a_general_phone_number_1_800}\n"
            f"NUMÉRO DE POLICE / POLICY NUMBER\n\n"
            f"{a_policy_number}\n"
            f"{a_insuree_name}\n"
            f"{a_insuree_address}\n"
            f"VÉHICULE ASSURÉ / INSURED VEHICLE\n"
            f"{an_insured_car}\n"
            f"DURÉE DU CONTRAT DU "
            f"{a_start_date} AU {a_contract_end_date}\n"
            f"POLICY PERIOD FROM An/Yr M J/D TO An/Yr M J/D\n"
            f"Vous voulez déclarer un sinistre?\n"
            f"Communiquez avec nous.\n"
            f"Service des sinistres 7 jours/24h :\n"
            f"Local: {a_claims_phone_number}\n"
            f"Sans frais : {a_claims_phone_number_1_800}\n"
            f"Service à la clientèle\n"
            f"Sans frais :{a_general_phone_number_1_800}\n\n"
            f"{a_new_page}\n"
            "CERTIFICATS D'ASSURANCE RESPONABILITÉ AUTOMOBILE\n"
            "CONSERVER AVEC VOTRE PERMIS DE CONDUIRE\n"
            f"Pour télécharger vos certiﬁcats dans l'application Wallet (disponible seulement sur iPhone) :\n"
            f"\t1. Connectez-vous à Espace client à partir de votre iPhone, au {a_website}/espaceclient.\n"
            f"\t2. Dans la section Auto, habitation et véhicules de loisirs, cliquez sur « Obtenir "
            f"un certiﬁcat d'assurance », puis sur « Ajouter à Apple Wallet ».\n"
            f"Vous devrez mettre à jour vos certiﬁcats à chaque renouvellement ou modiﬁcation de votre police "
            f"d'assurance en les téléchargeant de nouveau dans l'application Wallet.\n"
            f"{a_insurer_name} ne peut pas garantir l'acceptation des certiﬁcats en format électronique par "
            f"tous les corps policiers. Assurez-vous de toujours en garder une version papier avec vous.\n\n"
            "CERTIFICAT D'ASSURANCE RESPONSABILITÉ AUTOMOBILE\n"
            "Le présent certiﬁcat est assujetti aux dispositions et conditions de la police "
            "d'assurance automobile de l'Assureur.\n"
            "Ce certiﬁcat atteste que la personne susnommée est assurée contre la responsabilité "
            "pour blessures et dommages aux biens découlant de l'usage du véhicule ci-décrit, "
            "conformément aux limites minimales exigées par les lois d'assurance en vigueur dans "
            "chacune des provinces canadiennes.\n"
            "AVERTISSEMENT - Quiconque émet ou présente un tel certiﬁcat comme preuve d'une "
            "police d'assurance responsabilité qui effectivement n'est pas en vigueur, est coupable "
            "d'une infraction passible d'une forte amende et/ou d'emprisonnement et suspension "
            "de son permis.\n"
            "Tout sinistre devrait être rapporté immédiatement.\n\n"
            "CANADA INTER-PROVINCE MOTOR VEHICLE LIABILITY INSURANCE CARD\n"
            "This certiﬁcate is subject to the terms and conditions of the Insurers standard "
            "automobile policy.\n"
            "This certiﬁes that the party named herein is insured against liability for bodily injury and "
            "property damage by reason of the operation of the motor vehicle described herein, for an "
            "amount not less than the statutory minimum requirements of every province of Canada.\n"
            "WARNING - Any person who issues or presents such a certiﬁcate as proof of insurance "
            "when no policy exists is guilty of fraud and liable to a heavy ﬁ ne and/or imprisonment. "
            "His driving permit may also be suspended.\n"
            "All loss should be reported immediately.\n\n"
            "CERTIFICAT D'ASSURANCE RESPONSABILITÉ AUTOMOBILE\n"
            "Le présent certiﬁcat est assujetti aux dispositions et conditions de la police "
            "d'assurance automobile de l'Assureur.\n"
            "Ce certiﬁcat atteste que la personne susnommée est assurée contre la responsabilité "
            "pour blessures et dommages aux biens découlant de l'usage du véhicule ci-décrit, "
            "conformément aux limites minimales exigées par les lois d'assurance en vigueur dans "
            "chacune des provinces canadiennes.\n"
            "AVERTISSEMENT - Quiconque émet ou présente un tel certiﬁcat comme preuve d'une "
            "police d'assurance responsabilité qui effectivement n'est pas en vigueur, est coupable "
            "d'une infraction passible d'une forte amende et/ou d'emprisonnement et suspension "
            "de son permis.\n"
            "Tout sinistre devrait être rapporté immédiatement.\n\n"
            "CANADA INTER-PROVINCE MOTOR VEHICLE LIABILITY INSURANCE CARD\n"
            "This certiﬁcate is subject to the terms and conditions of the Insurers standard "
            "automobile policy.\n"
            "This certiﬁes that the party named herein is insured against liability for bodily injury and "
            "property damage by reason of the operation of the motor vehicle described herein, for an "
            "amount not less than the statutory minimum requirements of every province of Canada.\n"
            "WARNING - Any person who issues or presents such a certiﬁcate as proof of insurance "
            "when no policy exists is guilty of fraud and liable to a heavy ﬁ ne and/or imprisonment. "
            "His driving permit may also be suspended.\n"
            "All loss should be reported immediately.\n\n"
            f"{a_new_page}\n"
        )

        self.assertEqual(expected, actual)

    def test_givenAFRContractWithFAQ27_whenGenerateCertificatesText_thenReturnProperFRText(self):
        protections = self.a_dict_of_protections.copy()
        protections.update({"FAQ27Coverage": include})
        a_protections = Protections(protections=protections)

        fpq1_contract = FPQ1Contract(
            client_number=self.a_client_number,
            contract_start_date=self.a_contract_start_date,
            insuree=self.a_insuree,
            vehicle=self.a_vehicle,
            payment_method=self.a_pre_authorize_payment_method,
            protections=a_protections,
            premium=self.a_premium_mock,
            financing=self.a_creditor,
            locale=self.a_fr_locale,
        )

        actual = fpq1_contract.generate_certificates_text()

        a_start_date = "2022-02-01"  # See self.a_contract_start_date
        a_contract_end_date = "2023-02-01"  # 1 year later
        a_claims_phone_number = "098 765-4321"
        a_claims_phone_number_1_800 = "1 800 765-4321"
        a_general_phone_number_1_800 = "1 800 123-4567"
        a_policy_number = "1234567-001"
        a_insuree_name = "A Name"
        a_insuree_address = "An address\nA city, QC, A1A 1A1"
        an_insured_car = "AMaker AModel 2020 1234567890"
        a_website = "assureur.ca"
        a_insurer_name = "Assureur"
        a_new_page = "<###NEW_PAGE###>"

        expected = (
            "Les certiﬁcats d'assurance du véhicule assuré peuvent maintenant être téléchargés dans l'application "
            "Wallet de Apple. Détails au verso.\n"
            f"F.A.Q. N 27 : VOTRE CERTIFICAT POUR VÉHICULE DE LOCATION\n"
            f"Lors de votre prochaine location d'auto, présentez ce certiﬁcat au locateur pour "
            f"éviter des frais additionnels d'assurance. Il est valide au Canada et aux États-Unis "
            f"jusqu'à concurrence de Détails au verso du certiﬁcat.\n"
            f"NUMÉRO DE POLICE / POLICY NUMBER\n\n"
            f"{a_policy_number}\n"
            f"{a_insuree_name}\n"
            f"{a_insuree_address}\n"
            f"DURÉE DU CONTRAT DU "
            f"{a_start_date} AU {a_contract_end_date}\n"
            f"POLICY PERIOD FROM An/Yr M J/D TO An/Yr M J/D\n"
            f"IMPORTANT\n"
            f"AU BESOIN, VEUILLEZ PRÉSENTER CE CERTIFICAT À VOTRE AGENCE DE LOCATION DE VOITURES\n"
            f"IF NECESSARY, PLEASE PRESENT THIS CERTIFICATE TO YOUR AUTOMOBILE RENTAL AGENCY\n"
            f"Vous voulez déclarer un sinistre?\n"
            f"Communiquez avec nous.\n"
            f"Service des sinistres 7 jours/24h :\n"
            f"Local: {a_claims_phone_number}\n"
            f"Sans frais : {a_claims_phone_number_1_800}\n"
            f"Service à la clientèle\n"
            f"Sans frais :{a_general_phone_number_1_800}\n\n"
            f"VOICI VOS DEUX CERTIFICATS D'ASSURANCE POUR LE VÉHICULE ASSURÉ\n"
            f"NUMÉRO DE POLICE / POLICY NUMBER\n\n"
            f"{a_policy_number}\n"
            f"{a_insuree_name}\n"
            f"{a_insuree_address}\n"
            f"VÉHICULE ASSURÉ / INSURED VEHICLE\n"
            f"{an_insured_car}\n"
            f"DURÉE DU CONTRAT DU "
            f"{a_start_date} AU {a_contract_end_date}\n"
            f"POLICY PERIOD FROM An/Yr M J/D TO An/Yr M J/D\n"
            f"Vous voulez déclarer un sinistre?\n"
            f"Communiquez avec nous.\n"
            f"Service des sinistres 7 jours/24h :\n"
            f"Local: {a_claims_phone_number}\n"
            f"Sans frais : {a_claims_phone_number_1_800}\n"
            f"Service à la clientèle\n"
            f"Sans frais :{a_general_phone_number_1_800}\n"
            f"NUMÉRO DE POLICE / POLICY NUMBER\n\n"
            f"{a_policy_number}\n"
            f"{a_insuree_name}\n"
            f"{a_insuree_address}\n"
            f"VÉHICULE ASSURÉ / INSURED VEHICLE\n"
            f"{an_insured_car}\n"
            f"DURÉE DU CONTRAT DU "
            f"{a_start_date} AU {a_contract_end_date}\n"
            f"POLICY PERIOD FROM An/Yr M J/D TO An/Yr M J/D\n"
            f"Vous voulez déclarer un sinistre?\n"
            f"Communiquez avec nous.\n"
            f"Service des sinistres 7 jours/24h :\n"
            f"Local: {a_claims_phone_number}\n"
            f"Sans frais : {a_claims_phone_number_1_800}\n"
            f"Service à la clientèle\n"
            f"Sans frais :{a_general_phone_number_1_800}\n\n"
            f"{a_new_page}\n"
            "CERTIFICATS D'ASSURANCE RESPONABILITÉ AUTOMOBILE\n"
            "CONSERVER AVEC VOTRE PERMIS DE CONDUIRE\n"
            f"Pour télécharger vos certiﬁcats dans l'application Wallet (disponible seulement sur iPhone) :\n"
            f"\t1. Connectez-vous à Espace client à partir de votre iPhone, au {a_website}/espaceclient.\n"
            f"\t2. Dans la section Auto, habitation et véhicules de loisirs, cliquez sur « Obtenir "
            f"un certiﬁcat d'assurance », puis sur « Ajouter à Apple Wallet ».\n"
            f"Vous devrez mettre à jour vos certiﬁcats à chaque renouvellement ou modiﬁcation de votre police "
            f"d'assurance en les téléchargeant de nouveau dans l'application Wallet.\n"
            f"{a_insurer_name} ne peut pas garantir l'acceptation des certiﬁcats en format électronique par "
            f"tous les corps policiers. Assurez-vous de toujours en garder une version papier avec vous.\n\n"
            f"CERTIFICAT D'ASSURANCE POUR LOCATION DE VOITURE\n"
            f"(Valide au Canada et aux États-Unis d'Amérique seulement)\n"
            f"Application particulière de l'avenant F.A.Q. 27 : Responsabilité civile du fait de dommages causés à "
            f"des véhicules dont l'assuré désigné n'est pas propriétaire (incluant les véhicules fournis par un "
            f"employeur).\n"
            f"En cas de vol ou d'endommagement d'un véhicule de location, {a_insurer_name} s'engage "
            f"à rembourser, à l'Assuré ou au propriétaire du véhicule, le montant des dommages réellement encourus "
            f"et dont l'Assuré ou son conjoint s'est rendu responsable en vertu d'un contrat de location, le tout "
            f"jusqu'à concurrence de : 75 000 $\n\n"
            f"CAR RENTAL INSURANCE CERTIFICATE\n"
            f"(Valid only in Canada and the United States of America)\n"
            f"Speciﬁc application of Q.E.F. endorsement B 27 : Civil liability resulting from damage caused to "
            f"vehicles of which named insured is not owner (including vehicles provided by an employer).\n"
            f"In the event of theft or damage to a rental vehicle, {a_insurer_name} "
            f"agrees to refund the Insured or the owner of the vehicle, the amount of damage actually "
            f"incurred and for which the Insured or his/her spouse assumes liability under a rental "
            f"contract, in all up to: $75,000\n"
            "CERTIFICAT D'ASSURANCE RESPONSABILITÉ AUTOMOBILE\n"
            "Le présent certiﬁcat est assujetti aux dispositions et conditions de la police "
            "d'assurance automobile de l'Assureur.\n"
            "Ce certiﬁcat atteste que la personne susnommée est assurée contre la responsabilité "
            "pour blessures et dommages aux biens découlant de l'usage du véhicule ci-décrit, "
            "conformément aux limites minimales exigées par les lois d'assurance en vigueur dans "
            "chacune des provinces canadiennes.\n"
            "AVERTISSEMENT - Quiconque émet ou présente un tel certiﬁcat comme preuve d'une "
            "police d'assurance responsabilité qui effectivement n'est pas en vigueur, est coupable "
            "d'une infraction passible d'une forte amende et/ou d'emprisonnement et suspension "
            "de son permis.\n"
            "Tout sinistre devrait être rapporté immédiatement.\n\n"
            "CANADA INTER-PROVINCE MOTOR VEHICLE LIABILITY INSURANCE CARD\n"
            "This certiﬁcate is subject to the terms and conditions of the Insurers standard "
            "automobile policy.\n"
            "This certiﬁes that the party named herein is insured against liability for bodily injury and "
            "property damage by reason of the operation of the motor vehicle described herein, for an "
            "amount not less than the statutory minimum requirements of every province of Canada.\n"
            "WARNING - Any person who issues or presents such a certiﬁcate as proof of insurance "
            "when no policy exists is guilty of fraud and liable to a heavy ﬁ ne and/or imprisonment. "
            "His driving permit may also be suspended.\n"
            "All loss should be reported immediately.\n\n"
            "CERTIFICAT D'ASSURANCE RESPONSABILITÉ AUTOMOBILE\n"
            "Le présent certiﬁcat est assujetti aux dispositions et conditions de la police "
            "d'assurance automobile de l'Assureur.\n"
            "Ce certiﬁcat atteste que la personne susnommée est assurée contre la responsabilité "
            "pour blessures et dommages aux biens découlant de l'usage du véhicule ci-décrit, "
            "conformément aux limites minimales exigées par les lois d'assurance en vigueur dans "
            "chacune des provinces canadiennes.\n"
            "AVERTISSEMENT - Quiconque émet ou présente un tel certiﬁcat comme preuve d'une "
            "police d'assurance responsabilité qui effectivement n'est pas en vigueur, est coupable "
            "d'une infraction passible d'une forte amende et/ou d'emprisonnement et suspension "
            "de son permis.\n"
            "Tout sinistre devrait être rapporté immédiatement.\n\n"
            "CANADA INTER-PROVINCE MOTOR VEHICLE LIABILITY INSURANCE CARD\n"
            "This certiﬁcate is subject to the terms and conditions of the Insurers standard "
            "automobile policy.\n"
            "This certiﬁes that the party named herein is insured against liability for bodily injury and "
            "property damage by reason of the operation of the motor vehicle described herein, for an "
            "amount not less than the statutory minimum requirements of every province of Canada.\n"
            "WARNING - Any person who issues or presents such a certiﬁcate as proof of insurance "
            "when no policy exists is guilty of fraud and liable to a heavy ﬁ ne and/or imprisonment. "
            "His driving permit may also be suspended.\n"
            "All loss should be reported immediately.\n\n"
            f"{a_new_page}\n"
        )

        self.assertEqual(expected, actual)

    def test_givenAENContract_whenGenerateCertificatesText_thenReturnProperENText(self):
        a_protections = Protections(protections=self.a_dict_of_protections.copy())

        fpq1_contract = FPQ1Contract(
            client_number=self.a_client_number,
            contract_start_date=self.a_contract_start_date,
            insuree=self.a_insuree,
            vehicle=self.a_vehicle,
            payment_method=self.a_pre_authorize_payment_method,
            protections=a_protections,
            premium=self.a_premium_mock,
            financing=self.a_creditor,
            locale=self.a_en_locale,
        )

        actual = fpq1_contract.generate_certificates_text()

        a_start_date = "2022-02-01"  # See self.a_contract_start_date
        a_contract_end_date = "2023-02-01"  # 1 year later
        a_claims_phone_number = "098 765-4321"
        a_claims_phone_number_1_800 = "1 800 765-4321"
        a_general_phone_number_1_800 = "1 800 123-4567"
        a_policy_number = "1234567-001"
        a_insuree_name = "A Name"
        a_insuree_address = "An address\nA city, QC, A1A 1A1"
        an_insured_car = "AMaker AModel 2020 1234567890"
        a_website = "assureur.ca"
        a_insurer_name = "Assureur"
        a_new_page = "<###NEW_PAGE###>"

        expected = (
            "The insured vehicle's insurance certificates can now be downloaded into the Apple Wallet application. "
            "Details on the back.\n"
            f"HERE ARE YOUR TWO INSURANCE CERTIFICATES FOR THE INSURED VEHICLE\n"
            f"NUMÉRO DE POLICE / POLICY NUMBER\n\n"
            f"{a_policy_number}\n"
            f"{a_insuree_name}\n"
            f"{a_insuree_address}\n"
            f"VÉHICULE ASSURÉ / INSURED VEHICLE\n"
            f"{an_insured_car}\n"
            f"DURÉE DU CONTRAT DU "
            f"{a_start_date} AU {a_contract_end_date}\n"
            f"POLICY PERIOD FROM An/Yr M J/D TO An/Yr M J/D\n"
            f"Need to file an insurance claim?\n"
            f"Contact us.\n"
            f"Claims Department open 24/7\n"
            f"Local: {a_claims_phone_number}\n"
            f"Toll free: {a_claims_phone_number_1_800}\n"
            f"Customer Service\n"
            f"Toll free:{a_general_phone_number_1_800}\n"
            f"NUMÉRO DE POLICE / POLICY NUMBER\n\n"
            f"{a_policy_number}\n"
            f"{a_insuree_name}\n"
            f"{a_insuree_address}\n"
            f"VÉHICULE ASSURÉ / INSURED VEHICLE\n"
            f"{an_insured_car}\n"
            f"DURÉE DU CONTRAT DU "
            f"{a_start_date} AU {a_contract_end_date}\n"
            f"POLICY PERIOD FROM An/Yr M J/D TO An/Yr M J/D\n"
            f"Need to file an insurance claim?\n"
            f"Contact us.\n"
            f"Claims Department open 24/7\n"
            f"Local: {a_claims_phone_number}\n"
            f"Toll free: {a_claims_phone_number_1_800}\n"
            f"Customer Service\n"
            f"Toll free:{a_general_phone_number_1_800}\n\n"
            f"{a_new_page}\n"
            "CANADA INTER-PROVINCE\n"
            "MOTOR VEHICLE LIABILITY INSURANCE CARD\n"
            "Keep with your driver's licence\n"
            f"To download your certificate into the Apple Wallet application (available on iPhone only):\n"
            f"\t1. Log in to the Client Centre from your phone at {a_website}/clientcentre.\n"
            f"\t2. In the Home, auto and leisure vehicles section, click on ''Get an insurance certificate'', then"
            f"''Add to Apple Wallet''.\n"
            f"You will have to update your certificates at each renewal of, or change to, your insurance policy by "
            f"downloading it again to the Apple Wallet application.\n"
            f"{a_insurer_name} cannot guarantee that the electronic version of the certificates will be accepted by "
            f"all police forces. Make sure you always have a paper version on hand.\n\n"
            "CERTIFICAT D'ASSURANCE RESPONSABILITÉ AUTOMOBILE\n"
            "Le présent certiﬁcat est assujetti aux dispositions et conditions de la police "
            "d'assurance automobile de l'Assureur.\n"
            "Ce certiﬁcat atteste que la personne susnommée est assurée contre la responsabilité "
            "pour blessures et dommages aux biens découlant de l'usage du véhicule ci-décrit, "
            "conformément aux limites minimales exigées par les lois d'assurance en vigueur dans "
            "chacune des provinces canadiennes.\n"
            "AVERTISSEMENT - Quiconque émet ou présente un tel certiﬁcat comme preuve d'une "
            "police d'assurance responsabilité qui effectivement n'est pas en vigueur, est coupable "
            "d'une infraction passible d'une forte amende et/ou d'emprisonnement et suspension "
            "de son permis.\n"
            "Tout sinistre devrait être rapporté immédiatement.\n\n"
            "CANADA INTER-PROVINCE MOTOR VEHICLE LIABILITY INSURANCE CARD\n"
            "This certiﬁcate is subject to the terms and conditions of the Insurers standard "
            "automobile policy.\n"
            "This certiﬁes that the party named herein is insured against liability for bodily injury and "
            "property damage by reason of the operation of the motor vehicle described herein, for an "
            "amount not less than the statutory minimum requirements of every province of Canada.\n"
            "WARNING - Any person who issues or presents such a certiﬁcate as proof of insurance "
            "when no policy exists is guilty of fraud and liable to a heavy ﬁ ne and/or imprisonment. "
            "His driving permit may also be suspended.\n"
            "All loss should be reported immediately.\n\n"
            "CERTIFICAT D'ASSURANCE RESPONSABILITÉ AUTOMOBILE\n"
            "Le présent certiﬁcat est assujetti aux dispositions et conditions de la police "
            "d'assurance automobile de l'Assureur.\n"
            "Ce certiﬁcat atteste que la personne susnommée est assurée contre la responsabilité "
            "pour blessures et dommages aux biens découlant de l'usage du véhicule ci-décrit, "
            "conformément aux limites minimales exigées par les lois d'assurance en vigueur dans "
            "chacune des provinces canadiennes.\n"
            "AVERTISSEMENT - Quiconque émet ou présente un tel certiﬁcat comme preuve d'une "
            "police d'assurance responsabilité qui effectivement n'est pas en vigueur, est coupable "
            "d'une infraction passible d'une forte amende et/ou d'emprisonnement et suspension "
            "de son permis.\n"
            "Tout sinistre devrait être rapporté immédiatement.\n\n"
            "CANADA INTER-PROVINCE MOTOR VEHICLE LIABILITY INSURANCE CARD\n"
            "This certiﬁcate is subject to the terms and conditions of the Insurers standard "
            "automobile policy.\n"
            "This certiﬁes that the party named herein is insured against liability for bodily injury and "
            "property damage by reason of the operation of the motor vehicle described herein, for an "
            "amount not less than the statutory minimum requirements of every province of Canada.\n"
            "WARNING - Any person who issues or presents such a certiﬁcate as proof of insurance "
            "when no policy exists is guilty of fraud and liable to a heavy ﬁ ne and/or imprisonment. "
            "His driving permit may also be suspended.\n"
            "All loss should be reported immediately.\n\n"
            f"{a_new_page}\n"
        )

        self.assertEqual(expected, actual)

    def test_givenAENContractWithFAQ27_whenGenerateCertificatesText_thenReturnProperENText(self):
        protections = self.a_dict_of_protections.copy()
        protections.update({"FAQ27Coverage": include})
        a_protections = Protections(protections=protections)

        fpq1_contract = FPQ1Contract(
            client_number=self.a_client_number,
            contract_start_date=self.a_contract_start_date,
            insuree=self.a_insuree,
            vehicle=self.a_vehicle,
            payment_method=self.a_pre_authorize_payment_method,
            protections=a_protections,
            premium=self.a_premium_mock,
            financing=self.a_creditor,
            locale=self.a_en_locale,
        )

        actual = fpq1_contract.generate_certificates_text()

        a_start_date = "2022-02-01"  # See self.a_contract_start_date
        a_contract_end_date = "2023-02-01"  # 1 year later
        a_claims_phone_number = "098 765-4321"
        a_claims_phone_number_1_800 = "1 800 765-4321"
        a_general_phone_number_1_800 = "1 800 123-4567"
        a_policy_number = "1234567-001"
        a_insuree_name = "A Name"
        a_insuree_address = "An address\nA city, QC, A1A 1A1"
        an_insured_car = "AMaker AModel 2020 1234567890"
        a_website = "assureur.ca"
        a_insurer_name = "Assureur"
        a_new_page = "<###NEW_PAGE###>"

        expected = (
            "The insured vehicle's insurance certificates can now be downloaded into the Apple Wallet application. "
            "Details on the back.\n"
            f"Q.E.F. N 27 : YOUR RENTAL VEHICLE INSURANCE CERTIFICATE\n"
            f"The next time you rent a car, show this certificate to the rental agent to avoid paying additional "
            f"insurance fees. It's valid in Canada and the United States up to a maximum of "
            f"Details on back of the certificate.\n"
            f"NUMÉRO DE POLICE / POLICY NUMBER\n\n"
            f"{a_policy_number}\n"
            f"{a_insuree_name}\n"
            f"{a_insuree_address}\n"
            f"DURÉE DU CONTRAT DU "
            f"{a_start_date} AU {a_contract_end_date}\n"
            f"POLICY PERIOD FROM An/Yr M J/D TO An/Yr M J/D\n"
            f"IMPORTANT\n"
            f"AU BESOIN, VEUILLEZ PRÉSENTER CE CERTIFICAT À VOTRE AGENCE DE LOCATION DE VOITURES\n"
            f"IF NECESSARY, PLEASE PRESENT THIS CERTIFICATE TO YOUR AUTOMOBILE RENTAL AGENCY\n"
            f"Need to file an insurance claim?\n"
            f"Contact us.\n"
            f"Claims Department open 24/7\n"
            f"Local: {a_claims_phone_number}\n"
            f"Toll free: {a_claims_phone_number_1_800}\n"
            f"Customer Service\n"
            f"Toll free:{a_general_phone_number_1_800}\n\n"
            f"HERE ARE YOUR TWO INSURANCE CERTIFICATES FOR THE INSURED VEHICLE\n"
            f"NUMÉRO DE POLICE / POLICY NUMBER\n\n"
            f"{a_policy_number}\n"
            f"{a_insuree_name}\n"
            f"{a_insuree_address}\n"
            f"VÉHICULE ASSURÉ / INSURED VEHICLE\n"
            f"{an_insured_car}\n"
            f"DURÉE DU CONTRAT DU "
            f"{a_start_date} AU {a_contract_end_date}\n"
            f"POLICY PERIOD FROM An/Yr M J/D TO An/Yr M J/D\n"
            f"Need to file an insurance claim?\n"
            f"Contact us.\n"
            f"Claims Department open 24/7\n"
            f"Local: {a_claims_phone_number}\n"
            f"Toll free: {a_claims_phone_number_1_800}\n"
            f"Customer Service\n"
            f"Toll free:{a_general_phone_number_1_800}\n"
            f"NUMÉRO DE POLICE / POLICY NUMBER\n\n"
            f"{a_policy_number}\n"
            f"{a_insuree_name}\n"
            f"{a_insuree_address}\n"
            f"VÉHICULE ASSURÉ / INSURED VEHICLE\n"
            f"{an_insured_car}\n"
            f"DURÉE DU CONTRAT DU "
            f"{a_start_date} AU {a_contract_end_date}\n"
            f"POLICY PERIOD FROM An/Yr M J/D TO An/Yr M J/D\n"
            f"Need to file an insurance claim?\n"
            f"Contact us.\n"
            f"Claims Department open 24/7\n"
            f"Local: {a_claims_phone_number}\n"
            f"Toll free: {a_claims_phone_number_1_800}\n"
            f"Customer Service\n"
            f"Toll free:{a_general_phone_number_1_800}\n\n"
            f"{a_new_page}\n"
            "CANADA INTER-PROVINCE\n"
            "MOTOR VEHICLE LIABILITY INSURANCE CARD\n"
            "Keep with your driver's licence\n"
            f"To download your certificate into the Apple Wallet application (available on iPhone only):\n"
            f"\t1. Log in to the Client Centre from your phone at {a_website}/clientcentre.\n"
            f"\t2. In the Home, auto and leisure vehicles section, click on ''Get an insurance certificate'', then"
            f"''Add to Apple Wallet''.\n"
            f"You will have to update your certificates at each renewal of, or change to, your insurance policy by "
            f"downloading it again to the Apple Wallet application.\n"
            f"{a_insurer_name} cannot guarantee that the electronic version of the certificates will be accepted by "
            f"all police forces. Make sure you always have a paper version on hand.\n\n"
            f"CERTIFICAT D'ASSURANCE POUR LOCATION DE VOITURE\n"
            f"(Valide au Canada et aux États-Unis d'Amérique seulement)\n"
            f"Application particulière de l'avenant F.A.Q. 27 : Responsabilité civile du fait de dommages causés à "
            f"des véhicules dont l'assuré désigné n'est pas propriétaire (incluant les véhicules fournis par un "
            f"employeur).\n"
            f"En cas de vol ou d'endommagement d'un véhicule de location, {a_insurer_name} s'engage "
            f"à rembourser, à l'Assuré ou au propriétaire du véhicule, le montant des dommages réellement encourus "
            f"et dont l'Assuré ou son conjoint s'est rendu responsable en vertu d'un contrat de location, le tout "
            f"jusqu'à concurrence de : 75 000 $\n\n"
            f"CAR RENTAL INSURANCE CERTIFICATE\n"
            f"(Valid only in Canada and the United States of America)\n"
            f"Speciﬁc application of Q.E.F. endorsement B 27 : Civil liability resulting from damage caused to "
            f"vehicles of which named insured is not owner (including vehicles provided by an employer).\n"
            f"In the event of theft or damage to a rental vehicle, {a_insurer_name} "
            f"agrees to refund the Insured or the owner of the vehicle, the amount of damage actually "
            f"incurred and for which the Insured or his/her spouse assumes liability under a rental "
            f"contract, in all up to: $75,000\n"
            "CERTIFICAT D'ASSURANCE RESPONSABILITÉ AUTOMOBILE\n"
            "Le présent certiﬁcat est assujetti aux dispositions et conditions de la police "
            "d'assurance automobile de l'Assureur.\n"
            "Ce certiﬁcat atteste que la personne susnommée est assurée contre la responsabilité "
            "pour blessures et dommages aux biens découlant de l'usage du véhicule ci-décrit, "
            "conformément aux limites minimales exigées par les lois d'assurance en vigueur dans "
            "chacune des provinces canadiennes.\n"
            "AVERTISSEMENT - Quiconque émet ou présente un tel certiﬁcat comme preuve d'une "
            "police d'assurance responsabilité qui effectivement n'est pas en vigueur, est coupable "
            "d'une infraction passible d'une forte amende et/ou d'emprisonnement et suspension "
            "de son permis.\n"
            "Tout sinistre devrait être rapporté immédiatement.\n\n"
            "CANADA INTER-PROVINCE MOTOR VEHICLE LIABILITY INSURANCE CARD\n"
            "This certiﬁcate is subject to the terms and conditions of the Insurers standard "
            "automobile policy.\n"
            "This certiﬁes that the party named herein is insured against liability for bodily injury and "
            "property damage by reason of the operation of the motor vehicle described herein, for an "
            "amount not less than the statutory minimum requirements of every province of Canada.\n"
            "WARNING - Any person who issues or presents such a certiﬁcate as proof of insurance "
            "when no policy exists is guilty of fraud and liable to a heavy ﬁ ne and/or imprisonment. "
            "His driving permit may also be suspended.\n"
            "All loss should be reported immediately.\n\n"
            "CERTIFICAT D'ASSURANCE RESPONSABILITÉ AUTOMOBILE\n"
            "Le présent certiﬁcat est assujetti aux dispositions et conditions de la police "
            "d'assurance automobile de l'Assureur.\n"
            "Ce certiﬁcat atteste que la personne susnommée est assurée contre la responsabilité "
            "pour blessures et dommages aux biens découlant de l'usage du véhicule ci-décrit, "
            "conformément aux limites minimales exigées par les lois d'assurance en vigueur dans "
            "chacune des provinces canadiennes.\n"
            "AVERTISSEMENT - Quiconque émet ou présente un tel certiﬁcat comme preuve d'une "
            "police d'assurance responsabilité qui effectivement n'est pas en vigueur, est coupable "
            "d'une infraction passible d'une forte amende et/ou d'emprisonnement et suspension "
            "de son permis.\n"
            "Tout sinistre devrait être rapporté immédiatement.\n\n"
            "CANADA INTER-PROVINCE MOTOR VEHICLE LIABILITY INSURANCE CARD\n"
            "This certiﬁcate is subject to the terms and conditions of the Insurers standard "
            "automobile policy.\n"
            "This certiﬁes that the party named herein is insured against liability for bodily injury and "
            "property damage by reason of the operation of the motor vehicle described herein, for an "
            "amount not less than the statutory minimum requirements of every province of Canada.\n"
            "WARNING - Any person who issues or presents such a certiﬁcate as proof of insurance "
            "when no policy exists is guilty of fraud and liable to a heavy ﬁ ne and/or imprisonment. "
            "His driving permit may also be suspended.\n"
            "All loss should be reported immediately.\n\n"
            f"{a_new_page}\n"
        )

        self.assertEqual(expected, actual)
