Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allowing sdists to be packaged with tests #53

Merged
merged 7 commits into from
Jan 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/python-package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,14 @@ jobs:
run: |
ls dist
PACKAGE=`ls dist/jsf-*.tar.gz`
# Validate the CLI works
pip3 install $PACKAGE\[cli\]
jsf --help
# Validate the sdist tests work for conda
tar -xvf $PACKAGE
cd jsf-*
pip install pytest
pytest
- name: Upload coverage
uses: codecov/codecov-action@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Application
*.json
!src/tests/data/*.json
!jsf/tests/data/*.json
TODO.md

# MacOS
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
2 changes: 1 addition & 1 deletion README.md
4 changes: 2 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ fake_json = faker.generate()
#### Raw install

```bash
jsf --schema src/tests/data/custom.json --instance wow.json
jsf --schema jsf/tests/data/custom.json --instance wow.json
```

#### Docker

```bash
docker build . -t challisa/jsf
docker run -v $PWD:/data challisa/jsf jsf --schema /data/src/tests/data/custom.json --instance /data/wow.json
docker run -v $PWD:/data challisa/jsf jsf --schema /data/jsf/tests/data/custom.json --instance /data/wow.json
```
2 changes: 1 addition & 1 deletion examples/fastapi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
Using `api.py` and `custom.json` in current example folder

```bash
datamodel-codegen --input src/tests/data/custom.json --output model.py
datamodel-codegen --input jsf/tests/data/custom.json --output model.py
uvicorn api:app --reload --host 0.0.0.0 --port 8080
```
6 changes: 5 additions & 1 deletion src/jsf/BUILD → jsf/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ python_distribution(
"jsf": "jsf.cli:app"
},
},
dependencies=[":src", ":build_resources"],
dependencies=[
":src",
":build_resources",
"./tests:tests",
],
long_description_path="README.md",
provides=python_artifact(
name="jsf",
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/jsf/README.md → jsf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ fake_json = faker.generate()

```bash
pip install jsf[cli]
jsf --schema src/tests/data/custom.json --instance wow.json
jsf --schema jsf/tests/data/custom.json --instance wow.json
```

#### Docker
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 4 additions & 3 deletions src/tests/BUILD → jsf/tests/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ python_test_utils(
)

files(
name="test_data",
sources=["data/*.json"]
name="tests",
sources=["data/*.json", "*.py"]
)

python_tests(
dependencies=[":test_data"],
name="pytest",
dependencies=[":tests"],
interpreter_constraints=parametrize(py3=[">=3.7,<4"]),
)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"$ref": "#/definitions/LocalType"
},
"ReferenceToExternalSchema": {
"$ref": "file://src/tests/data/external-ref-common.json#/definitions/ExternalType"
"$ref": "file://jsf/tests/data/external-ref-common.json#/definitions/ExternalType"
}
},
"definitions": {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 1 addition & 2 deletions src/tests/test_cli.py → jsf/tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import json
from pathlib import Path

from jsf.cli import app
from jsonschema import validate
from typer.testing import CliRunner

from jsf.cli import app

runner = CliRunner()


Expand Down
File renamed without changes.
3 changes: 1 addition & 2 deletions src/tests/test_model_gen.py → jsf/tests/test_model_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
from typing import List

import pytest # pants: no-infer-dep
from pydantic.main import create_model

from jsf.parser import JSF
from pydantic.main import create_model

Object = create_model("Object")

Expand Down
2 changes: 1 addition & 1 deletion src/tests/test_parser.py → jsf/tests/test_parser.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import json

import pytest # pants: no-infer-dep

from jsf.parser import JSF

from jsf.schema_types import (
Array,
Boolean,
Expand Down
File renamed without changes.
5 changes: 1 addition & 4 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,11 @@ plugins:
default_handler: python
handlers:
python:
setup_commands:
- import sys
- sys.path.append("src")
rendering:
show_root_heading: no
show_if_no_docstring: no
watch:
- src/jsf
- jsf

extra:
social:
Expand Down
5 changes: 0 additions & 5 deletions pants.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ backend_packages = [
[python]
interpreter_constraints = ["CPython>=3.7,<4"]

[source]
root_patterns = [
'/src',
]

[flake8]
config = ".flake8"

Expand Down
Empty file removed src/tests/__init__.py
Empty file.