@@ -49,18 +49,23 @@ def _find_latest(uris):
4949# Look directly at the latest schemas storage directory to infer latest schemas
5050_LATEST_DIR = Path (__file__ ).parent .parent .absolute () / "latest"
5151_LATEST_PATHS = MappingProxyType (
52- {latest_path : yaml .safe_load (latest_path .read_bytes ()) for latest_path in _LATEST_DIR .glob ("**/*.yaml" )}
52+ {
53+ latest_path .relative_to (_LATEST_DIR ): yaml .safe_load (latest_path .read_bytes ())
54+ for latest_path in _LATEST_DIR .glob ("**/*.yaml" )
55+ }
5356)
54- _LATEST_TOP_LEVEL_PATHS = tuple (latest_path for latest_path in _LATEST_PATHS if latest_path .parent == _LATEST_DIR )
5557_LATEST_URI_PATHS = MappingProxyType ({schema ["id" ]: path for path , schema in _LATEST_PATHS .items ()})
56- _LATEST_URIS = tuple (_LATEST_URI_PATHS .keys ())
57- _LATEST_MANIFEST_URIS = tuple (uri for uri in _LATEST_URIS if "manifests" in uri )
58+ _LATEST_MANIFEST_URIS = MappingProxyType (
59+ {schema ["id" ]: schema for schema in _LATEST_PATHS .values () if "manifests" in schema ["id" ]}
60+ )
61+ _LATEST_TOP_LEVEL_PATHS = tuple (latest_path for latest_path in _LATEST_PATHS if latest_path .parent == Path ("." ))
62+
5863_LATEST_MANIFEST_TAGS = MappingProxyType (
59- {uri : tuple (entry ["tag_uri" ] for entry in _CURRENT_RESOURCES [ uri ][ "tags" ]) for uri in _LATEST_MANIFEST_URIS }
64+ {uri : tuple (entry ["tag_uri" ] for entry in schema [ "tags" ]) for uri , schema in _LATEST_MANIFEST_URIS . items () }
6065)
6166_LATEST_DATAMODELS_URI = next (uri for uri in _LATEST_MANIFEST_URIS if "static" not in uri )
6267_LATEST_STATIC_URI = next (uri for uri in _LATEST_MANIFEST_URIS if "static" in uri )
63- _LATEST_DATAMODEL_URIS = tuple (uri ["schema_uri" ] for uri in _CURRENT_RESOURCES [_LATEST_DATAMODELS_URI ]["tags" ])
68+ _LATEST_DATAMODEL_URIS = tuple (uri ["schema_uri" ] for uri in _LATEST_MANIFEST_URIS [_LATEST_DATAMODELS_URI ]["tags" ])
6469_LATEST_ARCHIVE_URIS = tuple (schema ["id" ] for schema in _LATEST_PATHS .values () if "archive_meta" in schema )
6570
6671
@@ -121,6 +126,22 @@ def latest_path(request):
121126 return request .param
122127
123128
129+ @pytest .fixture (scope = "session" )
130+ def latest_schema (latest_path ):
131+ """
132+ Get the latest schema from a latest path.
133+ """
134+ return _LATEST_PATHS [latest_path ]
135+
136+
137+ @pytest .fixture (scope = "session" )
138+ def latest_uri (latest_schema ):
139+ """
140+ Get a latest resource URI
141+ """
142+ return latest_schema ["id" ]
143+
144+
124145@pytest .fixture (scope = "session" , params = _LATEST_ARCHIVE_URIS )
125146def latest_archive_uri (request ):
126147 """
@@ -138,19 +159,27 @@ def latest_dir():
138159
139160
140161@pytest .fixture (scope = "session" )
141- def latest_reference_files_dir (latest_dir ):
162+ def latest_datamodels_dir ():
163+ """
164+ Get the path to the latest datamodels directory.
165+ """
166+ return Path ("." )
167+
168+
169+ @pytest .fixture (scope = "session" )
170+ def latest_reference_files_dir (latest_datamodels_dir ):
142171 """
143172 Get the path to the latest reference files directory.
144173 """
145- return latest_dir / "reference_files"
174+ return latest_datamodels_dir / "reference_files"
146175
147176
148177@pytest .fixture (scope = "session" )
149- def latest_ccsp_dir (latest_dir ):
178+ def latest_ccsp_dir (latest_datamodels_dir ):
150179 """
151180 Get the path to the latest CCSP schemas directory.
152181 """
153- return latest_dir / "CCSP"
182+ return latest_datamodels_dir / "CCSP"
154183
155184
156185@pytest .fixture (scope = "session" , params = _LATEST_TOP_LEVEL_PATHS )
@@ -161,28 +190,12 @@ def latest_top_level_path(request):
161190 return request .param
162191
163192
164- @pytest .fixture (scope = "session" )
165- def latest_uri_paths ():
166- """
167- Get the mapping of latest URIs to their paths.
168- """
169- return _LATEST_URI_PATHS
170-
171-
172193@pytest .fixture (scope = "session" )
173194def latest_uris ():
174195 """
175196 Get the URIs of the latest schemas.
176197 """
177- return _LATEST_URIS
178-
179-
180- @pytest .fixture (scope = "session" , params = _LATEST_URIS )
181- def latest_uri (request ):
182- """
183- Get a latest resource URI
184- """
185- return request .param
198+ return _LATEST_URI_PATHS
186199
187200
188201@pytest .fixture (scope = "session" )
@@ -235,11 +248,14 @@ def latest_static_tag_uri(request):
235248
236249
237250@pytest .fixture (scope = "session" )
238- def latest_schemas (latest_paths , latest_uris ):
251+ def latest_schemas (latest_dir , latest_paths , latest_uris ):
239252 """
240253 Get the text of the latest schemas.
241254 """
242- return {latest_uri : latest_path .read_text () for latest_uri , latest_path in zip (latest_uris , latest_paths , strict = True )}
255+ return {
256+ latest_uri : (latest_dir / latest_path ).read_text ()
257+ for latest_uri , latest_path in zip (latest_uris , latest_paths , strict = True )
258+ }
243259
244260
245261@pytest .fixture (scope = "session" , params = tuple (entry ["tag_uri" ] for entry in _CURRENT_RESOURCES [_PREVIOUS_DATAMODELS_URI ]["tags" ]))
@@ -353,7 +369,7 @@ def schema_uris():
353369 return _SCHEMA_URIS
354370
355371
356- @pytest .fixture (scope = "session" , params = tuple (uri for uri in _LATEST_URIS if uri in _SCHEMA_URIS ))
372+ @pytest .fixture (scope = "session" , params = tuple (uri for uri in _LATEST_URI_PATHS if uri in _SCHEMA_URIS ))
357373def schema_uri (request ):
358374 """
359375 Get a URI for a RAD schema from the ASDF resource manager.
@@ -366,15 +382,18 @@ def schema_uri(request):
366382 return request .param
367383
368384
369- @pytest .fixture (scope = "session" , params = tuple (uri for uri in _LATEST_URIS if "/reference_files" in uri and uri in _SCHEMA_URIS ))
385+ @pytest .fixture (
386+ scope = "session" , params = tuple (uri for uri in _LATEST_URI_PATHS if "/reference_files" in uri and uri in _SCHEMA_URIS )
387+ )
370388def ref_file_uri (request ):
371389 """
372- Get a URI related to the RAD reference files from the ASDF resource manager.
390+ Get a URI related to the RAD reference files from the ASDF r
391+ esource manager.
373392 """
374393 return request .param
375394
376395
377- @pytest .fixture (scope = "session" , params = tuple (uri for uri in _LATEST_URIS if "/CCSP" in uri and uri in _SCHEMA_URIS ))
396+ @pytest .fixture (scope = "session" , params = tuple (uri for uri in _LATEST_URI_PATHS if "/CCSP" in uri and uri in _SCHEMA_URIS ))
378397def ccsp_uri (request ):
379398 """
380399 Get a URI related to the RAD CCSP schemas.
0 commit comments