def get_context_data(self): return { **self.cleaned_data, **urls_processor(None), **header_footer_processor(None), 'recipient_name': self.recipient_name, }
def test_header_footer_processor(settings): context = context_processors.header_footer_processor(None) assert context['header_footer_urls'] == { 'create_an_export_plan': ('https://exred.com/advice/create-an-export-plan/'), 'find_an_export_market': ('https://exred.com/advice/find-an-export-market/'), 'define_route_to_market': ('https://exred.com/advice/define-route-to-market/'), 'get_export_finance_and_funding': ('https://exred.com/advice/get-export-finance-and-funding/'), 'manage_payment_for_export_orders': ('https://exred.com/advice/manage-payment-for-export-orders/'), 'prepare_to_do_business_in_a_foreign_country': ('https://exred.com/' 'advice/prepare-to-do-business-in-a-foreign-country/'), 'manage_legal_and_ethical_compliance': ('https://exred.com/advice/manage-legal-and-ethical-compliance/'), 'prepare_for_export_procedures_and_logistics': ('https://exred.com/' 'advice/prepare-for-export-procedures-and-logistics/'), 'about': 'https://exred.com/about/', 'dit': urls.DIT, 'advice': 'https://exred.com/advice/', 'markets': 'https://exred.com/markets/', 'search': 'https://exred.com/search/', 'services': 'https://exred.com/services/', 'domestic_news': 'https://exred.com/news/', 'fas': 'https://fas.com', 'how_to_do_business_with_the_uk': ('https://international.com/international' '/how-to-do-business-with-the-uk/'), 'industries': 'https://international.com/international/industries/', 'international_news': 'https://international.com/international/news/', 'get_finance': 'https://exred.com/get-finance/', 'ukef': 'https://exred.com/get-finance/', 'performance': 'https://exred.com/performance-dashboard/', 'privacy_and_cookies': 'https://exred.com/privacy-and-cookies/', 'terms_and_conditions': 'https://exred.com/terms-and-conditions/', 'market_access': 'https://exred.com/report-trade-barrier/' }
def test_urls_exist_in_domestic_footer(url, settings): context = { **context_processors.header_footer_processor(None), **context_processors.urls_processor(None), **context_processors.feature_flags(None), } template_name = ('directory_components/header_footer/domestic_footer.html') assert url in render_to_string(template_name, context)
def test_urls_exist_in_domestic_header(url, settings): context = { 'features': { 'NEWS_SECTION_ON': True }, **context_processors.header_footer_processor(None), **context_processors.urls_processor(None) } template_name = ('directory_components/header_footer/domestic_header.html') assert url in render_to_string(template_name, context)
def test_header_international_news_section_off(settings): context = { 'features': { 'NEWS_SECTION_ON': False }, **context_processors.header_footer_processor(None), **context_processors.urls_processor(None) } template_name = 'directory_components/header_footer/domestic_header.html' html = render_to_string(template_name, context) assert urls.GREAT_INTERNATIONAL_NEWS not in html
def test_header_logged_out(template_name): context = { 'sso_is_logged_in': False, 'sso_login_url': 'login.com', 'sso_logout_url': 'logout.com', **context_processors.header_footer_processor(None), } html = render_to_string(template_name, context) assert 'Sign in' in html assert context['sso_login_url'] in html assert 'Sign out' not in html assert context['sso_logout_url'] not in html
def test_urls_exist_in_international_header(url, settings): context = { 'features': { 'NEWS_SECTION_ON': True, 'HOW_TO_DO_BUSINESS_ON': True, }, **context_processors.header_footer_processor(None), **context_processors.urls_processor(None) } template_name = ( 'directory_components/header_footer/international_header.html') assert url in render_to_string(template_name, context)
def test_domestic_footer_ids_match_urls_and_text(title, element_id, url, settings): context = { **context_processors.header_footer_processor(None), **context_processors.urls_processor(None), **context_processors.feature_flags(None), } html = render_to_string( 'directory_components/header_footer/domestic_footer.html', context) soup = BeautifulSoup(html, 'html.parser') element = soup.find(id=element_id) assert element.attrs['href'] == url if title: assert element.string == title
def test_international_header_ids_match_urls_and_text(title, element_id, url, settings): context = { 'features': { 'NEWS_SECTION_ON': True, 'HOW_TO_DO_BUSINESS_ON': True }, **context_processors.header_footer_processor(None), **context_processors.urls_processor(None), } html = render_to_string( 'directory_components/header_footer/international_header.html', context) soup = BeautifulSoup(html, 'html.parser') element = soup.find(id=element_id) assert element.attrs['href'] == url if title: assert element.string == title