docges-api-py 0.1.2__tar.gz → 0.1.3__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.
- {docges_api_py-0.1.2/src/docges_api_py.egg-info → docges_api_py-0.1.3}/PKG-INFO +5 -2
- {docges_api_py-0.1.2 → docges_api_py-0.1.3}/README.md +4 -1
- {docges_api_py-0.1.2 → docges_api_py-0.1.3}/pyproject.toml +1 -1
- {docges_api_py-0.1.2 → docges_api_py-0.1.3}/src/docges_api_py/client.py +10 -2
- {docges_api_py-0.1.2 → docges_api_py-0.1.3/src/docges_api_py.egg-info}/PKG-INFO +5 -2
- {docges_api_py-0.1.2 → docges_api_py-0.1.3}/src/docges_api_py.egg-info/SOURCES.txt +1 -0
- docges_api_py-0.1.3/tests/test_examples.py +121 -0
- {docges_api_py-0.1.2 → docges_api_py-0.1.3}/LICENSE +0 -0
- {docges_api_py-0.1.2 → docges_api_py-0.1.3}/setup.cfg +0 -0
- {docges_api_py-0.1.2 → docges_api_py-0.1.3}/src/docges_api_py/__init__.py +0 -0
- {docges_api_py-0.1.2 → docges_api_py-0.1.3}/src/docges_api_py/models/__init__.py +0 -0
- {docges_api_py-0.1.2 → docges_api_py-0.1.3}/src/docges_api_py/models/auth.py +0 -0
- {docges_api_py-0.1.2 → docges_api_py-0.1.3}/src/docges_api_py/models/document.py +0 -0
- {docges_api_py-0.1.2 → docges_api_py-0.1.3}/src/docges_api_py/models/requests.py +0 -0
- {docges_api_py-0.1.2 → docges_api_py-0.1.3}/src/docges_api_py/models/responses.py +0 -0
- {docges_api_py-0.1.2 → docges_api_py-0.1.3}/src/docges_api_py.egg-info/dependency_links.txt +0 -0
- {docges_api_py-0.1.2 → docges_api_py-0.1.3}/src/docges_api_py.egg-info/requires.txt +0 -0
- {docges_api_py-0.1.2 → docges_api_py-0.1.3}/src/docges_api_py.egg-info/top_level.txt +0 -0
- {docges_api_py-0.1.2 → docges_api_py-0.1.3}/tests/test_client_auth.py +0 -0
- {docges_api_py-0.1.2 → docges_api_py-0.1.3}/tests/test_content_methods.py +0 -0
- {docges_api_py-0.1.2 → docges_api_py-0.1.3}/tests/test_endpoints.py +0 -0
- {docges_api_py-0.1.2 → docges_api_py-0.1.3}/tests/test_get_document.py +0 -0
- {docges_api_py-0.1.2 → docges_api_py-0.1.3}/tests/test_initial_cats.py +0 -0
- {docges_api_py-0.1.2 → docges_api_py-0.1.3}/tests/test_models_auth.py +0 -0
- {docges_api_py-0.1.2 → docges_api_py-0.1.3}/tests/test_models_init.py +0 -0
- {docges_api_py-0.1.2 → docges_api_py-0.1.3}/tests/test_models_requests.py +0 -0
- {docges_api_py-0.1.2 → docges_api_py-0.1.3}/tests/test_models_responses.py +0 -0
- {docges_api_py-0.1.2 → docges_api_py-0.1.3}/tests/test_remaining_methods.py +0 -0
- {docges_api_py-0.1.2 → docges_api_py-0.1.3}/tests/test_retry.py +0 -0
- {docges_api_py-0.1.2 → docges_api_py-0.1.3}/tests/test_token_refresh.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: docges-api-py
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.3
|
|
4
4
|
Summary: Async, typed Python client for DocGes REST API
|
|
5
5
|
Author-email: "ct.galega" <soporte@ctgalega.com>
|
|
6
6
|
License: MIT
|
|
@@ -83,7 +83,8 @@ async def main():
|
|
|
83
83
|
print(f"User: {auth_resp.user_info.get('Nombre')}")
|
|
84
84
|
print(f"Warehouse: {auth_resp.ware_house_info.get('Nombre')}")
|
|
85
85
|
|
|
86
|
-
# Load initial categories (the client injects loginResponse automatically)
|
|
86
|
+
# Load initial categories (the client injects loginDocGesData + loginResponse automatically)
|
|
87
|
+
# Some DocGes bridge servers expect both fields in requestModel for Content endpoints.
|
|
87
88
|
cats = await client.get_initial_cats()
|
|
88
89
|
print(f"Initial categories: {len(cats.CategoriasHijas)}")
|
|
89
90
|
|
|
@@ -99,6 +100,8 @@ asyncio.run(main())
|
|
|
99
100
|
|
|
100
101
|
See `docs/quickstart.md` or `examples/quickstart.py` for a more complete example.
|
|
101
102
|
|
|
103
|
+
For a working end-to-end demo (login + fetch root categories), see [`examples/initial_categories.py`](examples/initial_categories.py).
|
|
104
|
+
|
|
102
105
|
## Development
|
|
103
106
|
|
|
104
107
|
```bash
|
|
@@ -63,7 +63,8 @@ async def main():
|
|
|
63
63
|
print(f"User: {auth_resp.user_info.get('Nombre')}")
|
|
64
64
|
print(f"Warehouse: {auth_resp.ware_house_info.get('Nombre')}")
|
|
65
65
|
|
|
66
|
-
# Load initial categories (the client injects loginResponse automatically)
|
|
66
|
+
# Load initial categories (the client injects loginDocGesData + loginResponse automatically)
|
|
67
|
+
# Some DocGes bridge servers expect both fields in requestModel for Content endpoints.
|
|
67
68
|
cats = await client.get_initial_cats()
|
|
68
69
|
print(f"Initial categories: {len(cats.CategoriasHijas)}")
|
|
69
70
|
|
|
@@ -79,6 +80,8 @@ asyncio.run(main())
|
|
|
79
80
|
|
|
80
81
|
See `docs/quickstart.md` or `examples/quickstart.py` for a more complete example.
|
|
81
82
|
|
|
83
|
+
For a working end-to-end demo (login + fetch root categories), see [`examples/initial_categories.py`](examples/initial_categories.py).
|
|
84
|
+
|
|
82
85
|
## Development
|
|
83
86
|
|
|
84
87
|
```bash
|
|
@@ -192,8 +192,16 @@ class AsyncDocGes:
|
|
|
192
192
|
request_model: dict[str, Any] = {}
|
|
193
193
|
|
|
194
194
|
# Inject session for all Content endpoints
|
|
195
|
-
if
|
|
196
|
-
|
|
195
|
+
if "/Content/" in url:
|
|
196
|
+
# Include original login request data (loginDocGesData) so bridge can reconstruct
|
|
197
|
+
# the DocGesLoginModel (some bridges expect this field).
|
|
198
|
+
request_model["loginDocGesData"] = {
|
|
199
|
+
"username": self.user,
|
|
200
|
+
"password": self.pwd,
|
|
201
|
+
"appID": self.appid,
|
|
202
|
+
}
|
|
203
|
+
if self._login_response is not None:
|
|
204
|
+
request_model["loginResponse"] = self._login_response
|
|
197
205
|
|
|
198
206
|
# Merge endpoint-specific data
|
|
199
207
|
if data is not None:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: docges-api-py
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.3
|
|
4
4
|
Summary: Async, typed Python client for DocGes REST API
|
|
5
5
|
Author-email: "ct.galega" <soporte@ctgalega.com>
|
|
6
6
|
License: MIT
|
|
@@ -83,7 +83,8 @@ async def main():
|
|
|
83
83
|
print(f"User: {auth_resp.user_info.get('Nombre')}")
|
|
84
84
|
print(f"Warehouse: {auth_resp.ware_house_info.get('Nombre')}")
|
|
85
85
|
|
|
86
|
-
# Load initial categories (the client injects loginResponse automatically)
|
|
86
|
+
# Load initial categories (the client injects loginDocGesData + loginResponse automatically)
|
|
87
|
+
# Some DocGes bridge servers expect both fields in requestModel for Content endpoints.
|
|
87
88
|
cats = await client.get_initial_cats()
|
|
88
89
|
print(f"Initial categories: {len(cats.CategoriasHijas)}")
|
|
89
90
|
|
|
@@ -99,6 +100,8 @@ asyncio.run(main())
|
|
|
99
100
|
|
|
100
101
|
See `docs/quickstart.md` or `examples/quickstart.py` for a more complete example.
|
|
101
102
|
|
|
103
|
+
For a working end-to-end demo (login + fetch root categories), see [`examples/initial_categories.py`](examples/initial_categories.py).
|
|
104
|
+
|
|
102
105
|
## Development
|
|
103
106
|
|
|
104
107
|
```bash
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"""Tests for examples/initial_categories.py — TDD RED → GREEN."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import os
|
|
5
|
+
import runpy
|
|
6
|
+
import sys
|
|
7
|
+
|
|
8
|
+
import pytest
|
|
9
|
+
import respx
|
|
10
|
+
import httpx
|
|
11
|
+
import json
|
|
12
|
+
|
|
13
|
+
# Shared fixtures -----------------------------------------------------------------
|
|
14
|
+
|
|
15
|
+
LOGIN_RESPONSE = {
|
|
16
|
+
"userInfo": {"SID": "a6e65fd7-0000-0000-0000-000000000001", "Nombre": "TestUser", "Id": 1},
|
|
17
|
+
"wareHouseInfo": {"SID": "16cf3ed3-0000-0000-0000-000000000002", "Nombre": "devbg"},
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
CATS_RESPONSE = {
|
|
21
|
+
"result": {
|
|
22
|
+
"CategoriasHijas": [
|
|
23
|
+
{"_Nombre": "CatA", "_SID": "cat-a"},
|
|
24
|
+
{"_Nombre": "CatB", "_SID": "cat-b"},
|
|
25
|
+
],
|
|
26
|
+
"Documentos": [],
|
|
27
|
+
},
|
|
28
|
+
"message": "OK",
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
CATS_EMPTY_RESPONSE = {
|
|
32
|
+
"result": {
|
|
33
|
+
"CategoriasHijas": [],
|
|
34
|
+
"Documentos": [],
|
|
35
|
+
},
|
|
36
|
+
"message": "OK",
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
ENV_VARS = {
|
|
40
|
+
"DOCGES_API_BASE_URL": "http://testserver.local",
|
|
41
|
+
"DOCGES_USER": "testuser",
|
|
42
|
+
"DOCGES_PASSWORD": "testpass",
|
|
43
|
+
"DOCGES_APP_ID": "testapp",
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def _run_example(monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture) -> str:
|
|
48
|
+
"""Run examples/initial_categories.py in-process via runpy and return captured stdout."""
|
|
49
|
+
for k, v in ENV_VARS.items():
|
|
50
|
+
monkeypatch.setenv(k, v)
|
|
51
|
+
|
|
52
|
+
example_path = os.path.join(os.path.dirname(__file__), "..", "examples", "initial_categories.py")
|
|
53
|
+
example_path = os.path.normpath(example_path)
|
|
54
|
+
|
|
55
|
+
# Remove cached module state so re-runs are isolated
|
|
56
|
+
for mod in list(sys.modules.keys()):
|
|
57
|
+
if "initial_categories" in mod:
|
|
58
|
+
del sys.modules[mod]
|
|
59
|
+
|
|
60
|
+
runpy.run_path(example_path, run_name="__main__")
|
|
61
|
+
captured = capsys.readouterr()
|
|
62
|
+
return captured.out
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
# Tests ---------------------------------------------------------------------------
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def test_example_prints_logged_in_user(monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture) -> None:
|
|
69
|
+
"""Script prints the logged-in user name from auth response."""
|
|
70
|
+
with respx.mock:
|
|
71
|
+
respx.post("http://testserver.local/Auth/Login").respond(json=LOGIN_RESPONSE)
|
|
72
|
+
# Expect the example to send loginDocGesData + loginResponse in requestModel
|
|
73
|
+
def load_ini_cats_handler(request):
|
|
74
|
+
# request.content is bytes
|
|
75
|
+
body = json.loads(request.content.decode())
|
|
76
|
+
rm = body.get("requestModel", {})
|
|
77
|
+
assert "loginDocGesData" in rm
|
|
78
|
+
assert "loginResponse" in rm
|
|
79
|
+
return httpx.Response(200, json=CATS_RESPONSE)
|
|
80
|
+
|
|
81
|
+
respx.post("http://testserver.local/Content/LoadIniCats").mock(side_effect=load_ini_cats_handler)
|
|
82
|
+
|
|
83
|
+
output = _run_example(monkeypatch, capsys)
|
|
84
|
+
|
|
85
|
+
assert "TestUser" in output
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def test_example_prints_root_category_count(monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture) -> None:
|
|
89
|
+
"""Script prints 'Root categories: 2' when 2 categories are returned."""
|
|
90
|
+
with respx.mock:
|
|
91
|
+
respx.post("http://testserver.local/Auth/Login").respond(json=LOGIN_RESPONSE)
|
|
92
|
+
respx.post("http://testserver.local/Content/LoadIniCats").mock(side_effect=lambda req: httpx.Response(200, json=CATS_RESPONSE))
|
|
93
|
+
|
|
94
|
+
output = _run_example(monkeypatch, capsys)
|
|
95
|
+
|
|
96
|
+
assert "Root categories: 2" in output
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def test_example_prints_zero_categories_when_empty(
|
|
100
|
+
monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture
|
|
101
|
+
) -> None:
|
|
102
|
+
"""Script prints 'Root categories: 0' when no categories are returned."""
|
|
103
|
+
with respx.mock:
|
|
104
|
+
respx.post("http://testserver.local/Auth/Login").respond(json=LOGIN_RESPONSE)
|
|
105
|
+
respx.post("http://testserver.local/Content/LoadIniCats").mock(side_effect=lambda req: httpx.Response(200, json=CATS_EMPTY_RESPONSE))
|
|
106
|
+
|
|
107
|
+
output = _run_example(monkeypatch, capsys)
|
|
108
|
+
|
|
109
|
+
assert "Root categories: 0" in output
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def test_example_exits_when_env_vars_missing(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
113
|
+
"""Script raises SystemExit when required environment variables are absent."""
|
|
114
|
+
for k in ENV_VARS:
|
|
115
|
+
monkeypatch.delenv(k, raising=False)
|
|
116
|
+
|
|
117
|
+
example_path = os.path.join(os.path.dirname(__file__), "..", "examples", "initial_categories.py")
|
|
118
|
+
example_path = os.path.normpath(example_path)
|
|
119
|
+
|
|
120
|
+
with pytest.raises(SystemExit):
|
|
121
|
+
runpy.run_path(example_path, run_name="__main__")
|
|
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
|
|
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
|