apexdevkit 1.15.6__tar.gz → 1.15.7__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.15.6 → apexdevkit-1.15.7}/PKG-INFO +1 -1
- {apexdevkit-1.15.6 → apexdevkit-1.15.7}/apexdevkit/formatter.py +12 -0
- {apexdevkit-1.15.6 → apexdevkit-1.15.7}/apexdevkit/testing/__init__.py +2 -0
- {apexdevkit-1.15.6 → apexdevkit-1.15.7}/apexdevkit/testing/fake.py +16 -0
- apexdevkit-1.15.7/apexdevkit/value.py +29 -0
- {apexdevkit-1.15.6 → apexdevkit-1.15.7}/pyproject.toml +1 -1
- {apexdevkit-1.15.6 → apexdevkit-1.15.7}/LICENSE +0 -0
- {apexdevkit-1.15.6 → apexdevkit-1.15.7}/README.md +0 -0
- {apexdevkit-1.15.6 → apexdevkit-1.15.7}/apexdevkit/__init__.py +0 -0
- {apexdevkit-1.15.6 → apexdevkit-1.15.7}/apexdevkit/annotation/__init__.py +0 -0
- {apexdevkit-1.15.6 → apexdevkit-1.15.7}/apexdevkit/annotation/deprecate.py +0 -0
- {apexdevkit-1.15.6 → apexdevkit-1.15.7}/apexdevkit/environment.py +0 -0
- {apexdevkit-1.15.6 → apexdevkit-1.15.7}/apexdevkit/error.py +0 -0
- {apexdevkit-1.15.6 → apexdevkit-1.15.7}/apexdevkit/fastapi/__init__.py +0 -0
- {apexdevkit-1.15.6 → apexdevkit-1.15.7}/apexdevkit/fastapi/builder.py +0 -0
- {apexdevkit-1.15.6 → apexdevkit-1.15.7}/apexdevkit/fastapi/dependable.py +0 -0
- {apexdevkit-1.15.6 → apexdevkit-1.15.7}/apexdevkit/fastapi/docs.py +0 -0
- {apexdevkit-1.15.6 → apexdevkit-1.15.7}/apexdevkit/fastapi/resource.py +0 -0
- {apexdevkit-1.15.6 → apexdevkit-1.15.7}/apexdevkit/fastapi/response.py +0 -0
- {apexdevkit-1.15.6 → apexdevkit-1.15.7}/apexdevkit/fastapi/router.py +0 -0
- {apexdevkit-1.15.6 → apexdevkit-1.15.7}/apexdevkit/fastapi/schema.py +0 -0
- {apexdevkit-1.15.6 → apexdevkit-1.15.7}/apexdevkit/fastapi/service.py +0 -0
- {apexdevkit-1.15.6 → apexdevkit-1.15.7}/apexdevkit/fluent.py +0 -0
- {apexdevkit-1.15.6 → apexdevkit-1.15.7}/apexdevkit/http/__init__.py +0 -0
- {apexdevkit-1.15.6 → apexdevkit-1.15.7}/apexdevkit/http/fake.py +0 -0
- {apexdevkit-1.15.6 → apexdevkit-1.15.7}/apexdevkit/http/fluent.py +0 -0
- {apexdevkit-1.15.6 → apexdevkit-1.15.7}/apexdevkit/http/httpx.py +0 -0
- {apexdevkit-1.15.6 → apexdevkit-1.15.7}/apexdevkit/http/json.py +0 -0
- {apexdevkit-1.15.6 → apexdevkit-1.15.7}/apexdevkit/http/url.py +0 -0
- {apexdevkit-1.15.6 → apexdevkit-1.15.7}/apexdevkit/key_fn.py +0 -0
- {apexdevkit-1.15.6 → apexdevkit-1.15.7}/apexdevkit/py.typed +0 -0
- {apexdevkit-1.15.6 → apexdevkit-1.15.7}/apexdevkit/repository/__init__.py +0 -0
- {apexdevkit-1.15.6 → apexdevkit-1.15.7}/apexdevkit/repository/base.py +0 -0
- {apexdevkit-1.15.6 → apexdevkit-1.15.7}/apexdevkit/repository/connector.py +0 -0
- {apexdevkit-1.15.6 → apexdevkit-1.15.7}/apexdevkit/repository/database.py +0 -0
- {apexdevkit-1.15.6 → apexdevkit-1.15.7}/apexdevkit/repository/decorator.py +0 -0
- {apexdevkit-1.15.6 → apexdevkit-1.15.7}/apexdevkit/repository/in_memory.py +0 -0
- {apexdevkit-1.15.6 → apexdevkit-1.15.7}/apexdevkit/repository/interface.py +0 -0
- {apexdevkit-1.15.6 → apexdevkit-1.15.7}/apexdevkit/repository/mongo.py +0 -0
- {apexdevkit-1.15.6 → apexdevkit-1.15.7}/apexdevkit/repository/mssql.py +0 -0
- {apexdevkit-1.15.6 → apexdevkit-1.15.7}/apexdevkit/repository/sqlite.py +0 -0
- {apexdevkit-1.15.6 → apexdevkit-1.15.7}/apexdevkit/server.py +0 -0
- {apexdevkit-1.15.6 → apexdevkit-1.15.7}/apexdevkit/synchronization.py +0 -0
- {apexdevkit-1.15.6 → apexdevkit-1.15.7}/apexdevkit/testing/database.py +0 -0
- {apexdevkit-1.15.6 → apexdevkit-1.15.7}/apexdevkit/testing/rest.py +0 -0
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
1
3
|
import pickle
|
|
2
4
|
from copy import deepcopy
|
|
3
5
|
from dataclasses import asdict, dataclass, field
|
|
4
6
|
from typing import Any, Generic, Protocol, Self, TypeVar
|
|
5
7
|
|
|
8
|
+
from apexdevkit.value import Value
|
|
9
|
+
|
|
6
10
|
_SourceT = TypeVar("_SourceT")
|
|
7
11
|
_TargetT = TypeVar("_TargetT")
|
|
8
12
|
_ItemT = TypeVar("_ItemT")
|
|
@@ -59,3 +63,11 @@ class DataclassFormatter(Generic[_TargetT]):
|
|
|
59
63
|
|
|
60
64
|
def dump(self, item: _TargetT) -> dict[str, Any]:
|
|
61
65
|
return asdict(item) # type: ignore
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
class ValueFormatter:
|
|
69
|
+
def load(self, raw: dict[str, Any]) -> Value:
|
|
70
|
+
return DataclassFormatter(Value).load(raw)
|
|
71
|
+
|
|
72
|
+
def dump(self, value: Value) -> dict[str, Any]:
|
|
73
|
+
return DataclassFormatter(Value).dump(value)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
from apexdevkit.testing.database import FakeConnector
|
|
2
|
+
from apexdevkit.testing.fake import FakeValue
|
|
2
3
|
from apexdevkit.testing.rest import RestCollection, RestfulName, RestResource
|
|
3
4
|
|
|
4
5
|
__all__ = [
|
|
@@ -6,4 +7,5 @@ __all__ = [
|
|
|
6
7
|
"RestCollection",
|
|
7
8
|
"RestfulName",
|
|
8
9
|
"RestResource",
|
|
10
|
+
"FakeValue",
|
|
9
11
|
]
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import random
|
|
1
4
|
from dataclasses import dataclass, field
|
|
2
5
|
from functools import cached_property
|
|
3
6
|
from typing import Any, Generic, Type, TypeVar
|
|
@@ -5,6 +8,7 @@ from typing import Any, Generic, Type, TypeVar
|
|
|
5
8
|
from faker import Faker
|
|
6
9
|
|
|
7
10
|
from apexdevkit.http import JsonDict
|
|
11
|
+
from apexdevkit.value import Value
|
|
8
12
|
|
|
9
13
|
ItemT = TypeVar("ItemT")
|
|
10
14
|
|
|
@@ -67,3 +71,15 @@ class FakeResource(Generic[ItemT]):
|
|
|
67
71
|
|
|
68
72
|
def entity(self, **fields: Any) -> ItemT:
|
|
69
73
|
return self.item_type(**self.json().merge(JsonDict(fields)))
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
@dataclass(frozen=True)
|
|
77
|
+
class FakeValue(FakeResource[Value]):
|
|
78
|
+
item_type: Type[Value] = field(default=Value)
|
|
79
|
+
|
|
80
|
+
@cached_property
|
|
81
|
+
def _raw(self) -> dict[str, Any]:
|
|
82
|
+
return {
|
|
83
|
+
"value": self.fake.number(),
|
|
84
|
+
"exponent": random.choice([10, 100, 1000]),
|
|
85
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
from decimal import Decimal
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@dataclass(frozen=True)
|
|
8
|
+
class Value:
|
|
9
|
+
value: int = 0
|
|
10
|
+
exponent: int = 1
|
|
11
|
+
|
|
12
|
+
def as_decimal(self) -> Decimal:
|
|
13
|
+
return Decimal(self.value) / Decimal(self.exponent)
|
|
14
|
+
|
|
15
|
+
@classmethod
|
|
16
|
+
def from_string(cls, decimal_str: str) -> Value:
|
|
17
|
+
integer_part, _, fractional_part = decimal_str.partition(".")
|
|
18
|
+
value = int(integer_part + fractional_part)
|
|
19
|
+
exponent = 10 ** len(fractional_part)
|
|
20
|
+
return cls(value, exponent)
|
|
21
|
+
|
|
22
|
+
def add(self, other: Value) -> Value:
|
|
23
|
+
return Value(self.value + self._adjusted(other), self.exponent)
|
|
24
|
+
|
|
25
|
+
def subtract(self, other: Value) -> Value:
|
|
26
|
+
return Value(self.value - self._adjusted(other), self.exponent)
|
|
27
|
+
|
|
28
|
+
def _adjusted(self, other: Value) -> int:
|
|
29
|
+
return int(Decimal(other.value) / Decimal(other.exponent) * self.exponent)
|
|
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
|
|
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
|