Skip to content

Commit d1ccb04

Browse files
author
David Andersson
committed
add caching validation
1 parent 0f60507 commit d1ccb04

4 files changed

Lines changed: 15 additions & 3 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ venv36
2222
coverage.xml
2323
docs/source/_*
2424
__pycache__
25+
__open_alchemy_*_cache__

open_alchemy/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def init_model_factory(
6464
schemas = components.get("schemas", {})
6565

6666
# Pre-processing schemas
67-
_schemas_module.process(schemas=schemas)
67+
_schemas_module.process(schemas=schemas, spec_filename=spec_path)
6868

6969
# Getting artifacts
7070
schemas_artifacts = _schemas_artifacts.get_from_schemas(

open_alchemy/schemas/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
"""Performs operations on the schemas to prepare them for further processing."""
22

3+
import typing
4+
35
from .. import types as _types
46
from . import association
57
from . import backref
68
from . import foreign_key
79
from . import validation
810

911

10-
def process(*, schemas: _types.Schemas) -> None:
12+
def process(
13+
*, schemas: _types.Schemas, spec_filename: typing.Optional[str] = None
14+
) -> None:
1115
"""
1216
Pre-process schemas.
1317
@@ -18,7 +22,7 @@ def process(*, schemas: _types.Schemas) -> None:
1822
schemas: The schemas to pre-process in place.
1923
2024
"""
21-
validation.process(schemas=schemas)
25+
validation.process(schemas=schemas, spec_filename=spec_filename)
2226
backref.process(schemas=schemas)
2327
foreign_key.process(schemas=schemas)
2428
association.process(schemas=schemas)

tests/open_alchemy/integration/test_init.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import yaml
99

1010
import open_alchemy
11+
from open_alchemy import cache
1112
from open_alchemy.facades.sqlalchemy import types as sqlalchemy_types
1213

1314

@@ -236,6 +237,9 @@ def test_init_json(engine, sessionmaker, tmp_path):
236237
queried_model = session.query(model).first()
237238
assert queried_model.column == value
238239

240+
# Checking for cache
241+
assert cache.schemas_valid(str(spec_file)) is True
242+
239243

240244
@pytest.mark.integration
241245
def test_init_json_remote(engine, sessionmaker, tmp_path, _clean_remote_schemas_store):
@@ -315,6 +319,9 @@ def test_init_yaml(engine, sessionmaker, tmp_path):
315319
queried_model = session.query(model).first()
316320
assert queried_model.column == value
317321

322+
# Checking for cache
323+
assert cache.schemas_valid(str(spec_file)) is True
324+
318325

319326
@pytest.mark.integration
320327
def test_init_yaml_remote(engine, sessionmaker, tmp_path, _clean_remote_schemas_store):

0 commit comments

Comments
 (0)