def get_enterprise_customer_logo_url(request): """ Client API operation adapter/wrapper. """ if not enterprise_enabled(): return None parameter = get_enterprise_branding_filter_param(request) if not parameter: return None provider_id = parameter.get('provider_id', None) ec_uuid = parameter.get('ec_uuid', None) if provider_id: branding_info = enterprise_utils.get_enterprise_branding_info_by_provider_id(identity_provider_id=provider_id) elif ec_uuid: branding_info = enterprise_utils.get_enterprise_branding_info_by_ec_uuid(ec_uuid=ec_uuid) logo_url = None if branding_info and branding_info.logo: logo_url = branding_info.logo.url return logo_url
def test_enterprise_branding_info_by_provider_id(self): """ Test `get_enterprise_branding_info_by_provider_id` helper method. """ EnterpriseCustomerBrandingFactory(enterprise_customer=self.customer, logo='/test_1.png/') self.assertEqual( utils.get_enterprise_branding_info_by_provider_id(), None, ) self.assertEqual( utils.get_enterprise_branding_info_by_provider_id( identity_provider_id=self.provider_id).logo, '/test_1.png/', ) self.assertEqual( utils.get_enterprise_branding_info_by_provider_id( identity_provider_id='fake'), None, )