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/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'))