OpenGeodeWeb-Microservice 1.2.2__tar.gz → 1.3.0rc1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {opengeodeweb_microservice-1.2.2/src/OpenGeodeWeb_Microservice.egg-info → opengeodeweb_microservice-1.3.0rc1}/PKG-INFO +7 -7
- {opengeodeweb_microservice-1.2.2 → opengeodeweb_microservice-1.3.0rc1}/pyproject.toml +2 -2
- {opengeodeweb_microservice-1.2.2 → opengeodeweb_microservice-1.3.0rc1}/requirements.txt +6 -6
- {opengeodeweb_microservice-1.2.2 → opengeodeweb_microservice-1.3.0rc1/src/OpenGeodeWeb_Microservice.egg-info}/PKG-INFO +7 -7
- {opengeodeweb_microservice-1.2.2 → opengeodeweb_microservice-1.3.0rc1}/src/OpenGeodeWeb_Microservice.egg-info/SOURCES.txt +3 -1
- opengeodeweb_microservice-1.3.0rc1/src/OpenGeodeWeb_Microservice.egg-info/requires.txt +9 -0
- opengeodeweb_microservice-1.3.0rc1/src/opengeodeweb_microservice/error.json +20 -0
- opengeodeweb_microservice-1.3.0rc1/src/opengeodeweb_microservice/schemas.py +84 -0
- opengeodeweb_microservice-1.3.0rc1/tests/test_schemas.py +44 -0
- opengeodeweb_microservice-1.2.2/src/OpenGeodeWeb_Microservice.egg-info/requires.txt +0 -9
- opengeodeweb_microservice-1.2.2/src/opengeodeweb_microservice/schemas.py +0 -15
- {opengeodeweb_microservice-1.2.2 → opengeodeweb_microservice-1.3.0rc1}/LICENSE +0 -0
- {opengeodeweb_microservice-1.2.2 → opengeodeweb_microservice-1.3.0rc1}/README.md +0 -0
- {opengeodeweb_microservice-1.2.2 → opengeodeweb_microservice-1.3.0rc1}/setup.cfg +0 -0
- {opengeodeweb_microservice-1.2.2 → opengeodeweb_microservice-1.3.0rc1}/src/OpenGeodeWeb_Microservice.egg-info/dependency_links.txt +0 -0
- {opengeodeweb_microservice-1.2.2 → opengeodeweb_microservice-1.3.0rc1}/src/OpenGeodeWeb_Microservice.egg-info/top_level.txt +0 -0
- {opengeodeweb_microservice-1.2.2 → opengeodeweb_microservice-1.3.0rc1}/src/opengeodeweb_microservice/__init__.py +0 -0
- {opengeodeweb_microservice-1.2.2 → opengeodeweb_microservice-1.3.0rc1}/src/opengeodeweb_microservice/database/__init__.py +0 -0
- {opengeodeweb_microservice-1.2.2 → opengeodeweb_microservice-1.3.0rc1}/src/opengeodeweb_microservice/database/base.py +0 -0
- {opengeodeweb_microservice-1.2.2 → opengeodeweb_microservice-1.3.0rc1}/src/opengeodeweb_microservice/database/connection.py +0 -0
- {opengeodeweb_microservice-1.2.2 → opengeodeweb_microservice-1.3.0rc1}/src/opengeodeweb_microservice/database/data.py +0 -0
- {opengeodeweb_microservice-1.2.2 → opengeodeweb_microservice-1.3.0rc1}/src/opengeodeweb_microservice/database/data_types.py +0 -0
- {opengeodeweb_microservice-1.2.2 → opengeodeweb_microservice-1.3.0rc1}/src/opengeodeweb_microservice/py.typed +0 -0
- {opengeodeweb_microservice-1.2.2 → opengeodeweb_microservice-1.3.0rc1}/tests/test_database.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: OpenGeodeWeb-Microservice
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.3.0rc1
|
|
4
4
|
Summary: Database model and ORM layer for OpenGeodeWeb ecosystem
|
|
5
5
|
Author-email: Geode-solutions <team-web@geode-solutions.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/Geode-solutions/OpenGeodeWeb-Microservice
|
|
@@ -13,13 +13,13 @@ Description-Content-Type: text/markdown
|
|
|
13
13
|
License-File: LICENSE
|
|
14
14
|
Requires-Dist: dataclasses-json==0.6.7
|
|
15
15
|
Requires-Dist: fastjsonschema==2.21.1
|
|
16
|
-
Requires-Dist: greenlet==3
|
|
17
|
-
Requires-Dist: marshmallow==3
|
|
18
|
-
Requires-Dist: mypy-extensions==1
|
|
19
|
-
Requires-Dist: packaging==26
|
|
16
|
+
Requires-Dist: greenlet==3.*
|
|
17
|
+
Requires-Dist: marshmallow==3.*
|
|
18
|
+
Requires-Dist: mypy-extensions==1.*
|
|
19
|
+
Requires-Dist: packaging==26.*
|
|
20
20
|
Requires-Dist: sqlalchemy==2.0.43
|
|
21
|
-
Requires-Dist: typing-extensions==4
|
|
22
|
-
Requires-Dist: typing-inspect==0
|
|
21
|
+
Requires-Dist: typing-extensions==4.*
|
|
22
|
+
Requires-Dist: typing-inspect==0.*
|
|
23
23
|
Dynamic: license-file
|
|
24
24
|
|
|
25
25
|
<h1 align="center">OpenGeodeWeb-Microservice<sup><i>by Geode-solutions</i></sup></h1>
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "OpenGeodeWeb-Microservice"
|
|
7
|
-
version = "1.
|
|
7
|
+
version = "1.3.0-rc.1"
|
|
8
8
|
dynamic = ["dependencies"]
|
|
9
9
|
authors = [{ name = "Geode-solutions", email = "team-web@geode-solutions.com" }]
|
|
10
10
|
description = "Database model and ORM layer for OpenGeodeWeb ecosystem"
|
|
@@ -27,4 +27,4 @@ dependencies = { file = ["requirements.txt"] }
|
|
|
27
27
|
where = ["src"]
|
|
28
28
|
|
|
29
29
|
[tool.setuptools.package-data]
|
|
30
|
-
opengeodeweb_microservice = ["py.typed"]
|
|
30
|
+
opengeodeweb_microservice = ["py.typed", "error.json"]
|
|
@@ -8,20 +8,20 @@ dataclasses-json==0.6.7
|
|
|
8
8
|
# via -r requirements.in
|
|
9
9
|
fastjsonschema==2.21.1
|
|
10
10
|
# via -r requirements.in
|
|
11
|
-
greenlet==3
|
|
11
|
+
greenlet==3.*
|
|
12
12
|
# via sqlalchemy
|
|
13
|
-
marshmallow==3
|
|
13
|
+
marshmallow==3.*
|
|
14
14
|
# via dataclasses-json
|
|
15
|
-
mypy-extensions==1
|
|
15
|
+
mypy-extensions==1.*
|
|
16
16
|
# via typing-inspect
|
|
17
|
-
packaging==26
|
|
17
|
+
packaging==26.*
|
|
18
18
|
# via marshmallow
|
|
19
19
|
sqlalchemy==2.0.43
|
|
20
20
|
# via -r requirements.in
|
|
21
|
-
typing-extensions==4
|
|
21
|
+
typing-extensions==4.*
|
|
22
22
|
# via
|
|
23
23
|
# sqlalchemy
|
|
24
24
|
# typing-inspect
|
|
25
|
-
typing-inspect==0
|
|
25
|
+
typing-inspect==0.*
|
|
26
26
|
# via dataclasses-json
|
|
27
27
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: OpenGeodeWeb-Microservice
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.3.0rc1
|
|
4
4
|
Summary: Database model and ORM layer for OpenGeodeWeb ecosystem
|
|
5
5
|
Author-email: Geode-solutions <team-web@geode-solutions.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/Geode-solutions/OpenGeodeWeb-Microservice
|
|
@@ -13,13 +13,13 @@ Description-Content-Type: text/markdown
|
|
|
13
13
|
License-File: LICENSE
|
|
14
14
|
Requires-Dist: dataclasses-json==0.6.7
|
|
15
15
|
Requires-Dist: fastjsonschema==2.21.1
|
|
16
|
-
Requires-Dist: greenlet==3
|
|
17
|
-
Requires-Dist: marshmallow==3
|
|
18
|
-
Requires-Dist: mypy-extensions==1
|
|
19
|
-
Requires-Dist: packaging==26
|
|
16
|
+
Requires-Dist: greenlet==3.*
|
|
17
|
+
Requires-Dist: marshmallow==3.*
|
|
18
|
+
Requires-Dist: mypy-extensions==1.*
|
|
19
|
+
Requires-Dist: packaging==26.*
|
|
20
20
|
Requires-Dist: sqlalchemy==2.0.43
|
|
21
|
-
Requires-Dist: typing-extensions==4
|
|
22
|
-
Requires-Dist: typing-inspect==0
|
|
21
|
+
Requires-Dist: typing-extensions==4.*
|
|
22
|
+
Requires-Dist: typing-inspect==0.*
|
|
23
23
|
Dynamic: license-file
|
|
24
24
|
|
|
25
25
|
<h1 align="center">OpenGeodeWeb-Microservice<sup><i>by Geode-solutions</i></sup></h1>
|
|
@@ -8,6 +8,7 @@ src/OpenGeodeWeb_Microservice.egg-info/dependency_links.txt
|
|
|
8
8
|
src/OpenGeodeWeb_Microservice.egg-info/requires.txt
|
|
9
9
|
src/OpenGeodeWeb_Microservice.egg-info/top_level.txt
|
|
10
10
|
src/opengeodeweb_microservice/__init__.py
|
|
11
|
+
src/opengeodeweb_microservice/error.json
|
|
11
12
|
src/opengeodeweb_microservice/py.typed
|
|
12
13
|
src/opengeodeweb_microservice/schemas.py
|
|
13
14
|
src/opengeodeweb_microservice/database/__init__.py
|
|
@@ -15,4 +16,5 @@ src/opengeodeweb_microservice/database/base.py
|
|
|
15
16
|
src/opengeodeweb_microservice/database/connection.py
|
|
16
17
|
src/opengeodeweb_microservice/database/data.py
|
|
17
18
|
src/opengeodeweb_microservice/database/data_types.py
|
|
18
|
-
tests/test_database.py
|
|
19
|
+
tests/test_database.py
|
|
20
|
+
tests/test_schemas.py
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "object",
|
|
3
|
+
"properties": {
|
|
4
|
+
"code": {
|
|
5
|
+
"type": "integer"
|
|
6
|
+
},
|
|
7
|
+
"name": {
|
|
8
|
+
"type": "string"
|
|
9
|
+
},
|
|
10
|
+
"description": {
|
|
11
|
+
"type": "string"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"required": [
|
|
15
|
+
"code",
|
|
16
|
+
"name",
|
|
17
|
+
"description"
|
|
18
|
+
],
|
|
19
|
+
"additionalProperties": false
|
|
20
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import glob
|
|
3
|
+
import json
|
|
4
|
+
import dataclasses
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
from typing import Any, Generic, TypeVar
|
|
7
|
+
|
|
8
|
+
from dataclasses_json import DataClassJsonMixin
|
|
9
|
+
|
|
10
|
+
type SchemaDict = dict[str, str]
|
|
11
|
+
|
|
12
|
+
ERROR_SCHEMA_PATH = os.path.join(os.path.dirname(__file__), "error.json")
|
|
13
|
+
|
|
14
|
+
ParamsT = TypeVar("ParamsT", bound=DataClassJsonMixin)
|
|
15
|
+
ResponseT = TypeVar("ResponseT", bound=DataClassJsonMixin)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
MAX_VALUE_LENGTH = 80
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def _format_value(value: Any, max_length: int) -> str:
|
|
22
|
+
if dataclasses.is_dataclass(value) and not isinstance(value, type):
|
|
23
|
+
return format_dataclass(value, max_length)
|
|
24
|
+
text = repr(value)
|
|
25
|
+
if len(text) <= max_length:
|
|
26
|
+
return text
|
|
27
|
+
details = type(value).__name__
|
|
28
|
+
if hasattr(value, "__len__"):
|
|
29
|
+
details += f", len={len(value)}"
|
|
30
|
+
return f"{text[:max_length]}... ({details})"
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def format_dataclass(instance: Any, max_length: int = MAX_VALUE_LENGTH) -> str:
|
|
34
|
+
"""Like repr(), but every field value longer than max_length is truncated and followed by its type and length."""
|
|
35
|
+
fields = ", ".join(
|
|
36
|
+
f"{field.name}={_format_value(getattr(instance, field.name), max_length)}"
|
|
37
|
+
for field in dataclasses.fields(instance)
|
|
38
|
+
)
|
|
39
|
+
return f"{type(instance).__name__}({fields})"
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def print_dataclass(instance: Any) -> None:
|
|
43
|
+
print(format_dataclass(instance), flush=True)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def get_schemas_dict(path: str) -> dict[str, SchemaDict]:
|
|
47
|
+
schemas_dict: dict[str, SchemaDict] = {}
|
|
48
|
+
for json_file in glob.glob(os.path.join(path, "*.json")):
|
|
49
|
+
filename = os.path.basename(json_file)
|
|
50
|
+
with open(os.path.join(path, json_file), "r") as file:
|
|
51
|
+
file_content = json.load(file)
|
|
52
|
+
schemas_dict[os.path.splitext(filename)[0]] = file_content
|
|
53
|
+
return schemas_dict
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def load_schema(python_file: str) -> dict[str, Any]:
|
|
57
|
+
"""Load the JSON route schema sitting next to a generated schema module."""
|
|
58
|
+
json_file = os.path.splitext(python_file)[0] + ".json"
|
|
59
|
+
with open(json_file, "r") as file:
|
|
60
|
+
schema: dict[str, Any] = json.load(file)
|
|
61
|
+
return schema
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
@dataclass(frozen=True)
|
|
65
|
+
class Route(Generic[ParamsT, ResponseT]):
|
|
66
|
+
"""Generated binding between a route schema, its request params and its success response."""
|
|
67
|
+
|
|
68
|
+
schema: dict[str, Any]
|
|
69
|
+
params: type[ParamsT]
|
|
70
|
+
response: type[ResponseT]
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
@dataclass
|
|
74
|
+
class BinaryResponse(DataClassJsonMixin):
|
|
75
|
+
"""Response of a route streaming a file (schema `"response": {"format": "binary"}`) instead of JSON."""
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
@dataclass
|
|
79
|
+
class ErrorResponse(DataClassJsonMixin):
|
|
80
|
+
"""Body of every 4xx/5xx response, matches error.json."""
|
|
81
|
+
|
|
82
|
+
code: int
|
|
83
|
+
name: str
|
|
84
|
+
description: str
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import json
|
|
2
|
+
|
|
3
|
+
import fastjsonschema # type: ignore
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
|
|
7
|
+
from opengeodeweb_microservice.schemas import (
|
|
8
|
+
ERROR_SCHEMA_PATH,
|
|
9
|
+
ErrorResponse,
|
|
10
|
+
format_dataclass,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def test_error_response_matches_error_schema() -> None:
|
|
15
|
+
with open(ERROR_SCHEMA_PATH, "r") as file:
|
|
16
|
+
validate = fastjsonschema.compile(json.load(file))
|
|
17
|
+
validate(
|
|
18
|
+
ErrorResponse(
|
|
19
|
+
code=500, name="Internal Server Error", description="boom"
|
|
20
|
+
).to_dict()
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@dataclass
|
|
25
|
+
class _Inner:
|
|
26
|
+
values: list[int]
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
@dataclass
|
|
30
|
+
class _Outer:
|
|
31
|
+
name: str
|
|
32
|
+
content: str
|
|
33
|
+
inner: _Inner
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def test_format_dataclass_truncates_long_values() -> None:
|
|
37
|
+
text = format_dataclass(
|
|
38
|
+
_Outer(name="short", content="x" * 1000, inner=_Inner(values=list(range(500)))),
|
|
39
|
+
max_length=20,
|
|
40
|
+
)
|
|
41
|
+
assert text.startswith(
|
|
42
|
+
"_Outer(name='short', content='xxxxxxxxxxxxxxxxxxx... (str, len=1000)"
|
|
43
|
+
)
|
|
44
|
+
assert "inner=_Inner(values=[0, 1, 2, 3, 4, 5, 6... (list, len=500))" in text
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import glob
|
|
3
|
-
import json
|
|
4
|
-
|
|
5
|
-
type SchemaDict = dict[str, str]
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
def get_schemas_dict(path: str) -> dict[str, SchemaDict]:
|
|
9
|
-
schemas_dict: dict[str, SchemaDict] = {}
|
|
10
|
-
for json_file in glob.glob(os.path.join(path, "*.json")):
|
|
11
|
-
filename = os.path.basename(json_file)
|
|
12
|
-
with open(os.path.join(path, json_file), "r") as file:
|
|
13
|
-
file_content = json.load(file)
|
|
14
|
-
schemas_dict[os.path.splitext(filename)[0]] = file_content
|
|
15
|
-
return schemas_dict
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{opengeodeweb_microservice-1.2.2 → opengeodeweb_microservice-1.3.0rc1}/tests/test_database.py
RENAMED
|
File without changes
|