HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/buyercall_forms/buyercall/buyercall/tests/forms/test_models.py
from buyercall.blueprints.contacts.models import Contact
from buyercall.blueprints.form_leads.models import ExternalForm, ExternalFormField, FormLeadField, FormLead
import pytest


class TestFormLead(object):

    def test_form_lead_tos(self, form_leads):
        contact_1 = Contact.query.filter(Contact.firstname == 'first_form_lead').first()
        contact_2 = Contact.query.filter(Contact.firstname == 'yes_first_form_lead').first()
        contact_3 = Contact.query.filter(Contact.firstname == 'no_first_form_lead').first()

        form_lead_1 = FormLead.query.filter(FormLead.contact_id == contact_1.id).first()
        form_lead_2 = FormLead.query.filter(FormLead.contact_id == contact_2.id).first()
        form_lead_3 = FormLead.query.filter(FormLead.contact_id == contact_3.id).first()

        if form_lead_1 and form_lead_1.tos == '' and \
            form_lead_2 and form_lead_2.tos == 'Yes' and \
            form_lead_3 and form_lead_3.tos == 'No':
            assert True

    def test_form_lead_interaction_time(self):
        contact = Contact.query.filter().first()

        if contact:
            form_lead = FormLead.query\
                .filter(FormLead.contact_id == contact.id)\
                .first()

            if form_lead and form_lead.interaction_time == form_lead.created_on.strftime('%Y-%m-%d %H:%M:%S'):
                assert True

    def test_form_lead_source(self):
        contact = Contact.query\
            .filter(Contact.firstname == 'first_form_lead')\
            .first()

        form_lead = FormLead.query\
            .filter(FormLead.contact_id == contact.id)\
            .first()

        if form_lead and form_lead.source == 'form1':
            assert True

    @pytest.mark.skip(reason="method not currently used in system")
    def test_form_lead_source_id(self):
        test = 'test'