apexdevkit 1.8.1__tar.gz → 1.8.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.
- {apexdevkit-1.8.1 → apexdevkit-1.8.3}/PKG-INFO +1 -1
- {apexdevkit-1.8.1 → apexdevkit-1.8.3}/apexdevkit/http/fake.py +4 -1
- {apexdevkit-1.8.1 → apexdevkit-1.8.3}/apexdevkit/http/fluent.py +4 -1
- {apexdevkit-1.8.1 → apexdevkit-1.8.3}/apexdevkit/http/httpx.py +6 -1
- {apexdevkit-1.8.1 → apexdevkit-1.8.3}/apexdevkit/testing/rest.py +52 -46
- {apexdevkit-1.8.1 → apexdevkit-1.8.3}/pyproject.toml +1 -1
- {apexdevkit-1.8.1 → apexdevkit-1.8.3}/LICENSE +0 -0
- {apexdevkit-1.8.1 → apexdevkit-1.8.3}/README.md +0 -0
- {apexdevkit-1.8.1 → apexdevkit-1.8.3}/apexdevkit/__init__.py +0 -0
- {apexdevkit-1.8.1 → apexdevkit-1.8.3}/apexdevkit/annotation/__init__.py +0 -0
- {apexdevkit-1.8.1 → apexdevkit-1.8.3}/apexdevkit/annotation/deprecate.py +0 -0
- {apexdevkit-1.8.1 → apexdevkit-1.8.3}/apexdevkit/error.py +0 -0
- {apexdevkit-1.8.1 → apexdevkit-1.8.3}/apexdevkit/fastapi/__init__.py +0 -0
- {apexdevkit-1.8.1 → apexdevkit-1.8.3}/apexdevkit/fastapi/builder.py +0 -0
- {apexdevkit-1.8.1 → apexdevkit-1.8.3}/apexdevkit/fastapi/dependable.py +0 -0
- {apexdevkit-1.8.1 → apexdevkit-1.8.3}/apexdevkit/fastapi/docs.py +0 -0
- {apexdevkit-1.8.1 → apexdevkit-1.8.3}/apexdevkit/fastapi/resource.py +0 -0
- {apexdevkit-1.8.1 → apexdevkit-1.8.3}/apexdevkit/fastapi/response.py +0 -0
- {apexdevkit-1.8.1 → apexdevkit-1.8.3}/apexdevkit/fastapi/router.py +0 -0
- {apexdevkit-1.8.1 → apexdevkit-1.8.3}/apexdevkit/fastapi/schema.py +0 -0
- {apexdevkit-1.8.1 → apexdevkit-1.8.3}/apexdevkit/fastapi/service.py +0 -0
- {apexdevkit-1.8.1 → apexdevkit-1.8.3}/apexdevkit/formatter.py +0 -0
- {apexdevkit-1.8.1 → apexdevkit-1.8.3}/apexdevkit/http/__init__.py +0 -0
- {apexdevkit-1.8.1 → apexdevkit-1.8.3}/apexdevkit/http/json.py +0 -0
- {apexdevkit-1.8.1 → apexdevkit-1.8.3}/apexdevkit/http/url.py +0 -0
- {apexdevkit-1.8.1 → apexdevkit-1.8.3}/apexdevkit/py.typed +0 -0
- {apexdevkit-1.8.1 → apexdevkit-1.8.3}/apexdevkit/repository/__init__.py +0 -0
- {apexdevkit-1.8.1 → apexdevkit-1.8.3}/apexdevkit/repository/base.py +0 -0
- {apexdevkit-1.8.1 → apexdevkit-1.8.3}/apexdevkit/repository/connector.py +0 -0
- {apexdevkit-1.8.1 → apexdevkit-1.8.3}/apexdevkit/repository/database.py +0 -0
- {apexdevkit-1.8.1 → apexdevkit-1.8.3}/apexdevkit/repository/in_memory.py +0 -0
- {apexdevkit-1.8.1 → apexdevkit-1.8.3}/apexdevkit/repository/interface.py +0 -0
- {apexdevkit-1.8.1 → apexdevkit-1.8.3}/apexdevkit/testing/__init__.py +0 -0
- {apexdevkit-1.8.1 → apexdevkit-1.8.3}/apexdevkit/testing/database.py +0 -0
- {apexdevkit-1.8.1 → apexdevkit-1.8.3}/apexdevkit/testing/fake.py +0 -0
|
@@ -48,6 +48,9 @@ class FakeHttp:
|
|
|
48
48
|
|
|
49
49
|
_request: InterceptedRequest = field(init=False)
|
|
50
50
|
|
|
51
|
+
def with_endpoint(self, value: str) -> Self: # pragma: no cover
|
|
52
|
+
raise NotImplementedError
|
|
53
|
+
|
|
51
54
|
def with_header(self, key: str, value: str) -> Self:
|
|
52
55
|
self.headers[key] = value
|
|
53
56
|
|
|
@@ -63,7 +66,7 @@ class FakeHttp:
|
|
|
63
66
|
|
|
64
67
|
return self
|
|
65
68
|
|
|
66
|
-
def request(self, method: HttpMethod, endpoint: str) -> HttpResponse:
|
|
69
|
+
def request(self, method: HttpMethod, endpoint: str = "") -> HttpResponse:
|
|
67
70
|
self._request = InterceptedRequest(method, endpoint)
|
|
68
71
|
|
|
69
72
|
return self.response
|
|
@@ -8,6 +8,9 @@ from apexdevkit.http.json import JsonDict
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
class Http(Protocol): # pragma: no cover
|
|
11
|
+
def with_endpoint(self, value: str) -> Http:
|
|
12
|
+
pass
|
|
13
|
+
|
|
11
14
|
def with_header(self, key: str, value: str) -> Http:
|
|
12
15
|
pass
|
|
13
16
|
|
|
@@ -17,7 +20,7 @@ class Http(Protocol): # pragma: no cover
|
|
|
17
20
|
def with_json(self, value: JsonDict) -> Http:
|
|
18
21
|
pass
|
|
19
22
|
|
|
20
|
-
def request(self, method: HttpMethod, endpoint: str) -> HttpResponse:
|
|
23
|
+
def request(self, method: HttpMethod, endpoint: str = "") -> HttpResponse:
|
|
21
24
|
pass
|
|
22
25
|
|
|
23
26
|
|
|
@@ -24,6 +24,11 @@ class Httpx:
|
|
|
24
24
|
def create_for(cls, url: str) -> Self:
|
|
25
25
|
return cls(Client(base_url=url), HttpxConfig())
|
|
26
26
|
|
|
27
|
+
def with_endpoint(self, value: str) -> Httpx:
|
|
28
|
+
self.client.base_url = self.client.base_url.join(value)
|
|
29
|
+
|
|
30
|
+
return self
|
|
31
|
+
|
|
27
32
|
def with_header(self, key: str, value: str) -> Httpx:
|
|
28
33
|
return Httpx(self.client, self.config.with_header(key, value))
|
|
29
34
|
|
|
@@ -33,7 +38,7 @@ class Httpx:
|
|
|
33
38
|
def with_json(self, value: JsonDict) -> Httpx:
|
|
34
39
|
return Httpx(self.client, self.config.with_json(value))
|
|
35
40
|
|
|
36
|
-
def request(self, method: HttpMethod, endpoint: str) -> HttpResponse:
|
|
41
|
+
def request(self, method: HttpMethod, endpoint: str = "") -> HttpResponse:
|
|
37
42
|
return _HttpxResponse(self.client.request(method.name, endpoint, **self.config))
|
|
38
43
|
|
|
39
44
|
|
|
@@ -6,7 +6,6 @@ from typing import Any, Iterable, Self
|
|
|
6
6
|
|
|
7
7
|
from apexdevkit.http import Http, HttpUrl, JsonDict
|
|
8
8
|
from apexdevkit.http.fluent import HttpMethod, HttpResponse
|
|
9
|
-
from apexdevkit.http.httpx import Httpx
|
|
10
9
|
|
|
11
10
|
|
|
12
11
|
@dataclass
|
|
@@ -17,86 +16,95 @@ class RestResource:
|
|
|
17
16
|
def create_one(self) -> RestRequest:
|
|
18
17
|
return RestRequest(
|
|
19
18
|
self.name,
|
|
20
|
-
HttpRequest(
|
|
19
|
+
HttpRequest(
|
|
20
|
+
HttpMethod.post,
|
|
21
|
+
self.http.with_endpoint(self.name.plural),
|
|
22
|
+
),
|
|
21
23
|
)
|
|
22
24
|
|
|
23
25
|
def create_many(self) -> RestRequest:
|
|
24
26
|
return RestRequest(
|
|
25
27
|
self.name,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
.with_endpoint(self.name.plural)
|
|
29
|
-
.with_endpoint("batch")
|
|
28
|
+
HttpRequest(
|
|
29
|
+
HttpMethod.post,
|
|
30
|
+
self.http.with_endpoint(self.name.plural).with_endpoint("batch"),
|
|
30
31
|
),
|
|
31
32
|
)
|
|
32
33
|
|
|
33
34
|
def read_one(self) -> RestRequest:
|
|
34
35
|
return RestRequest(
|
|
35
36
|
self.name,
|
|
36
|
-
HttpRequest(
|
|
37
|
+
HttpRequest(
|
|
38
|
+
HttpMethod.get,
|
|
39
|
+
self.http.with_endpoint(self.name.plural),
|
|
40
|
+
),
|
|
37
41
|
)
|
|
38
42
|
|
|
39
43
|
def read_all(self) -> RestRequest:
|
|
40
44
|
return RestRequest(
|
|
41
45
|
self.name,
|
|
42
|
-
HttpRequest(
|
|
46
|
+
HttpRequest(
|
|
47
|
+
HttpMethod.get,
|
|
48
|
+
self.http.with_endpoint(self.name.plural),
|
|
49
|
+
),
|
|
43
50
|
)
|
|
44
51
|
|
|
45
52
|
def update_one(self) -> RestRequest:
|
|
46
53
|
return RestRequest(
|
|
47
54
|
self.name,
|
|
48
|
-
HttpRequest(
|
|
55
|
+
HttpRequest(
|
|
56
|
+
HttpMethod.patch,
|
|
57
|
+
self.http.with_endpoint(self.name.plural),
|
|
58
|
+
),
|
|
49
59
|
)
|
|
50
60
|
|
|
51
61
|
def update_many(self) -> RestRequest:
|
|
52
62
|
return RestRequest(
|
|
53
63
|
self.name,
|
|
54
|
-
HttpRequest(
|
|
64
|
+
HttpRequest(
|
|
65
|
+
HttpMethod.patch,
|
|
66
|
+
self.http.with_endpoint(self.name.plural),
|
|
67
|
+
),
|
|
55
68
|
)
|
|
56
69
|
|
|
57
70
|
def replace_one(self) -> RestRequest:
|
|
58
71
|
return RestRequest(
|
|
59
72
|
self.name,
|
|
60
|
-
HttpRequest(
|
|
73
|
+
HttpRequest(
|
|
74
|
+
HttpMethod.put,
|
|
75
|
+
self.http.with_endpoint(self.name.plural),
|
|
76
|
+
),
|
|
61
77
|
)
|
|
62
78
|
|
|
63
79
|
def replace_many(self) -> RestRequest:
|
|
64
80
|
return RestRequest(
|
|
65
81
|
self.name,
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
.with_endpoint(self.name.plural)
|
|
69
|
-
.with_endpoint("batch")
|
|
82
|
+
HttpRequest(
|
|
83
|
+
HttpMethod.put,
|
|
84
|
+
self.http.with_endpoint(self.name.plural).with_endpoint("batch"),
|
|
70
85
|
),
|
|
71
86
|
)
|
|
72
87
|
|
|
73
88
|
def delete_one(self) -> RestRequest:
|
|
74
89
|
return RestRequest(
|
|
75
90
|
self.name,
|
|
76
|
-
HttpRequest(
|
|
91
|
+
HttpRequest(
|
|
92
|
+
HttpMethod.delete,
|
|
93
|
+
self.http.with_endpoint(self.name.plural),
|
|
94
|
+
),
|
|
77
95
|
)
|
|
78
96
|
|
|
79
97
|
|
|
80
98
|
@dataclass
|
|
81
99
|
class RestCollection(RestResource):
|
|
82
100
|
def sub_resource(self, name: str) -> RestItem:
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
client = self.http.client
|
|
86
|
-
client.base_url = client.base_url.join(self.name.plural)
|
|
87
|
-
|
|
88
|
-
return RestItem(self.http, RestfulName(name))
|
|
101
|
+
return RestItem(self.http.with_endpoint(self.name.plural), RestfulName(name))
|
|
89
102
|
|
|
90
103
|
|
|
91
104
|
@dataclass
|
|
92
105
|
class RestItem(RestResource):
|
|
93
106
|
def sub_resource(self, name: str) -> RestItem:
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
client = self.http.client
|
|
97
|
-
client.base_url = client.base_url.join(self.name.singular)
|
|
98
|
-
|
|
99
|
-
return RestItem(self.http, RestfulName(name))
|
|
107
|
+
return RestItem(self.http.with_endpoint(self.name.singular), RestfulName(name))
|
|
100
108
|
|
|
101
109
|
|
|
102
110
|
@dataclass
|
|
@@ -113,20 +121,20 @@ class RestfulName:
|
|
|
113
121
|
|
|
114
122
|
|
|
115
123
|
def as_plural(singular: str) -> str:
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
124
|
+
suffixes = {
|
|
125
|
+
"y": "ies",
|
|
126
|
+
"ch": "ches",
|
|
127
|
+
"sh": "shes",
|
|
128
|
+
"s": "ses",
|
|
129
|
+
"z": "zes",
|
|
130
|
+
"x": "xes",
|
|
131
|
+
"fe": "ves",
|
|
132
|
+
"f": "ves",
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
for singular_suffix, plural_suffix in suffixes.items():
|
|
136
|
+
if singular.endswith(singular_suffix):
|
|
137
|
+
return singular.removesuffix(singular_suffix) + plural_suffix
|
|
130
138
|
|
|
131
139
|
return singular + "s"
|
|
132
140
|
|
|
@@ -136,10 +144,8 @@ class HttpRequest:
|
|
|
136
144
|
method: HttpMethod
|
|
137
145
|
http: Http
|
|
138
146
|
|
|
139
|
-
endpoint: str = ""
|
|
140
|
-
|
|
141
147
|
def with_endpoint(self, value: Any) -> HttpRequest:
|
|
142
|
-
self.
|
|
148
|
+
self.http = self.http.with_endpoint(str(value))
|
|
143
149
|
|
|
144
150
|
return self
|
|
145
151
|
|
|
@@ -154,7 +160,7 @@ class HttpRequest:
|
|
|
154
160
|
return self
|
|
155
161
|
|
|
156
162
|
def __call__(self) -> HttpResponse:
|
|
157
|
-
return self.http.request(
|
|
163
|
+
return self.http.request(self.method)
|
|
158
164
|
|
|
159
165
|
|
|
160
166
|
@dataclass
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|