def test_vet_based_on_form(self): view = InquiryApplyWizard() view.request = self._get_request() mocked_form = mock.Mock() with mock.patch.object(mocked_form, 'cleaned_data', { 'state': 'MA', 'zip_code': '02138' }): (outcome_slug, url_name, vetted_message) = view._vet_based_on_form( 'first', mocked_form ) # yapf: disable self.assertIsNone(outcome_slug) self.assertEqual(url_name, '') self.assertEqual(vetted_message, '')
def test_vet_based_on_form_not_first_step(self): """ tests that only the first step vets based on state """ view = InquiryApplyWizard() view.request = self._get_request() mocked_form = mock.Mock() for form in ['home', 'homeowner', 'signup']: with mock.patch.object(mocked_form, 'cleaned_data', { 'state': 'MT', 'zip_code': '01234' }): (outcome_slug, url_name, vetted_message) = view._vet_based_on_form(form, mocked_form) self.assertIsNone(outcome_slug) self.assertEqual(url_name, '') self.assertEqual(vetted_message, '')
def test_vet_based_on_form_calls_get_state_zip_code_outcome_key( self, mocked_get_state_zip_code_outcome_key): view = InquiryApplyWizard() view.request = self._get_request() mocked_get_state_zip_code_outcome_key.return_value = (None, '') mocked_form = mock.Mock() with mock.patch.object(mocked_form, 'cleaned_data', { 'state': 'MA', 'zip_code': '02138' }): (outcome_slug, url_name, vetted_message) = view._vet_based_on_form( 'first', mocked_form ) # yapf: disable cleaned_data = mocked_form.cleaned_data mocked_get_state_zip_code_outcome_key.assert_called_once_with( cleaned_data['state'], cleaned_data['zip_code'])
def test_vet_based_on_form_expansion_state(self): view = InquiryApplyWizard() view.request = self._get_request() mocked_form = mock.Mock() for state in EXPANSION_STATES: with mock.patch.object(mocked_form, 'cleaned_data', { 'state': state, 'zip_code': '01234' }): (outcome_slug, url_name, vetted_message) = view._vet_based_on_form( 'first', mocked_form) self.assertEqual(outcome_slug, INQUIRY_OUTCOME_SLUG_MAP['2_expansion_states']) self.assertEqual(url_name, 'inquiry:outcome') self.assertEqual(vetted_message, 'rejected expansion states')
def test_vet_based_on_form_undesirable_zip_code(self): view = InquiryApplyWizard() view.request = self._get_request() mocked_form = mock.Mock() for undesirable_zip_code in UNDESIRABLE_ZIP_CODES: with mock.patch.object(mocked_form, 'cleaned_data', { 'state': 'MA', 'zip_code': undesirable_zip_code }): (outcome_slug, url_name, vetted_message) = view._vet_based_on_form( 'first', mocked_form) self.assertEqual( outcome_slug, INQUIRY_OUTCOME_SLUG_MAP['3_undesirable_zip_code']) self.assertEqual(url_name, 'inquiry:outcome') self.assertEqual(vetted_message, 'rejected undesirable zip code')