From c175a167f6d04be2054a4ffbeb47030db70c6f8f Mon Sep 17 00:00:00 2001 From: Ivan Subotic Date: Thu, 6 Jun 2019 21:00:27 +0200 Subject: [PATCH] chore: add testing (ongoing) --- README.md | 8 ++++++++ knora/__init__.py | 1 + requirements.txt | 1 + {knora => tests}/test-onto.json | 0 tests/test_create_ontology.py | 18 ++++++++++++++++++ .../test_create_resource.py | 4 ++-- 6 files changed, 30 insertions(+), 2 deletions(-) rename {knora => tests}/test-onto.json (100%) create mode 100644 tests/test_create_ontology.py rename knora/test-create-resource.py => tests/test_create_resource.py (93%) diff --git a/README.md b/README.md index dbe5438db..0f2a08e92 100644 --- a/README.md +++ b/README.md @@ -564,3 +564,11 @@ For local development: ```bash $ python3 setup.py develop ``` + +## Testing + +```bash +$ pip3 install pytest +$ pip3 install --editable . +$ pytest +``` diff --git a/knora/__init__.py b/knora/__init__.py index 32a97b341..52f3d946c 100644 --- a/knora/__init__.py +++ b/knora/__init__.py @@ -1,5 +1,6 @@ from .knora import KnoraError from .knora import Knora +from .knora import Sipi from .knora import BulkImport from .knora import IrisLookup from .knora import ListsLookup diff --git a/requirements.txt b/requirements.txt index c1f84e6e4..47e32b8b9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,3 +3,4 @@ setuptools wheel tqdm twine +pytest diff --git a/knora/test-onto.json b/tests/test-onto.json similarity index 100% rename from knora/test-onto.json rename to tests/test-onto.json diff --git a/tests/test_create_ontology.py b/tests/test_create_ontology.py new file mode 100644 index 000000000..2907170b8 --- /dev/null +++ b/tests/test_create_ontology.py @@ -0,0 +1,18 @@ +import pytest + +# we reuse a bit of pytest's own testing machinery, this should eventually come +# from a separatedly installable pytest-cli plugin. +pytest_plugins = ["pytester"] + +@pytest.fixture +def run(testdir): + def do_run(*args): + args = ["knora-create-ontology"] + list(args) + return testdir._run(*args) + return do_run + + +def test_create_test_onto(tmpdir, run): + input = tmpdir.join("test-onto.json") + result = run(input) + assert result.ret == 0 diff --git a/knora/test-create-resource.py b/tests/test_create_resource.py similarity index 93% rename from knora/test-create-resource.py rename to tests/test_create_resource.py index dfb91bc48..b2b241a30 100644 --- a/knora/test-create-resource.py +++ b/tests/test_create_resource.py @@ -4,7 +4,7 @@ import argparse import json from jsonschema import validate -from knora import KnoraError, knora, Sipi +from knora import KnoraError, Knora, Sipi parser = argparse.ArgumentParser() @@ -18,7 +18,7 @@ args = parser.parse_args() -con = knora(args.server, args.user, args.password) +con = Knora(args.server, args.user, args.password) graph = con.get_ontology_graph('00FE', 'kpt') #print(graph) #exit(0)