|
10 | 10 | from data_designer.plugins.errors import PluginLoadError |
11 | 11 | from data_designer.plugins.plugin import Plugin, PluginType |
12 | 12 | from data_designer.plugins.testing.examples import MODULE_NAME, ValidTestConfig, ValidTestTask |
| 13 | +from data_designer.plugins.testing.utils import assert_valid_plugin |
13 | 14 |
|
14 | 15 |
|
15 | 16 | @pytest.fixture |
@@ -130,6 +131,32 @@ def test_validation_fails_with_invalid_modules() -> None: |
130 | 131 | plugin_type=PluginType.COLUMN_GENERATOR, |
131 | 132 | ) |
132 | 133 |
|
| 134 | + with pytest.raises(PluginLoadError, match="Could not find class"): |
| 135 | + Plugin( |
| 136 | + task_class_name=f"{MODULE_NAME}.ValidTestTask", |
| 137 | + config_class_name=f"{MODULE_NAME}.NotADefinedClass", |
| 138 | + plugin_type=PluginType.COLUMN_GENERATOR, |
| 139 | + ) |
| 140 | + |
| 141 | + |
| 142 | +def test_helper_utility_identifies_invalid_classes() -> None: |
| 143 | + """Test the helper utility provides deeper validation of config classes.""" |
| 144 | + valid_plugin = Plugin( |
| 145 | + task_class_name=f"{MODULE_NAME}.ValidTestTask", |
| 146 | + config_class_name=f"{MODULE_NAME}.ValidTestConfig", |
| 147 | + plugin_type=PluginType.COLUMN_GENERATOR, |
| 148 | + ) |
| 149 | + assert_valid_plugin(valid_plugin) |
| 150 | + |
| 151 | + plugin_with_improper_task_class_type = Plugin( |
| 152 | + task_class_name=f"{MODULE_NAME}.ValidTestConfig", |
| 153 | + config_class_name=f"{MODULE_NAME}.ValidTestConfig", |
| 154 | + plugin_type=PluginType.COLUMN_GENERATOR, |
| 155 | + ) |
| 156 | + with pytest.raises(AssertionError): |
| 157 | + assert_valid_plugin(plugin_with_improper_task_class_type) |
| 158 | + |
| 159 | + |
133 | 160 |
|
134 | 161 | # ============================================================================= |
135 | 162 | # Integration Tests |
|
0 commit comments