|
3 | 3 | import pytest |
4 | 4 | from django.test import override_settings |
5 | 5 |
|
| 6 | +from django_bird.templates import BIRD_TAG_PATTERN |
6 | 7 | from django_bird.templates import get_template_names |
7 | 8 |
|
8 | 9 |
|
@@ -68,3 +69,28 @@ def test_get_template_names_duplicates(): |
68 | 69 |
|
69 | 70 | for _, count in template_counts.items(): |
70 | 71 | assert count == 1 |
| 72 | + |
| 73 | + |
| 74 | +@pytest.mark.parametrize( |
| 75 | + "template_content,expected_matches", |
| 76 | + [ |
| 77 | + ("{% bird button %}", ["button"]), |
| 78 | + ("{% bird alert %}{% bird button %}", ["alert", "button"]), |
| 79 | + ("{% bird 'button' %}", ["'button'"]), |
| 80 | + ('{% bird "button" %}', ['"button"']), |
| 81 | + ("{%bird button%}", ["button"]), |
| 82 | + ("{% bird button %}", ["button"]), |
| 83 | + ("{% endbird button %}", []), |
| 84 | + ("{% birds button %}", []), |
| 85 | + ("<bird:button>", []), |
| 86 | + ("{% extends 'base.html' %}{% bird button %}", ["button"]), |
| 87 | + ("{% bird\n'multiline'\n%}", ["'multiline'"]), |
| 88 | + ('{% bird "line1\nline2" %}', ['"line1\nline2"']), |
| 89 | + ("{% bird ' whitespace ' \n%}", ["' whitespace '"]), |
| 90 | + ("{% bird 'mixed\"quotes'\n%}", ["'mixed\"quotes'"]), |
| 91 | + ("{% bird content\n%}", ["content"]), |
| 92 | + ], |
| 93 | +) |
| 94 | +def test_bird_tag_pattern(template_content, expected_matches): |
| 95 | + matches = [m.group(1) for m in BIRD_TAG_PATTERN.finditer(template_content)] |
| 96 | + assert matches == expected_matches |
0 commit comments