Skip to content

Commit

Permalink
♻️ Move petstore openapi document to src/openapi to resemble project …
Browse files Browse the repository at this point in the history
…made with init command.
  • Loading branch information
rafalkrupinski committed May 25, 2024
1 parent e0e7ceb commit 082b0e1
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion tests/e2e/expected/petstore/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ lapidary = {path="../../../.."}
lapidary-render = "^0.9.0"

[tool.lapidary]
document_path = "src/openapi/openapi.json"
origin = "https://petstore3.swagger.io/api/v3/openapi.json"
package = "test_petstore"
document_path = "petstore.json"
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/e2e/init/petstore/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ lapidary = {path="../../../.."}
lapidary-render = "^0.9.0"

[tool.lapidary]
document_path = "src/openapi/openapi.json"
origin = "https://petstore3.swagger.io/api/v3/openapi.json"
package = "test_petstore"
document_path = "petstore.json"
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/process/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

@pytest.fixture
def document() -> openapi.OpenApiModel:
doc_text = (Path(__file__).parent.parent / 'e2e/init/petstore/petstore.json').read_text()
doc_text = (Path(__file__).parent.parent / 'e2e/init/petstore/src/openapi/openapi.json').read_text()
return openapi.OpenApiModel.model_validate_json(doc_text)


Expand Down
10 changes: 6 additions & 4 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ async def test_init_save_copies_document(monkeypatch, tmp_path: pathlib.Path) ->
output = tmp_path / 'output'
from lapidary.render.cli import app

with unittest.mock.patch('rybak.TreeTemplate') as mock:
result = await runner.invoke(app, ('init', '--save', str(source), str(output), 'petstore'))
result = await runner.invoke(app, ('init', '--save', str(source), str(output), 'petstore'))
if result.exception:
raise result.exception
mock().render.assert_called()
assert result.exit_code == 0
assert (output / 'src/openapi/petstore.json').is_file()
assert (output / 'src/openapi/openapi.json').is_file()

config = await load_config(anyio.Path(output))
assert config.origin is None
assert config.document_path == 'src/openapi/openapi.json'


@pytest.mark.asyncio
Expand Down

0 comments on commit 082b0e1

Please sign in to comment.