Пример #1
0
 def _verify_form_error(self, override_data, missing_field):
     browser = Browser()
     response = submit_inquiry_forms(browser, "*****@*****.**",
                                     **override_data)
     self.assertIsNotNone(response.context)
     self.assertEqual(response.status_code, 200)
     self.assertFormError(response, 'form', missing_field,
                          'This field is required.')
Пример #2
0
 def test_done_submit_inquiry_fails(self, mocked_client_submit_inquiry):
     mocked_client_submit_inquiry.side_effect = ValueError(
         "Invalid init value 'client' for Transition object")
     browser = Browser()
     email = '*****@*****.**'
     response = submit_inquiry_forms(browser, email)
     self.assertEqual(response.status_code, 500)
     for _class in [Client, Address, Inquiry, InquiryInReview, SmsConsent]:
         self.assertFalse(_class.objects.exists())
Пример #3
0
 def test_done_sms_consent_true(self):
     browser = Browser()
     email = '*****@*****.**'
     response = submit_inquiry_forms(browser, email)
     self.assertEqual(response.status_code, 302)
     client = self._check_created_objects(email)
     self.assertEqual(SmsConsent.objects.count(), 1)
     sms_consent = SmsConsent.objects.get()
     self.assertEqual(client.sms_consent, sms_consent)
Пример #4
0
 def test_done_address_fails(self, mocked_create_address):
     mocked_create_address.side_effect = ValidationError(
         {'state': ['This field cannot be blank.']})
     browser = Browser()
     email = '*****@*****.**'
     response = submit_inquiry_forms(browser, email)
     self.assertEqual(response.status_code, 500)
     for _class in [Client, Address, Inquiry, InquiryInReview, SmsConsent]:
         self.assertFalse(_class.objects.exists())
Пример #5
0
 def test_done_inquiry_fails(self, mocked_create_inquiry):
     mocked_create_inquiry.side_effect = ValidationError(
         {'client': ['Inquiry with this Client already exists.']})
     browser = Browser()
     email = '*****@*****.**'
     response = submit_inquiry_forms(browser, email)
     self.assertEqual(response.status_code, 500)
     for _class in [Client, Address, Inquiry, InquiryInReview, SmsConsent]:
         self.assertFalse(_class.objects.exists())
Пример #6
0
 def test_ok(self):
     browser = Browser()
     response = submit_inquiry_forms(browser, "*****@*****.**")
     self.assertRedirects(response,
                          '/inquiry/submitted/',
                          status_code=302,
                          target_status_code=200,
                          fetch_redirect_response=False)
     client = Client.objects.get(user__email="*****@*****.**")
     self.assertFalse(client.email_confirmed)
Пример #7
0
 def test_first_form_undesirable_zip_code(self):
     browser = Browser()
     first_data = copy.deepcopy(FIRST_DATA)
     for undesirable_zip_code in UNDESIRABLE_ZIP_CODES:
         first_data.update({
             "first-email": '*****@*****.**',
             'first-zip_code': undesirable_zip_code
         })
         response = browser.post('/inquiry/data/first/', first_data)
         self.assertEqual(response.status_code, 302)
Пример #8
0
 def test_first_form_operational_state(self):
     browser = Browser()
     first_data = copy.deepcopy(FIRST_DATA)
     for state in OPERATIONAL_STATES:
         first_data.update({
             "first-email": '*****@*****.**',
             "first-state": state
         })
         response = browser.post('/inquiry/data/first/', first_data)
         self.assertEqual(response.status_code, 302)
Пример #9
0
 def test_done_sms_consent_false(self):
     browser = Browser()
     email = '*****@*****.**'
     response = submit_inquiry_forms(browser,
                                     email,
                                     signup_overrides={
                                         "signup-sms_opt_in": "",
                                     })
     self.assertEqual(response.status_code, 302)
     self._check_created_objects(email)
     self.assertFalse(SmsConsent.objects.exists())
