def test_redirects_if_no_counties_in_session(self): mock_view_instance = Mock(session_data={}) with self.assertLogs('intake.views.applicant_form_view_base', level=logging.WARN): response = ApplicantFormViewBase.check_for_session_based_redirects( mock_view_instance) self.assertEqual(response.status_code, 302) self.assertEqual(response.url, reverse('intake-apply'))
def test_redirects_if_no_counties_in_session(self): mock_view_instance = Mock(session_data={}) with self.assertLogs( 'intake.views.applicant_form_view_base', level=logging.WARN): response = ApplicantFormViewBase.check_for_session_based_redirects( mock_view_instance) self.assertEqual(response.status_code, 302) self.assertEqual(response.url, reverse('intake-apply'))
def test_get_receiving_organizations_if_exists(self, get_agency): counties = models.County.objects.all()[:2] orgs = [ Organization.objects.filter(county_id=county.id).first() for county in counties ] get_agency.side_effect = orgs mock_view_instance = Mock(receiving_organizations=orgs, counties=counties) results = ApplicantFormViewBase.get_receiving_organizations( mock_view_instance, Mock()) self.assertEqual(get_agency.call_count, 0) self.assertListEqual(orgs, results) self.assertListEqual(orgs, mock_view_instance.receiving_organizations)
def test_get_receiving_organizations_if_exists(self, get_agency): counties = models.County.objects.all()[:2] orgs = [ Organization.objects.filter(county_id=county.id).first() for county in counties] get_agency.side_effect = orgs mock_view_instance = Mock( receiving_organizations=orgs, counties=counties) results = ApplicantFormViewBase.get_receiving_organizations( mock_view_instance, Mock()) self.assertEqual(get_agency.call_count, 0) self.assertListEqual(orgs, results) self.assertListEqual( orgs, mock_view_instance.receiving_organizations)
def test_doesnt_redirect_if_has_counties_in_session(self): mock_view_instance = Mock( session_data={'counties': ['alameda', 'contracosta']}) response = ApplicantFormViewBase.check_for_session_based_redirects( mock_view_instance) self.assertEqual(response, None)
def test_doesnt_redirect_if_has_counties_in_session(self): mock_view_instance = Mock( session_data={'counties': ['alameda', 'contracosta']}) response = ApplicantFormViewBase.check_for_session_based_redirects( mock_view_instance) self.assertEqual(response, None)