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/sms/test_views.py
from flask import url_for
from flask_babel import gettext as _

from buyercall.tests.lib.util import ViewTestMixin
from buyercall.tests.lib.assertions import assert_status_with_message
from buyercall.blueprints.sms.models import Message


class TestSmsViews(ViewTestMixin):

    def test_sms_leads_page_logged_out(self, messages):
        """sms leads page redirects to login."""
        response = self.client.get(url_for('sms.sms_leads'))
        assert_status_with_message(302, response, _('sms'))

    def test_sms_leads_page(self):
        """Sms leads page renders successfully."""
        self.login()
        response = self.client.get(url_for('sms.sms_leads'))
        assert_status_with_message(200, response, _('My Message List'))

    def test_sms_lead_edit_logged_out(self):
        """sms lead edit page redirects to login page."""
        response = self.client.get(url_for('sms.lead_edit', id=1))
        assert_status_with_message(302, response, _('login'))
        assert b'sms' in response.data

    def test_sms_lead_edit(self):
        """smd lead edit page renders successfully."""
        self.login()
        message = Message.query.first()
        response = self.client.get(url_for('sms.lead_edit', id=message.id))
        assert_status_with_message(200, response, _('Edit Message Lead'))