1313# See the License for the specific language governing permissions and
1414# limitations under the License.
1515
16- """Tests for the pure in-memory methods of AEMPackRegistry.
17-
18- These tests run against a ``mock_registry`` (collaborators are mocks) and do
19- not need MongoDB or Kafka. Covered methods:
20-
21- * ``_create_aem_pack`` and ``_apply_workflow_to_data`` — wrapper helpers
22- * ``_traverse_graph`` — the routing/publishing core, exercised with a range of
23- graph topologies
24- """
16+ """Tests for the in-memory methods of AEMPackRegistry."""
2517
2618from uuid import uuid4
2719
2820import pytest
2921from pydantic import UUID4
30- from schemapack .spec .datapack import DataPack
3122
3223from ets .core .aem_pack_registry import AEMPackRegistry
3324from ets .core .models import AEMPack , Model , PersistedConfig
@@ -44,7 +35,7 @@ def _ingress_model(config: PersistedConfig) -> Model:
4435
4536
4637def _ingress_for (config : PersistedConfig , name : str | None = None ) -> AEMPack :
47- """Build an ingress AEMPack (defaults to the configured ingress model) ."""
38+ """Build an ingress AEMPack. Defaults to the configured ingress model."""
4839 return AEMPack (
4940 id = uuid4 (),
5041 model_name = name or _ingress_model (config ).name ,
@@ -60,7 +51,7 @@ def _traverse(
6051 dirty_map : dict [str , UUID4 ],
6152 config : PersistedConfig ,
6253) -> tuple [list [AEMPack ], dict [str , UUID4 ]]:
63- """Run `` _traverse_graph`` seeding `` transformed_map` ` with the incoming pack."""
54+ """Run `_traverse_graph` seeding `transformed_map` with the incoming pack."""
6455 return mock_registry ._traverse_graph (
6556 incoming = incoming ,
6657 dirty_map = dirty_map ,
@@ -69,9 +60,6 @@ def _traverse(
6960 )
7061
7162
72- # --- _create_aem_pack / _apply_workflow_to_data ------------------------------
73-
74-
7563@pytest .mark .parametrize (
7664 "aem_id,expected_aem_id" ,
7765 [(None , False ), (EXPECTED_AEM_ID , True )],
@@ -80,7 +68,7 @@ def _traverse(
8068def test_create_aem_pack (
8169 mock_registry : AEMPackRegistry , aem_id : UUID4 | None , expected_aem_id : bool
8270):
83- """Creating an AEMPack wrapper, with and without a pre-specified ID."""
71+ """Ensure creating an AEMPack wrapper works , with and without a pre-specified ID."""
8472 aem_pack = mock_registry ._create_aem_pack (
8573 aem_id = aem_id ,
8674 model_name = "TestModel" ,
@@ -98,26 +86,6 @@ def test_create_aem_pack(
9886 assert aem_pack .id == EXPECTED_AEM_ID
9987
10088
101- def test_apply_workflow_to_data (mock_registry : AEMPackRegistry ):
102- """Applying a workflow transforms only the schema, not the resource data."""
103- config = load_aem_pack_config (AEM_PACK_REGISTRY_CONFIGS ["single_route" ])
104- ingress = _ingress_model (config )
105-
106- result = mock_registry ._apply_workflow_to_data (
107- data = TEST_DATAPACK ,
108- annotation = {},
109- input_schema = ingress .schema_ ,
110- workflow = config .workflows [0 ],
111- )
112-
113- assert isinstance (result , DataPack )
114- # rename_id_property only modifies the schema, not the resource data.
115- assert result .resources == TEST_DATAPACK .resources
116-
117-
118- # --- _traverse_graph ---------------------------------------------------------
119-
120-
12189@pytest .mark .parametrize (
12290 "aem_pack_config, dirty_names" ,
12391 [
@@ -148,8 +116,8 @@ def test_clears_dirty_map(
148116 aem_pack_config : PersistedConfig ,
149117 dirty_names : set [str ],
150118):
151- """Traversal clears all non-dangling dirty map entries and only publishes
152- derived packs whose model has `` publish=True` `.
119+ """Ensure traversal clears all non-dangling dirty map entries and only publishes
120+ derived packs whose model has `publish=True`.
153121 """
154122 incoming = _ingress_for (aem_pack_config )
155123 dirty_map : dict [str , UUID4 ] = {name : uuid4 () for name in dirty_names }
@@ -165,7 +133,7 @@ def test_clears_dirty_map(
165133
166134
167135def test_respects_topological_order (mock_registry : AEMPackRegistry ):
168- """Routes are processed in topological order regardless of fixture listing order."""
136+ """Ensure routes are processed in topological order regardless of fixture listing order."""
169137 config = load_aem_pack_config (AEM_PACK_REGISTRY_CONFIGS ["forking_routes" ])
170138 # Swap orders so DerivedModel2 (order=1) is processed before DerivedModel1 (order=2)
171139 by_name = {model .name : model for model in config .models }
@@ -203,9 +171,7 @@ def test_dirty_map_id_handling(
203171 have_dirty_map : bool ,
204172 expected_published : int ,
205173):
206- """With a dirty map, derived packs reuse the supplied UUIDs; without one,
207- fresh UUIDs are generated for each derived pack.
208- """
174+ """Ensure derived packs reuse the supplied UUIDs from the dirty map."""
209175 config = load_aem_pack_config (
210176 AEM_PACK_REGISTRY_CONFIGS [config_name ], publish_models = publish
211177 )
@@ -246,7 +212,7 @@ def test_bottleneck_topology(
246212 aem_pack_config : PersistedConfig ,
247213 ingress_name : str ,
248214):
249- """Traversal from each ingress through a bottleneck publishes downstream
215+ """Ensure traversal from each ingress through a bottleneck publishes downstream
250216 and reuses existing dirty-map IDs for the derived packs.
251217 """
252218 incoming = _ingress_for (aem_pack_config , name = ingress_name )
0 commit comments