apexdevkit 1.8.2__tar.gz → 1.8.4__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.
Files changed (35) hide show
  1. {apexdevkit-1.8.2 → apexdevkit-1.8.4}/PKG-INFO +1 -1
  2. {apexdevkit-1.8.2 → apexdevkit-1.8.4}/apexdevkit/http/httpx.py +22 -10
  3. {apexdevkit-1.8.2 → apexdevkit-1.8.4}/apexdevkit/testing/rest.py +15 -15
  4. {apexdevkit-1.8.2 → apexdevkit-1.8.4}/pyproject.toml +1 -1
  5. {apexdevkit-1.8.2 → apexdevkit-1.8.4}/LICENSE +0 -0
  6. {apexdevkit-1.8.2 → apexdevkit-1.8.4}/README.md +0 -0
  7. {apexdevkit-1.8.2 → apexdevkit-1.8.4}/apexdevkit/__init__.py +0 -0
  8. {apexdevkit-1.8.2 → apexdevkit-1.8.4}/apexdevkit/annotation/__init__.py +0 -0
  9. {apexdevkit-1.8.2 → apexdevkit-1.8.4}/apexdevkit/annotation/deprecate.py +0 -0
  10. {apexdevkit-1.8.2 → apexdevkit-1.8.4}/apexdevkit/error.py +0 -0
  11. {apexdevkit-1.8.2 → apexdevkit-1.8.4}/apexdevkit/fastapi/__init__.py +0 -0
  12. {apexdevkit-1.8.2 → apexdevkit-1.8.4}/apexdevkit/fastapi/builder.py +0 -0
  13. {apexdevkit-1.8.2 → apexdevkit-1.8.4}/apexdevkit/fastapi/dependable.py +0 -0
  14. {apexdevkit-1.8.2 → apexdevkit-1.8.4}/apexdevkit/fastapi/docs.py +0 -0
  15. {apexdevkit-1.8.2 → apexdevkit-1.8.4}/apexdevkit/fastapi/resource.py +0 -0
  16. {apexdevkit-1.8.2 → apexdevkit-1.8.4}/apexdevkit/fastapi/response.py +0 -0
  17. {apexdevkit-1.8.2 → apexdevkit-1.8.4}/apexdevkit/fastapi/router.py +0 -0
  18. {apexdevkit-1.8.2 → apexdevkit-1.8.4}/apexdevkit/fastapi/schema.py +0 -0
  19. {apexdevkit-1.8.2 → apexdevkit-1.8.4}/apexdevkit/fastapi/service.py +0 -0
  20. {apexdevkit-1.8.2 → apexdevkit-1.8.4}/apexdevkit/formatter.py +0 -0
  21. {apexdevkit-1.8.2 → apexdevkit-1.8.4}/apexdevkit/http/__init__.py +0 -0
  22. {apexdevkit-1.8.2 → apexdevkit-1.8.4}/apexdevkit/http/fake.py +0 -0
  23. {apexdevkit-1.8.2 → apexdevkit-1.8.4}/apexdevkit/http/fluent.py +0 -0
  24. {apexdevkit-1.8.2 → apexdevkit-1.8.4}/apexdevkit/http/json.py +0 -0
  25. {apexdevkit-1.8.2 → apexdevkit-1.8.4}/apexdevkit/http/url.py +0 -0
  26. {apexdevkit-1.8.2 → apexdevkit-1.8.4}/apexdevkit/py.typed +0 -0
  27. {apexdevkit-1.8.2 → apexdevkit-1.8.4}/apexdevkit/repository/__init__.py +0 -0
  28. {apexdevkit-1.8.2 → apexdevkit-1.8.4}/apexdevkit/repository/base.py +0 -0
  29. {apexdevkit-1.8.2 → apexdevkit-1.8.4}/apexdevkit/repository/connector.py +0 -0
  30. {apexdevkit-1.8.2 → apexdevkit-1.8.4}/apexdevkit/repository/database.py +0 -0
  31. {apexdevkit-1.8.2 → apexdevkit-1.8.4}/apexdevkit/repository/in_memory.py +0 -0
  32. {apexdevkit-1.8.2 → apexdevkit-1.8.4}/apexdevkit/repository/interface.py +0 -0
  33. {apexdevkit-1.8.2 → apexdevkit-1.8.4}/apexdevkit/testing/__init__.py +0 -0
  34. {apexdevkit-1.8.2 → apexdevkit-1.8.4}/apexdevkit/testing/database.py +0 -0
  35. {apexdevkit-1.8.2 → apexdevkit-1.8.4}/apexdevkit/testing/fake.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: apexdevkit
3
- Version: 1.8.2
3
+ Version: 1.8.4
4
4
  Summary: Apex Development Tools for python.
5
5
  Author: Apex Dev
6
6
  Author-email: dev@apex.ge
@@ -8,6 +8,7 @@ from httpx import Client
8
8
 
9
9
  from apexdevkit.http.fluent import HttpMethod, HttpResponse
