def test_render_time_with_dependency_for_large_page(self): from django.template.loader import get_template template = get_template('mdn_complete_page.html') response_content = create_and_process_template_response(template, {}) self.assertNotIn(CSS_DEPENDENCY_PLACEHOLDER, response_content) self.assertNotIn(JS_DEPENDENCY_PLACEHOLDER, response_content) self.assertIn('test.css', response_content) self.assertIn('test.js', response_content) without_middleware = self.timed_loop( lambda: create_and_process_template_response(template, {}, use_middleware=False)) with_middleware = self.timed_loop( lambda: create_and_process_template_response(template, {}, use_middleware=True)) print('Large page middleware test') self.report_results(with_middleware, without_middleware)
def test_middleware_time_with_dependency_for_small_page(self): template = Template( "{% load component_tags %}{% component_dependencies %}" "{% component_block 'test_component' %}{% slot \"header\" %}" "{% component 'inner_component' variable='foo' %}{% endslot %}{% endcomponent_block %}", name='root') # Sanity tests response_content = create_and_process_template_response(template) self.assertNotIn(CSS_DEPENDENCY_PLACEHOLDER, response_content) self.assertNotIn(JS_DEPENDENCY_PLACEHOLDER, response_content) self.assertIn('style.css', response_content) self.assertIn('script.js', response_content) without_middleware = self.timed_loop( lambda: create_and_process_template_response(template, use_middleware=False)) with_middleware = self.timed_loop( lambda: create_and_process_template_response(template, use_middleware=True)) print('Small page middleware test') self.report_results(with_middleware, without_middleware)