|
1 | 1 | """Unit test the provider plugin""" |
2 | 2 |
|
3 | | -from pathlib import Path |
4 | 3 | from typing import Any |
5 | 4 |
|
6 | 5 | import pytest |
7 | 6 |
|
8 | | -from cppython.plugins.cmake.builder import Builder |
9 | 7 | from cppython.plugins.cmake.plugin import CMakeGenerator |
10 | 8 | from cppython.plugins.cmake.schema import ( |
11 | 9 | CMakeConfiguration, |
12 | | - CMakePresets, |
13 | | - CMakeSyncData, |
14 | 10 | ) |
15 | 11 | from cppython.test.pytest.tests import GeneratorUnitTests |
16 | 12 | from cppython.test.schema import Variant |
17 | | -from cppython.utility.utility import TypeName |
18 | 13 |
|
19 | 14 | pytest_plugins = ['tests.fixtures.cmake'] |
20 | 15 |
|
@@ -44,107 +39,3 @@ def fixture_plugin_type() -> type[CMakeGenerator]: |
44 | 39 | The type of the Generator |
45 | 40 | """ |
46 | 41 | return CMakeGenerator |
47 | | - |
48 | | - @staticmethod |
49 | | - def test_provider_write(tmp_path: Path) -> None: |
50 | | - """Verifies that the provider preset writing works as intended |
51 | | -
|
52 | | - Args: |
53 | | - tmp_path: The input path the use |
54 | | - """ |
55 | | - builder = Builder() |
56 | | - |
57 | | - includes_file = tmp_path / 'includes.cmake' |
58 | | - with includes_file.open('w', encoding='utf-8') as file: |
59 | | - file.write('example contents') |
60 | | - |
61 | | - data = CMakeSyncData(provider_name=TypeName('test-provider'), top_level_includes=includes_file) |
62 | | - builder.write_provider_preset(tmp_path, data) |
63 | | - |
64 | | - @staticmethod |
65 | | - def test_cppython_write(tmp_path: Path) -> None: |
66 | | - """Verifies that the cppython preset writing works as intended |
67 | | -
|
68 | | - Args: |
69 | | - tmp_path: The input path the use |
70 | | - """ |
71 | | - builder = Builder() |
72 | | - |
73 | | - provider_directory = tmp_path / 'providers' |
74 | | - provider_directory.mkdir(parents=True, exist_ok=True) |
75 | | - |
76 | | - includes_file = provider_directory / 'includes.cmake' |
77 | | - with includes_file.open('w', encoding='utf-8') as file: |
78 | | - file.write('example contents') |
79 | | - |
80 | | - data = CMakeSyncData(provider_name=TypeName('test-provider'), top_level_includes=includes_file) |
81 | | - builder.write_provider_preset(provider_directory, data) |
82 | | - |
83 | | - builder.write_cppython_preset(tmp_path, provider_directory, data) |
84 | | - |
85 | | - @staticmethod |
86 | | - def test_root_write(tmp_path: Path) -> None: |
87 | | - """Verifies that the root preset writing works as intended |
88 | | -
|
89 | | - Args: |
90 | | - tmp_path: The input path the use |
91 | | - """ |
92 | | - builder = Builder() |
93 | | - |
94 | | - cppython_preset_directory = tmp_path / 'cppython' |
95 | | - cppython_preset_directory.mkdir(parents=True, exist_ok=True) |
96 | | - |
97 | | - provider_directory = cppython_preset_directory / 'providers' |
98 | | - provider_directory.mkdir(parents=True, exist_ok=True) |
99 | | - |
100 | | - includes_file = provider_directory / 'includes.cmake' |
101 | | - with includes_file.open('w', encoding='utf-8') as file: |
102 | | - file.write('example contents') |
103 | | - |
104 | | - root_file = tmp_path / 'CMakePresets.json' |
105 | | - presets = CMakePresets() |
106 | | - |
107 | | - serialized = presets.model_dump_json(exclude_none=True, by_alias=False, indent=4) |
108 | | - with open(root_file, 'w', encoding='utf8') as file: |
109 | | - file.write(serialized) |
110 | | - |
111 | | - data = CMakeSyncData(provider_name=TypeName('test-provider'), top_level_includes=includes_file) |
112 | | - builder.write_provider_preset(provider_directory, data) |
113 | | - |
114 | | - cppython_preset_file = builder.write_cppython_preset(cppython_preset_directory, provider_directory, data) |
115 | | - |
116 | | - builder.write_root_presets(root_file, cppython_preset_file) |
117 | | - |
118 | | - @staticmethod |
119 | | - def test_relative_root_write(tmp_path: Path) -> None: |
120 | | - """Verifies that the root preset writing works as intended |
121 | | -
|
122 | | - Args: |
123 | | - tmp_path: The input path the use |
124 | | - """ |
125 | | - builder = Builder() |
126 | | - |
127 | | - cppython_preset_directory = tmp_path / 'tool' / 'cppython' |
128 | | - cppython_preset_directory.mkdir(parents=True, exist_ok=True) |
129 | | - |
130 | | - provider_directory = cppython_preset_directory / 'providers' |
131 | | - provider_directory.mkdir(parents=True, exist_ok=True) |
132 | | - |
133 | | - includes_file = provider_directory / 'includes.cmake' |
134 | | - with includes_file.open('w', encoding='utf-8') as file: |
135 | | - file.write('example contents') |
136 | | - |
137 | | - relative_indirection = tmp_path / 'nested' |
138 | | - relative_indirection.mkdir(parents=True, exist_ok=True) |
139 | | - |
140 | | - root_file = relative_indirection / 'CMakePresets.json' |
141 | | - presets = CMakePresets() |
142 | | - serialized = presets.model_dump_json(exclude_none=True, by_alias=False, indent=4) |
143 | | - with open(root_file, 'w', encoding='utf8') as file: |
144 | | - file.write(serialized) |
145 | | - |
146 | | - data = CMakeSyncData(provider_name=TypeName('test-provider'), top_level_includes=includes_file) |
147 | | - builder.write_provider_preset(provider_directory, data) |
148 | | - |
149 | | - cppython_preset_file = builder.write_cppython_preset(cppython_preset_directory, provider_directory, data) |
150 | | - builder.write_root_presets(root_file, cppython_preset_file) |
0 commit comments