File: //home/arjun/projects/buyercall_forms/buyercall/buyercall/tests/phonenumbers/test_views.py
from flask import url_for, json
from flask_babel import gettext as _
from buyercall.blueprints.agents.models import Agent
from buyercall.blueprints.phonenumbers.models import Phone
from buyercall.blueprints.user.models import User
from buyercall.extensions import mail
from buyercall.tests.lib.util import ViewTestMixin
from buyercall.tests.lib.assertions import assert_status_with_message
class TestPhoneNumberViews(ViewTestMixin):
def test_onboarding_inbound_logged_out(self, messages):
"""Onboarding page redirects to login page."""
response = self.client.get(url_for('phonenumbers.onboarding_inbound'))
assert_status_with_message(302, response, _('inbound_onboarding'))
def test_onboarding_inbound(self):
"""Onboarding page renders successfully."""
self.login()
response = self.client.get(url_for('phonenumbers.onboarding_inbound'))
assert_status_with_message(200, response, _('inbound_onboarding'))
def test_onboarding_inbound_true(self):
"""Onboarding page renders successfully."""
self.login()
response = self.client.post(url_for('phonenumbers.onboarding_inbound'), follow_redirects=True)
assert_status_with_message(200, response, _('Business Priority Routing Phone Numbers'))
def test_inbound_list_logged_out(self):
"""Inbound list redirects to login."""
response = self.client.get(url_for('phonenumbers.inbound_list'))
assert_status_with_message(302, response, _("inbound"))
def test_inbound_list(self):
"""Inbound list renders successfully."""
self.login()
response = self.client.get(url_for('phonenumbers.inbound_list'), follow_redirects=True)
assert_status_with_message(200, response, _("Business Priority Routing Phone Numbers"))
def test_install_instructions_logged_out(self):
"""Install instructions page redirects to login."""
response = self.client.get(url_for('phonenumbers.install_instructions', id=1))
assert_status_with_message(302, response, _("login"))
assert b'install-instructions' in response.data
def test_install_instructions(self):
"""Install instructions page renders successfully."""
self.login()
phone = Phone.query.first()
response = self.client.get(
url_for('phonenumbers.install_instructions', id=phone.id),
follow_redirects=True
)
assert_status_with_message(200, response, _("Inbound Routing Instructions"))
def test_email_instructions(self):
"""instructions email is sent."""
self.login()
phone = Phone.query.first()
response = self.client.post(
url_for('phonenumbers.email_instructions', id=phone.id),
follow_redirects=True
)
assert_status_with_message(200, response, _("Inbound Routing Instructions"))
def test_inbound_new_logged_out(self):
"""Install instructions page redirects to login."""
response = self.client.get(url_for('phonenumbers.inbound_new'))
assert_status_with_message(302, response, _("login"))
assert b'inbound' in response.data
assert b'new' in response.data
def test_inbound_new(self):
"""Install instructions page renders successfully."""
self.login()
response = self.client.get(
url_for('phonenumbers.inbound_new'),
follow_redirects=True
)
assert_status_with_message(200, response, _("Business Phone Numbers"))
def test_phonenumber_edit_page_logged_out(self):
"""Install instructions page redirects to login."""
response = self.client.get(url_for('phonenumbers.phonenumber_edit', id=1))
assert_status_with_message(302, response, _("login"))
assert b'inbound' in response.data
def test_phonenumber_edit_page(self):
"""Install instructions page renders successfully."""
self.login()
phone = Phone.query.first()
response = self.client.get(
url_for('phonenumbers.phonenumber_edit', id=phone.id),
follow_redirects=True
)
assert_status_with_message(200, response, _("Edit Phone Number"))