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

from buyercall.blueprints.widgets.models import Widget
from buyercall.tests.lib.util import ViewTestMixin
from buyercall.tests.lib.assertions import assert_status_with_message


class TestWidgetViews(ViewTestMixin):

    def test_onboarding_outbound_logged_out(self, widgets):
        """Onboarding page redirects to login page."""
        response = self.client.get(url_for('widgets.onboarding_outbound'))
        assert_status_with_message(302, response, _('outbound_onboarding'))

    def test_onboarding_outbound(self):
        """Onboarding page renders successfully."""
        self.login()
        response = self.client.get(url_for('widgets.onboarding_outbound'))
        assert_status_with_message(200, response, _('outbound_onboarding'))

    def test_onboarding_outbound_true(self):
        """Onboarding page renders successfully."""
        self.login()
        response = self.client.post(url_for('widgets.onboarding_outbound'), follow_redirects=True)
        assert_status_with_message(200, response, _('Website and Form Call Widgets'))

    def test_widgets_list_logged_out(self):
        """Widgets list page redirects to login."""
        response = self.client.get(url_for('widgets.list'))
        assert_status_with_message(302, response, _('outbound'))

    def test_widgets_list(self):
        """Widgets list page renders successfully."""
        self.login()
        response = self.client.get(url_for('widgets.list'), follow_redirects=True)
        assert_status_with_message(200, response, _('Website and Form Call Widgets'))

    def test_outbound_new_logged_out(self):
        """new outbound page redirects to login."""
        response = self.client.get(url_for('widgets.new'))
        assert_status_with_message(302, response, _("login"))
        assert b'outbound' in response.data
        assert b'new' in response.data

    def test_outbound_new(self):
        """new outbound page renders successfully."""
        self.login()
        response = self.client.get(
            url_for('widgets.new'),
            follow_redirects=True
        )
        assert_status_with_message(200, response, _("Widget and Form Setup"))

    def test_outbound_edit_logged_out(self):
        """Install instructions page redirects to login."""
        response = self.client.get(url_for('widgets.edit', id=1))
        assert_status_with_message(302, response, _("login"))
        assert b'outbound' in response.data

    def test_outbound_edit_page(self):
        """Install instructions page renders successfully."""
        self.login()
        widget = Widget.query.first()
        response = self.client.get(
            url_for('widgets.edit', id=widget.id),
            follow_redirects=True
        )
        assert_status_with_message(200, response, _("Edit Widget"))

    def test_install_instructions(self):
        """test install instructions page."""
        self.login()
        widget = Widget.query.first()
        response = self.client.get(
            url_for('widgets.install_instructions', id=widget.id),
            follow_redirects=True
        )
        assert_status_with_message(200, response, _(" Widget Install Instructions "))