def test_retrieve_exporting_advice_email_not_ok(settings):
    url = api_client.exporting.endpoints['lookup-by-postcode'].format(
        postcode='ABC123')
    with requests_mock.mock() as mock:
        mock.get(url, status_code=404)
        email = helpers.retrieve_exporting_advice_email('ABC123')

    assert email == settings.CONTACT_DIT_AGENT_EMAIL_ADDRESS
Esempio n. 2
0
def test_retrieve_exporting_advice_email_success():
    url = api_client.exporting.endpoints['lookup-by-postcode'].format(
        postcode='ABC123')
    with requests_mock.mock() as mock:
        mock.get(url, status_code=200, json={'email': '*****@*****.**'})
        email = helpers.retrieve_exporting_advice_email('ABC123')

    assert email == '*****@*****.**'
def test_retrieve_exporting_advice_email_exception(settings):
    url = api_client.exporting.endpoints['lookup-by-postcode'].format(
        postcode='ABC123')
    with requests_mock.mock() as mock:
        mock.get(url, exc=requests.exceptions.ConnectTimeout)
        email = helpers.retrieve_exporting_advice_email('ABC123')

    assert email == settings.CONTACT_DIT_AGENT_EMAIL_ADDRESS
Esempio n. 4
0
 def serialize_form_list(self, form_list):
     data = {}
     for form in form_list:
         data.update(form.cleaned_data)
     del data['terms_agreed']
     data['region_office_email'] = helpers.retrieve_exporting_advice_email(
         data['postcode'])
     return data
 def agent_email(self):
     return helpers.retrieve_exporting_advice_email(self.kwargs['postcode'])