Пример #1
0
 def test_build_content(self):
     pagelet = ApplicationPagelet(request=mock_data.mock_request(), request_kwargs={}, pagelet=mock_pagelet_model,
                                  menu_label=mock_menu_label, selected_item=mock_menu_selected_item)
     content = pagelet._build_content()
     #mock_resolve.assert_called_once_with(mock_pagelet_model_starting_url, mock_urlconf_test_application)
     self.assertIsInstance(content, Markup, 'content was not markup')
     self.assertEqual(content, mock_resolve_response.content, 'content was incorrect %s' % content)
Пример #2
0
 def test_get_html_data(self):
     pagelet = ApplicationPagelet(request=mock_data.mock_request(), request_kwargs={}, pagelet=mock_pagelet_model,
                                  menu_label=mock_menu_label, selected_item=mock_menu_selected_item)
     data = pagelet._get_html_data()
     expected_data = {'starting_url' : mock_pagelet_model_starting_url,
                      'application' : mock_pagelet_model_application}
     self.assertDictContainsSubset(expected_data, data, 'data was missing expceted values %s' % data)
Пример #3
0
 def test_get_context(self):
     pagelet = SimplePagelet(request=mock_data.mock_request(), request_kwargs={}, pagelet=mock_pagelet_model,
                             menu_label=mock_menu_label, selected_item=mock_menu_selected_item)
     context = pagelet._get_context()
     self.assertIn('content', context, 'context did not contain content %s' % context)
     self.assertIsInstance(context['content'], Markup, 'content was not markup')
     self.assertEqual(context['content'], mock_pagelet_model.content, 'content was incorrect %s' % context['content'])
Пример #4
0
 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')
Пример #5
0
 def test_get_context_with_content(self):
     pagelet = ApplicationPagelet(request=mock_data.mock_request(), request_kwargs={}, pagelet=mock_pagelet_model,
                                  menu_label=mock_menu_label, selected_item=mock_menu_selected_item)
     context = pagelet._get_context(include_content=True)
     #mock_resolve.assert_called_once_with(mock_pagelet_model_starting_url, mock_urlconf_test_application)
     self.assertIn('content', context, 'context did not contain content %s' % context)
     self.assertIsInstance(context['content'], Markup, 'content was not markup')
     self.assertEqual(context['content'], mock_resolve_response.content, 'content was incorrect %s' % context['content'])
Пример #6
0
 def test_json(self):
     pagelet = ApplicationPagelet(request=mock_data.mock_request(), request_kwargs={}, pagelet=mock_pagelet_model,
                                  menu_label=mock_menu_label, selected_item=mock_menu_selected_item)
     json_output = pagelet.json()
     json_output = json.loads(json_output)
     #FIXME: Should check for html
     expected_json_output = {'location': mock_pagelet_model_starting_url,
                             'css': expected_css,
                             'js': expected_js}
     self.assertDictContainsSubset(expected_json_output, json_output, 'json was incorrect %s' % json_output)
Пример #7
0
 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)
Пример #8
0
 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)
Пример #9
0
 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')
Пример #10
0
 def test_build_js(self):
     pagelet = BasePagelet(request=mock_data.mock_request(), request_kwargs=None, pagelet=mock_pagelet_model)
     js = pagelet._build_js()
     self.assertListEqual(expected_js, js, 'css was incorrect %s' % js)
Пример #11
0
 def test_get_html_data(self):
     pagelet = BasePagelet(request=mock_data.mock_request(), request_kwargs=None, pagelet=mock_pagelet_model)
     data = pagelet._get_html_data()
     self.assertIn('name', data, 'data does not include a name %s' % data)
Пример #12
0
 def test_get_context_no_content(self):
     pagelet = ApplicationPagelet(request=mock_data.mock_request(), request_kwargs={}, pagelet=mock_pagelet_model,
                                  menu_label=mock_menu_label, selected_item=mock_menu_selected_item)
     context = pagelet._get_context()
     self.assertNotIn('content', context, 'context incorrectly contained content %s' % context)
Пример #13
0
 def test_get_context_with_request(self):
     content_type = BaseContentType(request=mock_data.mock_request(), request_kwargs=None)
     context = content_type._get_context()
     self.assertIsInstance(context, RequestContext, 'context was not a dictionary')