|
1 | 1 | from pipelex.core.concept import Concept |
2 | 2 | from pipelex.core.concept_native import NativeConcept |
| 3 | +from pipelex.core.concept_provider_abstract import ConceptProviderAbstract |
3 | 4 |
|
4 | 5 |
|
5 | 6 | class Testget_concept_providerIsNativeConcept: |
@@ -128,3 +129,103 @@ def test_is_native_concept_common_examples(self): |
128 | 129 |
|
129 | 130 | # And they should also work with the explicit "native." prefix |
130 | 131 | assert Concept.is_native_concept(f"native.{concept_name}") is True, f"'native.{concept_name}' should also be recognized as native concept" |
| 132 | + |
| 133 | + |
| 134 | +class TestConceptLibraryCompatibility: |
| 135 | + """Test ConceptLibrary compatibility methods.""" |
| 136 | + |
| 137 | + def test_is_compatible_by_concept_code_simple_text_concept_vs_text(self, concept_provider: ConceptProviderAbstract): |
| 138 | + """Test that SimpleTextConcept (no structure) is compatible with native Text.""" |
| 139 | + # Test: SimpleTextConcept should be compatible with native Text (defaults to Text) |
| 140 | + result = concept_provider.is_compatible_by_concept_code( |
| 141 | + tested_concept_code="concept_library_tests.SimpleTextConcept", wanted_concept_code="native.Text" |
| 142 | + ) |
| 143 | + assert result is True, "SimpleTextConcept should be compatible with native Text" |
| 144 | + |
| 145 | + def test_is_compatible_by_concept_code_fundamentals_doc_vs_text(self, concept_provider: ConceptProviderAbstract): |
| 146 | + """Test that FundamentalsDoc (custom structure) is not compatible with native Text.""" |
| 147 | + # Test: FundamentalsDoc should NOT be compatible with native Text (has custom structure) |
| 148 | + result = concept_provider.is_compatible_by_concept_code( |
| 149 | + tested_concept_code="concept_library_tests.FundamentalsDoc", wanted_concept_code="native.Text" |
| 150 | + ) |
| 151 | + assert result is False, "FundamentalsDoc should not be compatible with native Text" |
| 152 | + |
| 153 | + def test_is_compatible_by_concept_code_explicit_text_concept_vs_text(self, concept_provider: ConceptProviderAbstract): |
| 154 | + """Test that ExplicitTextConcept (explicitly refines Text) is compatible with native Text.""" |
| 155 | + # Test: ExplicitTextConcept should be compatible with native Text |
| 156 | + result = concept_provider.is_compatible_by_concept_code( |
| 157 | + tested_concept_code="concept_library_tests.ExplicitTextConcept", wanted_concept_code="native.Text" |
| 158 | + ) |
| 159 | + assert result is True, "ExplicitTextConcept should be compatible with native Text" |
| 160 | + |
| 161 | + def test_is_compatible_by_concept_code_image_based_concept_vs_image(self, concept_provider: ConceptProviderAbstract): |
| 162 | + """Test that ImageBasedConcept is compatible with native Image.""" |
| 163 | + # Test: ImageBasedConcept should be compatible with native Image |
| 164 | + result = concept_provider.is_compatible_by_concept_code( |
| 165 | + tested_concept_code="concept_library_tests.ImageBasedConcept", wanted_concept_code="native.Image" |
| 166 | + ) |
| 167 | + assert result is True, "ImageBasedConcept should be compatible with native Image" |
| 168 | + |
| 169 | + def test_is_compatible_by_concept_code_image_based_concept_vs_text(self, concept_provider: ConceptProviderAbstract): |
| 170 | + """Test that ImageBasedConcept is not compatible with native Text.""" |
| 171 | + # Test: ImageBasedConcept should NOT be compatible with native Text |
| 172 | + result = concept_provider.is_compatible_by_concept_code( |
| 173 | + tested_concept_code="concept_library_tests.ImageBasedConcept", wanted_concept_code="native.Text" |
| 174 | + ) |
| 175 | + assert result is False, "ImageBasedConcept should not be compatible with native Text" |
| 176 | + |
| 177 | + def test_is_compatible_by_concept_code_documentation_concept_vs_fundamentals_doc(self, concept_provider: ConceptProviderAbstract): |
| 178 | + """Test that DocumentationConcept is compatible with FundamentalsDoc.""" |
| 179 | + # Test: DocumentationConcept should be compatible with FundamentalsDoc |
| 180 | + result = concept_provider.is_compatible_by_concept_code( |
| 181 | + tested_concept_code="concept_library_tests.DocumentationConcept", wanted_concept_code="concept_library_tests.FundamentalsDoc" |
| 182 | + ) |
| 183 | + assert result is True, "DocumentationConcept should be compatible with FundamentalsDoc" |
| 184 | + |
| 185 | + def test_is_compatible_by_concept_code_specialized_doc_vs_fundamentals_doc(self, concept_provider: ConceptProviderAbstract): |
| 186 | + """Test that SpecializedDoc is compatible with FundamentalsDoc.""" |
| 187 | + # Test: SpecializedDoc should be compatible with FundamentalsDoc |
| 188 | + result = concept_provider.is_compatible_by_concept_code( |
| 189 | + tested_concept_code="concept_library_tests.SpecializedDoc", wanted_concept_code="concept_library_tests.FundamentalsDoc" |
| 190 | + ) |
| 191 | + assert result is True, "SpecializedDoc should be compatible with FundamentalsDoc" |
| 192 | + |
| 193 | + def test_is_compatible_by_concept_code_multimedia_concept_vs_text(self, concept_provider: ConceptProviderAbstract): |
| 194 | + """Test that MultiMediaConcept is compatible with Text (multiple inheritance).""" |
| 195 | + # Test: MultiMediaConcept should be compatible with Text |
| 196 | + result = concept_provider.is_compatible_by_concept_code( |
| 197 | + tested_concept_code="concept_library_tests.MultiMediaConcept", wanted_concept_code="native.Text" |
| 198 | + ) |
| 199 | + assert result is True, "MultiMediaConcept should be compatible with Text" |
| 200 | + |
| 201 | + def test_is_compatible_by_concept_code_multimedia_concept_vs_image(self, concept_provider: ConceptProviderAbstract): |
| 202 | + """Test that MultiMediaConcept is compatible with Image (multiple inheritance).""" |
| 203 | + # Test: MultiMediaConcept should be compatible with Image |
| 204 | + result = concept_provider.is_compatible_by_concept_code( |
| 205 | + tested_concept_code="concept_library_tests.MultiMediaConcept", wanted_concept_code="native.Image" |
| 206 | + ) |
| 207 | + assert result is True, "MultiMediaConcept should be compatible with Image" |
| 208 | + |
| 209 | + def test_is_compatible_by_concept_code_independent_concept_vs_text(self, concept_provider: ConceptProviderAbstract): |
| 210 | + """Test that IndependentConcept is not compatible with Text.""" |
| 211 | + # Test: IndependentConcept should NOT be compatible with Text (no refines) |
| 212 | + result = concept_provider.is_compatible_by_concept_code( |
| 213 | + tested_concept_code="concept_library_tests.IndependentConcept", wanted_concept_code="native.Text" |
| 214 | + ) |
| 215 | + assert result is False, "IndependentConcept should not be compatible with Text" |
| 216 | + |
| 217 | + def test_is_compatible_by_concept_code_derived_text_concept_vs_text(self, concept_provider: ConceptProviderAbstract): |
| 218 | + """Test that DerivedTextConcept is compatible with Text (inheritance chain).""" |
| 219 | + # Test: DerivedTextConcept should be compatible with Text (through ExplicitTextConcept) |
| 220 | + result = concept_provider.is_compatible_by_concept_code( |
| 221 | + tested_concept_code="concept_library_tests.DerivedTextConcept", wanted_concept_code="native.Text" |
| 222 | + ) |
| 223 | + assert result is True, "DerivedTextConcept should be compatible with Text through inheritance chain" |
| 224 | + |
| 225 | + def test_is_compatible_by_concept_code_derived_text_concept_vs_explicit_text(self, concept_provider: ConceptProviderAbstract): |
| 226 | + """Test that DerivedTextConcept is compatible with ExplicitTextConcept (direct inheritance).""" |
| 227 | + # Test: DerivedTextConcept should be compatible with ExplicitTextConcept |
| 228 | + result = concept_provider.is_compatible_by_concept_code( |
| 229 | + tested_concept_code="concept_library_tests.DerivedTextConcept", wanted_concept_code="concept_library_tests.ExplicitTextConcept" |
| 230 | + ) |
| 231 | + assert result is True, "DerivedTextConcept should be compatible with ExplicitTextConcept" |
0 commit comments