summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/hydrilla/server/serve.py12
-rw-r--r--src/test/test_server.py27
2 files changed, 28 insertions, 11 deletions
diff --git a/src/hydrilla/server/serve.py b/src/hydrilla/server/serve.py
index 6cfceaa..8a2b3a5 100644
--- a/src/hydrilla/server/serve.py
+++ b/src/hydrilla/server/serve.py
@@ -42,9 +42,15 @@ from werkzeug import Response
from .. import util
from . import config
+from . import _version
here = Path(__file__).resolve().parent
+generated_by = {
+ 'name': 'hydrilla.server',
+ 'version': _version.version
+}
+
class ItemInfo(ABC):
"""Shortened data of a resource/mapping."""
def __init__(self, item_obj: dict):
@@ -532,10 +538,8 @@ def query():
mapping_refs = [i.as_query_result() for i in malcontent().query(url)]
result = {
'api_schema_version': [1],
- 'generated_by': {
- 'name': 'hydrilla'
- },
- 'mappings': mapping_refs
+ 'mappings': mapping_refs,
+ 'generated_by': generated_by
}
return json.dumps(result)
diff --git a/src/test/test_server.py b/src/test/test_server.py
index b283a00..f7dc06e 100644
--- a/src/test/test_server.py
+++ b/src/test/test_server.py
@@ -39,12 +39,17 @@ from markupsafe import escape
from hydrilla import util as hydrilla_util
from hydrilla.builder import Build
-from hydrilla.server import HydrillaApp, config
+from hydrilla.server import HydrillaApp, config, _version
here = Path(__file__).resolve().parent
config_path = here / 'config.json'
source_path = here / 'source-package-example'
+expected_generated_by = {
+ 'name': 'hydrilla.server',
+ 'version': _version.version
+}
+
@pytest.fixture(scope="session")
def default_setup() -> Iterable[dict[str, Path]]:
with TemporaryDirectory() as tmpdir:
@@ -141,7 +146,11 @@ def test_empty_query(client: FlaskClient) -> None:
response_object = json.loads(response.data.decode())
- assert response_object['mappings'] == []
+ assert response_object == {
+ 'api_schema_version': [1],
+ 'mappings': [],
+ 'generated_by': expected_generated_by
+ }
hydrilla_util.validator_for('api_query_result-1.schema.json')\
.validate(response_object)
@@ -156,11 +165,15 @@ def test_query(client: FlaskClient) -> None:
response_object = json.loads(response.data.decode())
- assert response_object['mappings'] == [{
- 'identifier': 'helloapple',
- 'long_name': 'Hello Apple',
- 'version': [2021, 11, 10]
- }]
+ assert response_object == {
+ 'api_schema_version': [1],
+ 'mappings': [{
+ 'identifier': 'helloapple',
+ 'long_name': 'Hello Apple',
+ 'version': [2021, 11, 10]
+ }],
+ 'generated_by': expected_generated_by
+ }
hydrilla_util.validator_for('api_query_result-1.schema.json')\
.validate(response_object)