diff --git a/MANIFEST.in b/MANIFEST.in index dad66e3..14dac13 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -2,7 +2,6 @@ include ./tdd/*.py include ./tdd/data/*.ttl include ./tdd/data/*.json include ./tdd/lib/*.js -recursive-include tdd/jsonld *.js include ./scripts/*.py @@ -16,23 +15,11 @@ include package.json include package-lock.json include config.toml -include deployment/*.yaml - include fuseki-docker/**/*.ttl include fuseki-docker/*.ttl -include fuseki-docker/databases/.hg_keep - -exclude .gitlab-ci.yml -exclude .gitlab-ci-extended.yml -exclude pytest.ini -recursive-exclude tests *.json -recursive-exclude tests *.py -recursive-exclude tests *.jsonld -recursive-exclude tests *.ttl -recursive-exclude tests *.nquads -exclude tests/data/smart-coffee-machine.n3 -exclude tests/data/smart-coffee-machine.xml +recursive-include tdd/tests/data *.json *.jsonld *.nquads *.ttl *.xml *.n3 +recursive-include tdd/tests *.py prune doc prune node_modules diff --git a/README.md b/README.md index ffea584..29b6da9 100644 --- a/README.md +++ b/README.md @@ -183,3 +183,14 @@ black . flake8 pytests tests ``` + +## Plugin + +To use a specific plugin you can juste pip install the module and relaunch your +TDD-API server. The new plugins routes and transformers will then be available. + +### Develop your own plugin + +You can develop your own plugin to add features to your TDD-API server. +To do so you can create a new project and follow the instructions defined in the +[Plugin Documentation](doc/plugin.md) to add it to the TDD-API. diff --git a/doc/plugin.md b/doc/plugin.md new file mode 100644 index 0000000..9a18baa --- /dev/null +++ b/doc/plugin.md @@ -0,0 +1,134 @@ +# TDD-API Plugin + +You can find a plugin example here [https://github.com/wiresio/domus-tdd-api-plugin-example](https://github.com/wiresio/domus-tdd-api-plugin-example). + +To develop your own plugin, the first thing to do is to create a `setup.py` file +at the root of your new python project containing the usual python project information, +then add the entrypoints needed for TDD-API to consider it as a plugin. + +```python +#!/usr/bin/env python +from setuptools import setup, find_packages + +setup( + name="TDD API plugin Example", + version="1.0", + packages=find_packages(), + include_package_data=True, + zip_safe=False, + install_requires=[ + "tdd-api", + ], + extras_require={ + 'dev': [ + 'pytest', + 'mock', + ] + }, + entry_points={ + "tdd_api.plugins.blueprints": [ + "example=tdd_api_plugin_example:blueprint", + ], + "tdd_api.plugins.transformers": [ + "example=tdd_api_plugin_example.example:td_to_example", + ], + }, +) +``` + +We have defined two entrypoints. The first one is `tdd_api.plugins.blueprints` which is used to +define where to find the [Flask blueprint](https://flask.palletsprojects.com/en/3.0.x/blueprints/) for +the plugin. +The second one is `tdd_api.plugins.transformers` to specify the function to use to transform a TD to +what you want, here an `example`. + +Then you can develop the function for the routes using the blueprint and the transformer feature. + +## Blueprint + +As we defined in the [`tdd_api_plugin_example/__init__.py`](https://github.com/wiresio/tdd-api-plugin/blob/main/tdd_api_plugin_example/__init__.py) we define the blueprint +as follow: + +```python +blueprint = Blueprint("tdd_api_plugin_example", __name__, url_prefix="/example") +``` + +We can give any name to the variable since the `setup.py` links it to the `tdd_api.plugins.blueprints`. + +The first parameter `"tdd_api_plugin_example"` is the name of the blueprint, the second parameter is the +import module (here `__name__` since this is the same module) and we define a `url_prefix` to not redeclare it +on each route. +This `url_prefix` make sure that if we use different plugins, the routes they declare will be unique `/plugin1/route1`, `/plugin2/route1`. +This requires that all plugins have _different prefix_. + +This blueprint can be used to define all the routes you want to add to the TDD-API server regarding to +this plugin. +For example to add a `GET` route for the `Example` plugin you can add the route like this: + +```python +@blueprint.route("/", methods=["GET"]) +def describe_example(id): + return ... +``` + +We use the blueprint as decorator to add the route, the path is defined regarding the `url_prefix` and we +specify a dedicated method to match. +You can look at the [`tdd_api_plugin_example/__init__.py`](https://github.com/wiresio/tdd-api-plugin/blob/main/tdd_api_plugin_example/__init__.py) file to see +other examples. + +## Transformer + +Transformers are functions that will be called each time a thing is created/updated on the /things routes, +you can find the calls to these transformers in the [`tdd/__init__.py`](../tdd/__init__.py) file, in the functions: + +- `create_td` +- `update_td` +- `create_anonymous_td` + +We have defined a transformer to be sure, each time a TD is uploaded to transform it to our `example` format +and store in the SparqlEndpoint. To do, we declare the function to use in the entrypoint: here +`tdd_api_plugin_example.example:td_to_example` since we use the function `td_to_example` which is defined in the +`tdd_api_plugin_example/example.py` file. + +This method is declared like this: + +```python +def td_to_example(uri): + ... +``` + +The parameter must be only the TD URI as a string since we want to be the most generic as possible. Then the first +thing to do can be fetching the TD content, which can be done with: + +```python +content = get_id_description(uri, "application/n-triples", {"prefix": "td"}) +``` + +Using this content we can do whatever is needed to manipulate the data : transform it, +change its format, etc. +Then we can store the result using the helper method `put_json_in_sparql` or `put_rdf_in_sparql` from the +`tdd.common` module. +You can look at the [`tdd_api_plugin_example/example.py`](https://github.com/wiresio/blobl/main/tdd_api_plugin_example/example.py) file to see how it is defined. + +## Tests + +This example plugin come with some tests example to present how it can be done. +You can find it in the folder [`tdd_api_plugin_example/tests`](https://github.com/wiresio/blobl/main/tdd_api_plugin_example/tests). +`test_example.py` defines some tests for the `example.py` module, where the `test_td_to_example.py` +define tests for the routes. + +These tests simulate the existence of a real SparqlEndpoint using a RDFLib Graph abstraction. Then you +can specify a mock SparqlEndpoint prefilled with some data as it is defined with: + +```python +@pytest.fixture +def mock_sparql_example_and_td(httpx_mock): + graph = SparqlGraph("td_example.trig", format="trig", data_path=DATA_PATH) + httpx_mock.add_callback(graph.custom) +``` + +Where `DATA_PATH` is where the tests data are stored and `td_example.trig` the data to fill the SparqlEndpoint. + +There are some generic mocks defined in the `TDD-API` module. You have to import them to use them in your tests. +You can find for example the `mock_sparql_empty_endpoint` from `tdd.tests.conftest` module. This mock can be used +to simulate an empty SparqlEndpoint at the beginning of your test. diff --git a/setup.py b/setup.py index 6ed5589..7498cf7 100644 --- a/setup.py +++ b/setup.py @@ -32,6 +32,8 @@ "json-merge-patch", "python-configuration[toml]", "pyshacl", + "importlib-metadata", + "toml", ], extras_require={ "prod": [ diff --git a/tdd/__init__.py b/tdd/__init__.py index 1a7c857..b14d152 100644 --- a/tdd/__init__.py +++ b/tdd/__init__.py @@ -22,6 +22,7 @@ import json_merge_patch import httpx import toml +from importlib_metadata import entry_points from tdd.errors import ( @@ -44,6 +45,7 @@ ) from tdd.common import ( delete_id, + get_check_schema_from_url_params, ) from tdd.sparql import query, sparql_query from tdd.utils import ( @@ -59,6 +61,9 @@ LIMIT_SPARQLENDPOINT_TEST = 10 +TD_TRANSFORMERS = [] + + def wait_for_sparqlendpoint(): test_num = 0 while test_num < LIMIT_SPARQLENDPOINT_TEST: @@ -96,6 +101,25 @@ def create_app(): register_error_handler(app) register_routes(app) + # import all blueprints from imported modules + for entry_point in entry_points(group="tdd_api.plugins.blueprints"): + try: + app.register_blueprint(entry_point.load()) + except Exception as exc: + print(f"ERROR ({entry_point.name}): {exc}") + print( + f"Tried to {entry_point.value} but an error occurred, blueprint not loaded" + ) + # import all transformers from imported modules + for entry_point in entry_points(group="tdd_api.plugins.transformers"): + try: + TD_TRANSFORMERS.append(entry_point.load()) + except Exception as exc: + print(f"ERROR ({entry_point.name}): {exc}") + print( + f"Tried to load {entry_point.value} but an error occurred, transformer not loaded" + ) + # Launch thread to clear expired TDs periodically if CONFIG["PERIOD_CLEAR_EXPIRE_TD"] != 0: t = Thread(target=thread_clear_expire_td) @@ -130,13 +154,6 @@ def add_cors_headers(response): ) return response - def get_check_schema_from_url_params(request): - check_schema_param = request.args.get("check-schema") - check_schema = CONFIG["CHECK_SCHEMA"] - if check_schema_param in ["false", "False", "0"]: - check_schema = False - return check_schema - @app.route("/", methods=["GET"]) def directory_description(): with open("tdd/data/tdd-description.json", "r") as f: @@ -164,6 +181,8 @@ def create_td(id): ) else: raise WrongMimeType(mimetype) + for transformer in TD_TRANSFORMERS: + transformer(id) update_collection_etag() return Response(status=201 if not updated else 204, headers={"Location": uri}) @@ -184,6 +203,8 @@ def update_td(id): if not validated: raise JSONSchemaError(errors, td_id=id) put_td_json_in_sparql(td_updated) + for transformer in TD_TRANSFORMERS: + transformer(id) update_collection_etag() return Response(status=204) @@ -204,6 +225,8 @@ def create_anonymous_td(): ) else: # wrong mimetype raise WrongMimeType(mimetype) + for transformer in TD_TRANSFORMERS: + transformer(uri) update_collection_etag() return Response(status=201 if not updated else 204, headers={"Location": uri}) @@ -267,9 +290,9 @@ def generate(): response = Response( stream_with_context(generate()), content_type="application/ld+json" ) - response.headers[ - "Link" - ] = f'; rel="canonical"; etag="{get_collection_etag()}"' + response.headers["Link"] = ( + f'; rel="canonical"; etag="{get_collection_etag()}"' + ) return response elif format == "collection": @@ -295,9 +318,9 @@ def generate(): next_offset = params["offset"] + params["limit"] if next_offset < number_total: new_params = {**params, "offset": next_offset} - response[ - "next" - ] = f"/things?{create_link_params(new_params)}&format=collection" + response["next"] = ( + f"/things?{create_link_params(new_params)}&format=collection" + ) response = Response( json.dumps(response), content_type="application/ld+json" ) diff --git a/tdd/common.py b/tdd/common.py index 8f916e4..03b715b 100644 --- a/tdd/common.py +++ b/tdd/common.py @@ -29,6 +29,16 @@ ) from tdd.metadata import insert_metadata, delete_metadata from tdd.errors import IDNotFound +from tdd.config import CONFIG +from tdd.paths import LIB_PATH + + +def get_check_schema_from_url_params(request): + check_schema_param = request.args.get("check-schema") + check_schema = CONFIG["CHECK_SCHEMA"] + if check_schema_param in ["false", "False", "0"]: + check_schema = False + return check_schema def delete_id(uri): @@ -45,7 +55,7 @@ def delete_id(uri): def json_ld_to_ntriples(ld_content): p = subprocess.Popen( - ["node", "tdd/lib/transform-to-nt.js", json.dumps(ld_content)], + ["node", LIB_PATH / "transform-to-nt.js", json.dumps(ld_content)], stdout=subprocess.PIPE, ) nt_content = p.stdout.read() @@ -88,7 +98,7 @@ def put_rdf_in_sparql(g, uri, context, delete_if_exists, ontology, forced_type=N def frame_nt_content(id, nt_content, frame): p = subprocess.Popen( - ["node", "tdd/lib/frame-jsonld.js", nt_content, json.dumps(frame)], + ["node", LIB_PATH / "frame-jsonld.js", nt_content, json.dumps(frame)], stdout=subprocess.PIPE, ) json_ld_compacted = p.stdout.read() diff --git a/tdd/config.py b/tdd/config.py index e7f499d..a330523 100644 --- a/tdd/config.py +++ b/tdd/config.py @@ -17,13 +17,14 @@ from config import config_from_env, config_from_toml, config_from_dict from config.configuration_set import ConfigurationSet +from tdd.paths import DATA_PATH _default_config = { "TD_REPO_URL": "http://localhost:5000", "SPARQLENDPOINT_URL": "http://127.0.0.1:3030/things", - "TD_JSONSCHEMA": "./tdd/data/td-json-schema-validation.json", - "TD_ONTOLOGY": "./tdd/data/td.ttl", - "TD_SHACL_VALIDATOR": "./tdd/data/td-validation.ttl", + "TD_JSONSCHEMA": DATA_PATH / "td-json-schema-validation.json", + "TD_ONTOLOGY": DATA_PATH / "td.ttl", + "TD_SHACL_VALIDATOR": DATA_PATH / "td-validation.ttl", "ENDPOINT_TYPE": None, "LIMIT_BATCH_TDS": 25, "CHECK_SCHEMA": False, diff --git a/tdd/context.py b/tdd/context.py index feb6670..c4313e5 100644 --- a/tdd/context.py +++ b/tdd/context.py @@ -18,6 +18,7 @@ import json +from tdd.paths import DATA_PATH from tdd.config import CONFIG from tdd.utils import DEFAULT_THING_CONTEXT_URI, DEFAULT_DISCOVERY_CONTEXT_URI from tdd.sparql import ( @@ -45,7 +46,7 @@ def overwrite_thing_context(ld_content): return if type(ld_content["@context"]) not in (tuple, list): return - with open("tdd/data/fixed-ctx.json") as fp: + with open(DATA_PATH / "fixed-ctx.json") as fp: fixed_ctx = fp.read() try: index_wot_ctx = ld_content["@context"].index(DEFAULT_THING_CONTEXT_URI) @@ -61,7 +62,7 @@ def overwrite_discovery_context(ld_content): return if type(ld_content["@context"]) not in (tuple, list): return - with open("tdd/data/fixed-discovery-ctx.json") as fp: + with open(DATA_PATH / "fixed-discovery-ctx.json") as fp: fixed_discovery_ctx = fp.read() try: index_discovery_ctx = ld_content["@context"].index( diff --git a/tdd/paths.py b/tdd/paths.py new file mode 100644 index 0000000..596c9d5 --- /dev/null +++ b/tdd/paths.py @@ -0,0 +1,4 @@ +from pathlib import Path + +DATA_PATH = Path(__file__).parent / "data" +LIB_PATH = Path(__file__).parent / "lib" diff --git a/tdd/td.py b/tdd/td.py index 333051e..86ace54 100644 --- a/tdd/td.py +++ b/tdd/td.py @@ -337,13 +337,15 @@ def send_request(id, context): offset=offset, ontology=ONTOLOGY["base"], orderby_variable=f"?{sort_by}" if sort_by else "?id", - orderby_sparql=f""" + orderby_sparql=( + f""" OPTIONAL {{ GRAPH ?graph {{ {ORDERBY[sort_by]} }}}} """ - if sort_by - else "", + if sort_by + else "" + ), orderby_direction=sort_order if sort_order else "ASC", ), ) diff --git a/tdd/tests/__init__.py b/tdd/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/conftest.py b/tdd/tests/conftest.py similarity index 96% rename from tests/conftest.py rename to tdd/tests/conftest.py index d0c76cc..b5a78b5 100644 --- a/tests/conftest.py +++ b/tdd/tests/conftest.py @@ -65,10 +65,10 @@ def test_client(httpx_mock): class SparqlGraph: - def __init__(self, filename=None, format="nquads"): + def __init__(self, filename=None, format="nquads", data_path=DATA_PATH): self.graph = ConjunctiveGraph() if filename is not None: - self.graph.parse(DATA_PATH / filename, format=format) + self.graph.parse(data_path / filename, format=format) def sparql_get_query(self, query, content_type): if "json" not in content_type or content_type == "application/ld+json": diff --git a/tests/data/17_things.nquads b/tdd/tests/data/17_things.nquads similarity index 100% rename from tests/data/17_things.nquads rename to tdd/tests/data/17_things.nquads diff --git a/tests/data/bad-json-schema.td.jsonld b/tdd/tests/data/bad-json-schema.td.jsonld similarity index 100% rename from tests/data/bad-json-schema.td.jsonld rename to tdd/tests/data/bad-json-schema.td.jsonld diff --git a/tests/data/bad-json.td.jsonld b/tdd/tests/data/bad-json.td.jsonld similarity index 100% rename from tests/data/bad-json.td.jsonld rename to tdd/tests/data/bad-json.td.jsonld diff --git a/tests/data/registration-data.ttl b/tdd/tests/data/registration-data.ttl similarity index 100% rename from tests/data/registration-data.ttl rename to tdd/tests/data/registration-data.ttl diff --git a/tests/data/smart-coffee-machine.n3 b/tdd/tests/data/smart-coffee-machine.n3 similarity index 100% rename from tests/data/smart-coffee-machine.n3 rename to tdd/tests/data/smart-coffee-machine.n3 diff --git a/tests/data/smart-coffee-machine.td.jsonld b/tdd/tests/data/smart-coffee-machine.td.jsonld similarity index 100% rename from tests/data/smart-coffee-machine.td.jsonld rename to tdd/tests/data/smart-coffee-machine.td.jsonld diff --git a/tests/data/smart-coffee-machine.ttl b/tdd/tests/data/smart-coffee-machine.ttl similarity index 100% rename from tests/data/smart-coffee-machine.ttl rename to tdd/tests/data/smart-coffee-machine.ttl diff --git a/tests/data/smart-coffee-machine.xml b/tdd/tests/data/smart-coffee-machine.xml similarity index 100% rename from tests/data/smart-coffee-machine.xml rename to tdd/tests/data/smart-coffee-machine.xml diff --git a/tests/data/smart-coffee-machine_shacl_nok.ttl b/tdd/tests/data/smart-coffee-machine_shacl_nok.ttl similarity index 100% rename from tests/data/smart-coffee-machine_shacl_nok.ttl rename to tdd/tests/data/smart-coffee-machine_shacl_nok.ttl diff --git a/tests/data/smart-coffee-machine_shacl_ok.ttl b/tdd/tests/data/smart-coffee-machine_shacl_ok.ttl similarity index 100% rename from tests/data/smart-coffee-machine_shacl_ok.ttl rename to tdd/tests/data/smart-coffee-machine_shacl_ok.ttl diff --git a/tests/data/smart_coffe_machine_expired.nquads b/tdd/tests/data/smart_coffe_machine_expired.nquads similarity index 100% rename from tests/data/smart_coffe_machine_expired.nquads rename to tdd/tests/data/smart_coffe_machine_expired.nquads diff --git a/tests/data/smart_coffe_machine_init.nquads b/tdd/tests/data/smart_coffe_machine_init.nquads similarity index 100% rename from tests/data/smart_coffe_machine_init.nquads rename to tdd/tests/data/smart_coffe_machine_init.nquads diff --git a/tests/data/td/17_TD_RAW/actions-events-thing.td.jsonld b/tdd/tests/data/td/17_TD_RAW/actions-events-thing.td.jsonld similarity index 100% rename from tests/data/td/17_TD_RAW/actions-events-thing.td.jsonld rename to tdd/tests/data/td/17_TD_RAW/actions-events-thing.td.jsonld diff --git a/tests/data/td/17_TD_RAW/air-quality-sensor.td.jsonld b/tdd/tests/data/td/17_TD_RAW/air-quality-sensor.td.jsonld similarity index 100% rename from tests/data/td/17_TD_RAW/air-quality-sensor.td.jsonld rename to tdd/tests/data/td/17_TD_RAW/air-quality-sensor.td.jsonld diff --git a/tests/data/td/17_TD_RAW/alarm.td.jsonld b/tdd/tests/data/td/17_TD_RAW/alarm.td.jsonld similarity index 100% rename from tests/data/td/17_TD_RAW/alarm.td.jsonld rename to tdd/tests/data/td/17_TD_RAW/alarm.td.jsonld diff --git a/tests/data/td/17_TD_RAW/barmometric-pressure-sensor.td.jsonld b/tdd/tests/data/td/17_TD_RAW/barmometric-pressure-sensor.td.jsonld similarity index 100% rename from tests/data/td/17_TD_RAW/barmometric-pressure-sensor.td.jsonld rename to tdd/tests/data/td/17_TD_RAW/barmometric-pressure-sensor.td.jsonld diff --git a/tests/data/td/17_TD_RAW/binary-sensor.td.jsonld b/tdd/tests/data/td/17_TD_RAW/binary-sensor.td.jsonld similarity index 100% rename from tests/data/td/17_TD_RAW/binary-sensor.td.jsonld rename to tdd/tests/data/td/17_TD_RAW/binary-sensor.td.jsonld diff --git a/tests/data/td/17_TD_RAW/camera.td.jsonld b/tdd/tests/data/td/17_TD_RAW/camera.td.jsonld similarity index 100% rename from tests/data/td/17_TD_RAW/camera.td.jsonld rename to tdd/tests/data/td/17_TD_RAW/camera.td.jsonld diff --git a/tests/data/td/17_TD_RAW/color-control.td.jsonld b/tdd/tests/data/td/17_TD_RAW/color-control.td.jsonld similarity index 100% rename from tests/data/td/17_TD_RAW/color-control.td.jsonld rename to tdd/tests/data/td/17_TD_RAW/color-control.td.jsonld diff --git a/tests/data/td/17_TD_RAW/color-sensor.td.jsonld b/tdd/tests/data/td/17_TD_RAW/color-sensor.td.jsonld similarity index 100% rename from tests/data/td/17_TD_RAW/color-sensor.td.jsonld rename to tdd/tests/data/td/17_TD_RAW/color-sensor.td.jsonld diff --git a/tests/data/td/17_TD_RAW/dimmable-color-light.td.jsonld b/tdd/tests/data/td/17_TD_RAW/dimmable-color-light.td.jsonld similarity index 100% rename from tests/data/td/17_TD_RAW/dimmable-color-light.td.jsonld rename to tdd/tests/data/td/17_TD_RAW/dimmable-color-light.td.jsonld diff --git a/tests/data/td/17_TD_RAW/dimmable-light.td.jsonld b/tdd/tests/data/td/17_TD_RAW/dimmable-light.td.jsonld similarity index 100% rename from tests/data/td/17_TD_RAW/dimmable-light.td.jsonld rename to tdd/tests/data/td/17_TD_RAW/dimmable-light.td.jsonld diff --git a/tests/data/td/17_TD_RAW/tum-daylight.td.jsonld b/tdd/tests/data/td/17_TD_RAW/tum-daylight.td.jsonld similarity index 100% rename from tests/data/td/17_TD_RAW/tum-daylight.td.jsonld rename to tdd/tests/data/td/17_TD_RAW/tum-daylight.td.jsonld diff --git a/tests/data/td/17_TD_RAW/tum-dimmer-switch.td.jsonld b/tdd/tests/data/td/17_TD_RAW/tum-dimmer-switch.td.jsonld similarity index 100% rename from tests/data/td/17_TD_RAW/tum-dimmer-switch.td.jsonld rename to tdd/tests/data/td/17_TD_RAW/tum-dimmer-switch.td.jsonld diff --git a/tests/data/td/17_TD_RAW/tum-hue-indoor-sensor1.td.jsonld b/tdd/tests/data/td/17_TD_RAW/tum-hue-indoor-sensor1.td.jsonld similarity index 100% rename from tests/data/td/17_TD_RAW/tum-hue-indoor-sensor1.td.jsonld rename to tdd/tests/data/td/17_TD_RAW/tum-hue-indoor-sensor1.td.jsonld diff --git a/tests/data/td/17_TD_RAW/tum-hue-indoor-sensor2.td.jsonld b/tdd/tests/data/td/17_TD_RAW/tum-hue-indoor-sensor2.td.jsonld similarity index 100% rename from tests/data/td/17_TD_RAW/tum-hue-indoor-sensor2.td.jsonld rename to tdd/tests/data/td/17_TD_RAW/tum-hue-indoor-sensor2.td.jsonld diff --git a/tests/data/td/17_TD_RAW/tum-hue-outdoor-sensor1.td.jsonld b/tdd/tests/data/td/17_TD_RAW/tum-hue-outdoor-sensor1.td.jsonld similarity index 100% rename from tests/data/td/17_TD_RAW/tum-hue-outdoor-sensor1.td.jsonld rename to tdd/tests/data/td/17_TD_RAW/tum-hue-outdoor-sensor1.td.jsonld diff --git a/tests/data/td/17_TD_RAW/tum-light1.td.jsonld b/tdd/tests/data/td/17_TD_RAW/tum-light1.td.jsonld similarity index 100% rename from tests/data/td/17_TD_RAW/tum-light1.td.jsonld rename to tdd/tests/data/td/17_TD_RAW/tum-light1.td.jsonld diff --git a/tests/data/td/17_TD_RAW/tum-light2.td.jsonld b/tdd/tests/data/td/17_TD_RAW/tum-light2.td.jsonld similarity index 100% rename from tests/data/td/17_TD_RAW/tum-light2.td.jsonld rename to tdd/tests/data/td/17_TD_RAW/tum-light2.td.jsonld diff --git a/tests/data/tdd-description.json b/tdd/tests/data/tdd-description.json similarity index 100% rename from tests/data/tdd-description.json rename to tdd/tests/data/tdd-description.json diff --git a/tests/test_discovery.py b/tdd/tests/test_discovery.py similarity index 99% rename from tests/test_discovery.py rename to tdd/tests/test_discovery.py index cdb94e6..983adc0 100644 --- a/tests/test_discovery.py +++ b/tdd/tests/test_discovery.py @@ -19,7 +19,7 @@ from tdd.utils import get_collection_etag -from tests.conftest import ( +from tdd.tests.conftest import ( DATA_PATH, assert_only_on_known_errors, ) diff --git a/tests/test_modify.py b/tdd/tests/test_modify.py similarity index 99% rename from tests/test_modify.py rename to tdd/tests/test_modify.py index 5f420e7..190ce82 100644 --- a/tests/test_modify.py +++ b/tdd/tests/test_modify.py @@ -16,7 +16,7 @@ import json -from tests.conftest import ( +from tdd.tests.conftest import ( DATA_PATH, ) diff --git a/tests/test_registration.py b/tdd/tests/test_registration.py similarity index 99% rename from tests/test_registration.py rename to tdd/tests/test_registration.py index b194f68..f1fa328 100644 --- a/tests/test_registration.py +++ b/tdd/tests/test_registration.py @@ -25,7 +25,7 @@ update_registration, validate_ttl, ) -from tests.conftest import DATA_PATH +from tdd.tests.conftest import DATA_PATH def test_get_registration_dict_from_rdf(): diff --git a/tests/test_routes.py b/tdd/tests/test_routes.py similarity index 98% rename from tests/test_routes.py rename to tdd/tests/test_routes.py index 10ea693..763bfc4 100644 --- a/tests/test_routes.py +++ b/tdd/tests/test_routes.py @@ -20,7 +20,7 @@ from rdflib.compare import graph_diff from tdd.td import clear_expired_td -from tests.conftest import ( +from tdd.tests.conftest import ( DATA_PATH, add_registration_to_td, assert_only_on_known_errors, diff --git a/tox.ini b/tox.ini index 85a74ad..4bb7d24 100644 --- a/tox.ini +++ b/tox.ini @@ -6,7 +6,7 @@ deps = pytest extras = dev commands = - {envpython} -m pytest {posargs:tests} + {envpython} -m pytest {posargs:tdd/tests} [testenv:flake8] basepython = python3