|
1 | | -"""Shared fixtures for mirrored preset command tests.""" |
| 1 | +"""Load shared fixtures for mirrored preset command tests.""" |
2 | 2 |
|
3 | 3 | from __future__ import annotations |
4 | 4 |
|
5 | | -import shutil |
6 | | -import tempfile |
7 | | -from pathlib import Path |
| 5 | +from . import _fixtures |
8 | 6 |
|
9 | | -import pytest |
10 | | -import yaml |
11 | | - |
12 | | - |
13 | | -@pytest.fixture |
14 | | -def temp_dir(): |
15 | | - """Create a temporary directory for tests.""" |
16 | | - tmpdir = tempfile.mkdtemp() |
17 | | - yield Path(tmpdir) |
18 | | - shutil.rmtree(tmpdir) |
19 | | - |
20 | | - |
21 | | -@pytest.fixture |
22 | | -def valid_pack_data(): |
23 | | - """Return valid preset manifest data.""" |
24 | | - return { |
25 | | - "schema_version": "1.0", |
26 | | - "preset": { |
27 | | - "id": "test-pack", |
28 | | - "name": "Test Preset", |
29 | | - "version": "1.0.0", |
30 | | - "description": "A test preset", |
31 | | - "author": "Test Author", |
32 | | - "repository": "https://github.com/test/test-pack", |
33 | | - "license": "MIT", |
34 | | - }, |
35 | | - "requires": {"speckit_version": ">=0.1.0"}, |
36 | | - "provides": { |
37 | | - "templates": [ |
38 | | - { |
39 | | - "type": "template", |
40 | | - "name": "spec-template", |
41 | | - "file": "templates/spec-template.md", |
42 | | - "description": "Custom spec template", |
43 | | - "replaces": "spec-template", |
44 | | - } |
45 | | - ] |
46 | | - }, |
47 | | - "tags": ["testing", "example"], |
48 | | - } |
49 | | - |
50 | | - |
51 | | -@pytest.fixture |
52 | | -def pack_dir(temp_dir, valid_pack_data): |
53 | | - """Create a complete preset directory structure.""" |
54 | | - preset_dir = temp_dir / "test-pack" |
55 | | - preset_dir.mkdir() |
56 | | - (preset_dir / "preset.yml").write_text( |
57 | | - yaml.safe_dump(valid_pack_data), encoding="utf-8" |
58 | | - ) |
59 | | - templates_dir = preset_dir / "templates" |
60 | | - templates_dir.mkdir() |
61 | | - (templates_dir / "spec-template.md").write_text( |
62 | | - "# Custom Spec Template\n\nThis is a custom template.\n", |
63 | | - encoding="utf-8", |
64 | | - ) |
65 | | - return preset_dir |
66 | | - |
67 | | - |
68 | | -@pytest.fixture |
69 | | -def project_dir(temp_dir): |
70 | | - """Create a mock spec-kit project directory.""" |
71 | | - project = temp_dir / "project" |
72 | | - project.mkdir() |
73 | | - templates_dir = project / ".specify" / "templates" |
74 | | - templates_dir.mkdir(parents=True) |
75 | | - (templates_dir / "spec-template.md").write_text( |
76 | | - "# Core Spec Template\n", encoding="utf-8" |
77 | | - ) |
78 | | - (templates_dir / "plan-template.md").write_text( |
79 | | - "# Core Plan Template\n", encoding="utf-8" |
80 | | - ) |
81 | | - (templates_dir / "commands").mkdir() |
82 | | - return project |
| 7 | +temp_dir = _fixtures.temp_dir |
| 8 | +valid_pack_data = _fixtures.valid_pack_data |
| 9 | +pack_dir = _fixtures.pack_dir |
| 10 | +project_dir = _fixtures.project_dir |
0 commit comments