def get(self, request, pattern_template_name=None): # Get all pattern templates templates = get_pattern_templates() if pattern_template_name is None: # Just display the first pattern if a specific one isn't requested pattern_template_name = self.get_first_template(templates) if not is_pattern(pattern_template_name): raise Http404 template = get_template(pattern_template_name) pattern_config = get_pattern_config(pattern_template_name) context = self.get_context_data() context['pattern_templates'] = templates context['pattern_template_name'] = pattern_template_name context['pattern_source'] = escape(template.template.source) context['pattern_config'] = escape( get_pattern_config_str(pattern_template_name)) context['pattern_name'] = pattern_config.get('name', pattern_template_name) context['pattern_markdown'] = get_pattern_markdown( pattern_template_name) return self.render_to_response(context)
def test_not_existing_template(self): result = get_pattern_config_str("doesnotexist") self.assertEqual(result, "")
def test_atom_yml(self): result = get_pattern_config_str( "patterns/atoms/test_atom_yml/test_atom_yml.html") self.assertNotEqual(result, "") self.assertIn("atom_var value from test_atom.yml", result)