10
10
  from apexdevkit.http.json import JsonDict
11
+ from apexdevkit.http.url import HttpUrl
11
12
 
12
13
 
13
14
  def default_config() -> HttpxConfig:
@@ -22,12 +23,10 @@ class Httpx:
22
23
 
23
24
  @classmethod
24
25
  def create_for(cls, url: str) -> Self:
25
- return cls(Client(base_url=url), HttpxConfig())
26
+ return cls(Client(base_url=url))
26
27
 
27
28
  def with_endpoint(self, value: str) -> Httpx:
28
- self.client.base_url = self.client.base_url.join(value)
29
-
30
- return self
29
+ return Httpx(self.client, self.config.with_endpoint(value))
31
30
 
32
31
  def with_header(self, key: str, value: str) -> Httpx:
33
32
  return Httpx(self.client, self.config.with_header(key, value))
@@ -39,7 +38,12 @@ class Httpx:
39
38
  return Httpx(self.client, self.config.with_json(value))
40
39
 
41
40
  def request(self, method: HttpMethod, endpoint: str = "") -> HttpResponse:
42
- return _HttpxResponse(self.client.request(method.name, endpoint, **self.config))
41
+ return _HttpxResponse(
42
+ self.client.request(
43
+ method.name,
44
+ **self.config.with_endpoint(endpoint),
45
+ )
46
+ )
43
47
 
44
48
 
45
49
  @dataclass
@@ -58,14 +62,22 @@ class _HttpxResponse:
58
62
 
59
63
  @dataclass(frozen=True)
60
64
  class HttpxConfig(Mapping[str, Any]):
61
- timeout_s: int = 30
65
+ endpoint: str = ""
62
66
  headers: JsonDict = field(default_factory=JsonDict)
63
67
  params: JsonDict = field(default_factory=JsonDict)
64
68
  json: JsonDict = field(default_factory=JsonDict)
65
69
 
70
+ def with_endpoint(self, endpoint: str) -> HttpxConfig:
71
+ return HttpxConfig(
72
+ endpoint=HttpUrl(self.endpoint) + endpoint,
73
+ headers=self.headers,
74
+ params=self.params,
75
+ json=self.json,
76
+ )
77
+
66
78
  def with_header(self, key: str, value: str) -> HttpxConfig:
67
79
  return HttpxConfig(
68
- timeout_s=self.timeout_s,
80
+ endpoint=self.endpoint,
69
81
  headers=self.headers.merge(JsonDict({key: value})),
70
82
  params=self.params,
71
83
  json=self.json,
@@ -73,7 +85,7 @@ class HttpxConfig(Mapping[str, Any]):
73
85
 
74
86
  def with_param(self, key: str, value: str) -> HttpxConfig:
75
87
  return HttpxConfig(
76
- timeout_s=self.timeout_s,
88
+ endpoint=self.endpoint,
77
89
  headers=self.headers,
78
90
  params=self.params.merge(JsonDict({key: value})),
79
91
  json=self.json,
@@ -81,7 +93,7 @@ class HttpxConfig(Mapping[str, Any]):
81
93
 
82
94
  def with_json(self, value: JsonDict) -> HttpxConfig:
83
95
  return HttpxConfig(
84
- timeout_s=self.timeout_s,
96
+ endpoint=self.endpoint,
85
97
  headers=self.headers,
86
98
  params=self.params,
87
99
  json=value,
@@ -89,7 +101,7 @@ class HttpxConfig(Mapping[str, Any]):
89
101
 
90
102
  def as_dict(self) -> dict[str, Any]:
91
103
  return {
92
- "timeout": self.timeout_s,
104
+ "url": self.endpoint,
93
105
  "headers": dict(self.headers),
94
106
  "params": dict(self.params),
95
107
  "json": dict(self.json),
@@ -120,21 +120,21 @@ class RestfulName:
120
120
  return HttpUrl(self.plural) + other
121
121
 
122
122
 
123
- def as_plural(singular: str) -> str: # pragma: no cover
124
- if singular.endswith("y"):
125
- return singular[:-1] + "ies"
126
-
127
- if singular.endswith("ch") or singular.endswith("sh") or singular.endswith("ss"):
128
- return singular[:-2] + "es"
129
-
130
- if singular.endswith("s") or singular.endswith("z") or singular.endswith("x"):
131
- return singular[:-1] + "es"
132
-
133
- if singular.endswith("fe"):
134
- return singular[:-2] + "ves"
135
-
136
- if singular.endswith("f"):
137
- return singular[:-1] + "ves"
123
+ def as_plural(singular: str) -> str:
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
138
138
 
139
139
  return singular + "s"
140
140
 
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "apexdevkit"
3
- version = "1.8.2"
3
+ version = "1.8.4"
4
4
  description = "Apex Development Tools for python."
5
5
  authors = ["Apex Dev <dev@apex.ge>"]
6
6
  readme = "README.md"
File without changes
File without changes