def test_get_context(self): pagelet = MenuPagelet(request=mock_data.mock_request(), request_kwargs={}, menu_label=mock_menu_label, selected_item=mock_menu_selected_item) context = pagelet._get_context() self.assertIn('menu_label', context, 'context did not contain menu_label') self.assertIn('selected_item', context, 'context did not contain selected_item') self.assertEqual(mock_menu_label, context['menu_label'], 'context contained incorrect menu_label') self.assertEqual(mock_menu_selected_item, context['selected_item'], 'context contained incorrect selected_item')
def test_build_css(self): pagelet = MenuPagelet(request=mock_data.mock_request(), request_kwargs={}, menu_label=mock_menu_label, selected_item=mock_menu_selected_item) css = pagelet._build_css() expected_css = ['%scss/%s.css' % (settings.AMPCMS_MEDIA_URL, mock_menu_label)] self.assertListEqual(expected_css, css, 'css was incorrect %s' % css)
def test_get_html_data(self): pagelet = MenuPagelet(request=mock_data.mock_request(), request_kwargs={}, menu_label=mock_menu_label, selected_item=mock_menu_selected_item) data = pagelet._get_html_data() expected_data = {'name': mock_menu_label} self.assertDictEqual(expected_data, data, 'data was incorrect %s' % data)
def test_append(self): pagelet = MenuPagelet(request=mock_data.mock_request(), request_kwargs=None) pagelet.append(mock_menu_item_1, mock_menu_url_1) self.assertIn((mock_menu_item_1, mock_menu_url_1), pagelet._children, 'did not append item to menu')