Skip to content

Commit d0668de

Browse files
committed
added basic tests
1 parent 02c6301 commit d0668de

File tree

6 files changed

+56
-2
lines changed

6 files changed

+56
-2
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.ipynb_checkpoints
2+
__pycache__
13
archive
24
docs/build
3-
.ipynb_checkpoints
5+
venv

README.md

+23
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,26 @@ To build documentation locally, type:
7575
Then, open `docs/build/html/index.html`. The above make command
7676
should build docs when source changes. (Some types of changes require
7777
recleaning and building.)
78+
79+
80+
# Testing
81+
82+
The VRS repo contains two kinds of tests. Basic smoketests in `tests/`
83+
ensure that the schema is parseable and works with certain tools.
84+
These tests provide a basic sanity check during development.
85+
86+
Validation tests (in `validation/`) provide language-neutral tests for
87+
those implementing tools with VRS.
88+
89+
## Using smoketests
90+
91+
The smoketests require python 3.8+. This is the recommended setup:
92+
93+
```
94+
$ python3 -m venv venv
95+
$ source venv/bin/activate
96+
$ pip install -U setuptools pip
97+
$ pip install -r requirements.txt
98+
$ pytest
99+
100+
```

requirements.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
ipython >= 7.5.0
1+
pytest
2+
python-jsonschema-objects>=0.3,<=0.3.10
3+
pyyaml

setup.cfg

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[tool:pytest]

tests/config.py

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from pathlib import Path
2+
3+
import pytest
4+
5+
root_dir = Path(__file__).parent.parent
6+
schema_dir = root_dir / "schema"
7+
vrs_yaml_path = schema_dir / "vrs.yaml"
8+
vrs_json_path = schema_dir / "vrs.json"
9+

tests/test_basic.py

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import json
2+
3+
import python_jsonschema_objects as pjs
4+
import yaml
5+
6+
from config import vrs_json_path, vrs_yaml_path
7+
8+
9+
# Are the yaml and json parseable and do they match?
10+
y = yaml.load(open(vrs_yaml_path), Loader=yaml.SafeLoader)
11+
j = json.load(open(vrs_json_path))
12+
assert y == j, "parsed yaml and json do not match"
13+
14+
15+
# Can pjs handle this schema?
16+
ob = pjs.ObjectBuilder("schema/vrs.json")
17+
ob.build_classes() # no exception => okay

0 commit comments

Comments
 (0)