def test_request_collaboration(mock_request_collaboration, mock_submit): mock_request_collaboration.return_value = create_response( 201, {'company_email': '*****@*****.**'}) helpers.request_collaboration( company_number='12334', email='*****@*****.**', name='Foo Bar', form_url='/the/form/', ) assert mock_submit.call_args == mock.call({ 'data': { 'name': 'Foo Bar', 'email': '*****@*****.**', 'add_collaborator_url': settings.FAB_ADD_USER_URL, 'report_abuse_url': urls.FEEDBACK, }, 'meta': { 'action_name': 'gov-notify-email', 'form_url': '/the/form/', 'sender': {}, 'spam_control': {}, 'template_id': (settings.GOV_NOTIFY_REQUEST_COLLABORATION_TEMPLATE_ID), 'email_address': '*****@*****.**' } })
def done(self, form_list, **kwargs): data = self.serialize_form_list(form_list) is_enrolled = helpers.get_is_enrolled( company_number=data['company_number'], session=self.request.session, ) if is_enrolled: helpers.request_collaboration( company_number=data['company_number'], email=self.request.sso_user.email, name=f"{data['given_name']} {data['family_name']}", form_url=self.request.path, ) else: self.create_company_profile(data) return TemplateResponse(self.request, self.templates[FINISHED])