Skip to content

Commit 2a79c14

Browse files
author
David Andersson
committed
add cache to be generated into the build
1 parent d1ccb04 commit 2a79c14

4 files changed

Lines changed: 19 additions & 5 deletions

File tree

open_alchemy/build/MANIFEST.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
recursive-include {{ name }} *.json
1+
recursive-include {{ name }} *.json __open_alchemy_*_cache__
22
remove .*
33

open_alchemy/build/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import jinja2
1212

13+
from .. import cache
1314
from .. import exceptions
1415
from .. import models_file as models_file_module
1516
from .. import schemas as schemas_module
@@ -336,7 +337,9 @@ def dump(
336337
# Write files in the package directory.
337338
package = directory / name
338339
package.mkdir(parents=True, exist_ok=True)
339-
(package / "spec.json").write_text(spec_str)
340+
spec_file = package / "spec.json"
341+
spec_file.write_text(spec_str)
342+
cache.schemas_are_valid(str(spec_file))
340343
(package / "__init__.py").write_text(init)
341344
except OSError as exc:
342345
raise exceptions.BuildError(str(exc)) from exc

open_alchemy/build/setup.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ setuptools.setup(
44
name="{{ name }}",
55
version="{{ version }}",
66
packages=setuptools.find_packages(),
7-
python_requires=">=3.6",
7+
python_requires=">=3.7",
88
install_requires=[
99
"OpenAlchemy",
1010
],

tests/open_alchemy/test_build.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import pytest
44

55
from open_alchemy import build
6+
from open_alchemy import cache
67
from open_alchemy import exceptions
78
from open_alchemy.helpers import command
89

@@ -221,7 +222,7 @@ def test_generate_setup():
221222
name="name 1",
222223
version="version 1",
223224
packages=setuptools.find_packages(),
224-
python_requires=">=3.6",
225+
python_requires=">=3.7",
225226
install_requires=[
226227
"OpenAlchemy",
227228
],
@@ -243,7 +244,7 @@ def test_generate_manifest():
243244

244245
returned_contents = build.generate_manifest(name=name)
245246

246-
expected_contents = """recursive-include name 1 *.json
247+
expected_contents = """recursive-include name 1 *.json __open_alchemy_*_cache__
247248
remove .*
248249
"""
249250

@@ -444,6 +445,11 @@ def test_dump(tmp_path):
444445
with open(expected_spec_path) as in_file:
445446
assert in_file.read() == spec_str
446447

448+
# Check cache
449+
expected_cache_path = cache.calculate_cache_path(expected_spec_path)
450+
assert expected_cache_path.is_file()
451+
assert cache.schemas_valid(str(expected_spec_path))
452+
447453
# Check init file
448454
expected_init_path = package_path / "__init__.py"
449455
assert expected_init_path.is_file()
@@ -691,6 +697,11 @@ def test_execute(tmp_path, package_format, extensions):
691697
assert "Schema" in spec_file_contents
692698
assert "x-tablename" in spec_file_contents
693699

700+
# Check cache
701+
expected_cache_path = cache.calculate_cache_path(expected_spec_path)
702+
assert expected_cache_path.is_file()
703+
assert cache.schemas_valid(str(expected_spec_path))
704+
694705
# Check init file
695706
expected_init_path = package_path / "__init__.py"
696707
assert expected_init_path.is_file()

0 commit comments

Comments
 (0)