|
3 | 3 | import contextlib |
4 | 4 | import logging |
5 | 5 | import re |
6 | | -from dataclasses import dataclass |
7 | | -from dataclasses import field |
8 | 6 | from pathlib import Path |
9 | | -from typing import Any |
10 | 7 |
|
11 | 8 | import pytest |
12 | 9 | from django.conf import settings |
|
15 | 12 | from django.template.engine import Engine |
16 | 13 | from django.test import override_settings |
17 | 14 |
|
18 | | -from django_bird.staticfiles import AssetType |
19 | | - |
20 | 15 | from .settings import DEFAULT_SETTINGS |
21 | 16 |
|
22 | 17 | pytest_plugins = [] |
@@ -89,63 +84,6 @@ def _override_app_settings(**kwargs): |
89 | 84 | return _override_app_settings |
90 | 85 |
|
91 | 86 |
|
92 | | -@dataclass |
93 | | -class TestComponent: |
94 | | - name: str |
95 | | - content: str |
96 | | - file: Path | None = None |
97 | | - parent_dir: str = "bird" |
98 | | - sub_dir: str | None = None |
99 | | - |
100 | | - def create(self, base_dir: Path) -> TestComponent: |
101 | | - parent = base_dir / self.parent_dir |
102 | | - parent.mkdir(exist_ok=True) |
103 | | - |
104 | | - if self.sub_dir is not None: |
105 | | - dir = parent / self.sub_dir |
106 | | - dir.mkdir(exist_ok=True) |
107 | | - else: |
108 | | - dir = parent |
109 | | - |
110 | | - template = dir / f"{self.name}.html" |
111 | | - template.write_text(self.content) |
112 | | - |
113 | | - self.file = template |
114 | | - |
115 | | - return self |
116 | | - |
117 | | - |
118 | | -@dataclass |
119 | | -class TestAsset: |
120 | | - component: TestComponent |
121 | | - content: str |
122 | | - asset_type: AssetType |
123 | | - file: Path | None = None |
124 | | - |
125 | | - def create(self) -> TestAsset: |
126 | | - if self.component.file is None: |
127 | | - raise ValueError("Component must be created before adding assets") |
128 | | - |
129 | | - component_dir = self.component.file.parent |
130 | | - component_name = self.component.file.stem |
131 | | - |
132 | | - asset_file = component_dir / f"{component_name}{self.asset_type.ext}" |
133 | | - asset_file.write_text(self.content) |
134 | | - |
135 | | - self.file = asset_file |
136 | | - |
137 | | - return self |
138 | | - |
139 | | - |
140 | | -@dataclass |
141 | | -class TestComponentCase: |
142 | | - component: TestComponent |
143 | | - template_content: str |
144 | | - expected: str |
145 | | - description: str = "" |
146 | | - template_context: dict[str, Any] = field(default_factory=dict) |
147 | | - |
148 | | - |
149 | 87 | @pytest.fixture |
150 | 88 | def create_template(): |
151 | 89 | def _create_template(template_file: Path) -> DjangoTemplate: |
|
0 commit comments