File: //home/arjun/projects/buyercall_new/buyercall/buyercall/tests/reports/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
class TestReportViews(ViewTestMixin):
def test_all_reports_logged_out(self):
"""Reports page redirects to login page."""
response = self.client.get(url_for('reports.all_reports'))
assert_status_with_message(302, response, _('login'))
assert b'reports' in response.data
def test_all_reports_empty(self):
"""Report page returns 404."""
self.login()
response = self.client.get(url_for('reports.all_reports'))
assert response.status_code == 404
def test_all_reports(self, reports):
"""Report page renders successfully."""
self.login()
response = self.client.get(url_for('reports.all_reports'))
assert_status_with_message(200, response, _('Administrative Reports'))
def test_list_of_interest_csv_logged_out(self):
"""Reports page redirects to login page."""
response = self.client.get(url_for('reports.list_of_interest_csv'))
assert_status_with_message(302, response, _('login'))
assert b'listofinterest' in response.data
def test_list_of_interest_csv(self):
self.login()
response = self.client.get(url_for('reports.list_of_interest_csv'))
assert_status_with_message(200, response, _('email'))
def test_daily_report(self):
self.login()
params = {
'recipient_emails': 'sachin.whiteman@spericorn.com'
}
response = self.client.post(
url_for('reports.daily_report'),
data=params,
follow_redirects=True
)
assert_status_with_message(200, response, _('Administrative Reports'))