Пример #10
0
 def test_inquiry_submissions_same_email(self):
     """
     This tests submitting two inquiry submissions with the same email. This is possible
     if someone submits one, does not confirm their email, and submits another.
     """
     browser = Browser()
     response = submit_inquiry_forms(browser, "*****@*****.**")
     self.assertRedirects(response,
                          '/inquiry/submitted/',
                          status_code=302,
                          target_status_code=200,
                          fetch_redirect_response=False)
     response = submit_inquiry_forms(browser, "*****@*****.**")
     self.assertEqual(response.status_code, 200)
Пример #11
0
 def test_first_form_expansion_state(self):
     browser = Browser()
     first_data = copy.deepcopy(FIRST_DATA)
     for state in EXPANSION_STATES:
         first_data.update({
             "first-email": '*****@*****.**',
             "first-state": state
         })
         response = browser.post('/inquiry/data/first/', first_data)
         self.assertRedirects(response,
                              '/inquiry/results/rres/',
                              status_code=302,
                              target_status_code=200,
                              fetch_redirect_response=False)
Пример #12
0
    def test_event_e69_sent(self, mocked_segment_event,
                            mocked_get_inquiry_segment_event_data):
        mocked_get_inquiry_segment_event_data.return_value = {'foo': 'bar'}

        browser = Browser()
        submit_inquiry_forms(browser, '*****@*****.**')
        client = Client.objects.get(user__email='*****@*****.**')

        mocked_get_inquiry_segment_event_data.assert_called_once_with(client)
        # first four calls are to send the wizard step events
        self.assertEqual(mocked_segment_event.call_count, 5)
        mocked_segment_event.assert_called_with(
            '*****@*****.**',
            'investment inquiry - created account - server',
            mocked_get_inquiry_segment_event_data.return_value)
Пример #13
0
    def test_event_25_in_context(self):
        """
        Test that the datalayer event dict for event 25 is in the context of the inquiry submitted
        view when appropriate
        """
        browser = Browser()
        response = submit_inquiry_forms(browser, "*****@*****.**")
        self.assertEqual(response.status_code, 302)
        # Note: do not use assertRedirects because it does a GET which would conflict with
        # how DataLayerViewMixing.send_event_once_per_session works
        self.assertEqual(response.url, '/inquiry/submitted/')

        event_partial_string = (
            "[{\\u0022city\\u0022: \\u0022Cambridge\\u0022,"
            " \\u0022email\\u0022: \\[email protected]\\u0022")

        # test that the event is in the html on the first load to be sent via datalayer to GTM
        response = browser.get('/inquiry/submitted/')
        self.assertContains(response, event_partial_string)
Пример #14
0
 def test_multiple_inquiry_submissions_same_session(self):
     """
     This tests submitting multiple inquiry submissions during the same session. This is
     possible if someone submits one, does not confirm their email, and submits another. (After
     confirming, clients are unable to access the inquiry page). CustomFormToolsSessionStorage
     is used to fix bug EN-308 which would normally cause a KeyError in this same scenario
     (two inquiry wizard session view submissions in the same session). This test makes sure
     that that bug no longer occurs.
     """
     browser = Browser()
     response = submit_inquiry_forms(browser, "*****@*****.**")
     self.assertRedirects(response,
                          '/inquiry/submitted/',
                          status_code=302,
                          target_status_code=200,
                          fetch_redirect_response=False)
     response = submit_inquiry_forms(browser, "*****@*****.**")
     self.assertRedirects(response,
                          '/inquiry/submitted/',
                          status_code=302,
                          target_status_code=200,
                          fetch_redirect_response=False)
Пример #15
0
 def test_first_form_ok(self):
     browser = Browser()
     first_data = copy.deepcopy(FIRST_DATA)
     first_data.update({"first-email": '*****@*****.**'})
     response = browser.post('/inquiry/data/first/', first_data)
     self.assertEqual(response.status_code, 302)