GeneralManager 0.10.2__tar.gz → 0.10.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.
- {generalmanager-0.10.2 → generalmanager-0.10.3}/GeneralManager.egg-info/PKG-INFO +1 -1
- {generalmanager-0.10.2 → generalmanager-0.10.3}/PKG-INFO +1 -1
- {generalmanager-0.10.2 → generalmanager-0.10.3}/pyproject.toml +1 -1
- {generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/bucket/baseBucket.py +36 -31
- {generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/bucket/calculationBucket.py +1 -1
- {generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/bucket/databaseBucket.py +9 -2
- {generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/bucket/groupBucket.py +1 -1
- {generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/cache/modelDependencyCollector.py +6 -4
- {generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/utils/testing.py +66 -7
- {generalmanager-0.10.2 → generalmanager-0.10.3}/GeneralManager.egg-info/SOURCES.txt +0 -0
- {generalmanager-0.10.2 → generalmanager-0.10.3}/GeneralManager.egg-info/dependency_links.txt +0 -0
- {generalmanager-0.10.2 → generalmanager-0.10.3}/GeneralManager.egg-info/requires.txt +0 -0
- {generalmanager-0.10.2 → generalmanager-0.10.3}/GeneralManager.egg-info/top_level.txt +0 -0
- {generalmanager-0.10.2 → generalmanager-0.10.3}/LICENSE +0 -0
- {generalmanager-0.10.2 → generalmanager-0.10.3}/README.md +0 -0
- {generalmanager-0.10.2 → generalmanager-0.10.3}/setup.cfg +0 -0
- {generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/__init__.py +0 -0
- {generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/api/graphql.py +0 -0
- {generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/api/mutation.py +0 -0
- {generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/api/property.py +0 -0
- {generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/apps.py +0 -0
- {generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/cache/cacheDecorator.py +0 -0
- {generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/cache/cacheTracker.py +0 -0
- {generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/cache/dependencyIndex.py +0 -0
- {generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/cache/signals.py +0 -0
- {generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/factory/__init__.py +0 -0
- {generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/factory/autoFactory.py +0 -0
- {generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/factory/factories.py +0 -0
- {generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/factory/factoryMethods.py +0 -0
- {generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/interface/__init__.py +0 -0
- {generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/interface/baseInterface.py +0 -0
- {generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/interface/calculationInterface.py +0 -0
- {generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/interface/databaseBasedInterface.py +0 -0
- {generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/interface/databaseInterface.py +0 -0
- {generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/interface/models.py +0 -0
- {generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/interface/readOnlyInterface.py +0 -0
- {generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/manager/__init__.py +0 -0
- {generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/manager/generalManager.py +0 -0
- {generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/manager/groupManager.py +0 -0
- {generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/manager/input.py +0 -0
- {generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/manager/meta.py +0 -0
- {generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/measurement/__init__.py +0 -0
- {generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/measurement/measurement.py +0 -0
- {generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/measurement/measurementField.py +0 -0
- {generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/permission/__init__.py +0 -0
- {generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/permission/basePermission.py +0 -0
- {generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/permission/fileBasedPermission.py +0 -0
- {generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/permission/managerBasedPermission.py +0 -0
- {generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/permission/permissionChecks.py +0 -0
- {generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/permission/permissionDataManager.py +0 -0
- {generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/rule/__init__.py +0 -0
- {generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/rule/handler.py +0 -0
- {generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/rule/rule.py +0 -0
- {generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/utils/__init__.py +0 -0
- {generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/utils/argsToKwargs.py +0 -0
- {generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/utils/filterParser.py +0 -0
- {generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/utils/formatString.py +0 -0
- {generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/utils/jsonEncoder.py +0 -0
- {generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/utils/makeCacheKey.py +0 -0
- {generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/utils/noneToZero.py +0 -0
- {generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/utils/pathMapping.py +0 -0
- {generalmanager-0.10.2 → generalmanager-0.10.3}/tests/test_settings.py +0 -0
- {generalmanager-0.10.2 → generalmanager-0.10.3}/tests/test_urls.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: GeneralManager
|
3
|
-
Version: 0.10.
|
3
|
+
Version: 0.10.3
|
4
4
|
Summary: Modular Django-based data management framework with ORM, GraphQL, fine-grained permissions, rule validation, calculations and caching.
|
5
5
|
Author-email: Tim Kleindick <tkleindick@yahoo.de>
|
6
6
|
License-Expression: MIT
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: GeneralManager
|
3
|
-
Version: 0.10.
|
3
|
+
Version: 0.10.3
|
4
4
|
Summary: Modular Django-based data management framework with ORM, GraphQL, fine-grained permissions, rule validation, calculations and caching.
|
5
5
|
Author-email: Tim Kleindick <tkleindick@yahoo.de>
|
6
6
|
License-Expression: MIT
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
4
4
|
|
5
5
|
[project]
|
6
6
|
name = "GeneralManager"
|
7
|
-
version = "0.10.
|
7
|
+
version = "0.10.3"
|
8
8
|
description = "Modular Django-based data management framework with ORM, GraphQL, fine-grained permissions, rule validation, calculations and caching."
|
9
9
|
readme = "README.md"
|
10
10
|
authors = [{ name = "Tim Kleindick", email = "tkleindick@yahoo.de" }]
|
@@ -15,6 +15,7 @@ if TYPE_CHECKING:
|
|
15
15
|
from general_manager.manager.generalManager import GeneralManager
|
16
16
|
from general_manager.manager.groupManager import GroupManager
|
17
17
|
from general_manager.bucket.groupBucket import GroupBucket
|
18
|
+
from general_manager.interface.baseInterface import InterfaceBase
|
18
19
|
|
19
20
|
|
20
21
|
class Bucket(ABC, Generic[GeneralManagerType]):
|
@@ -22,7 +23,7 @@ class Bucket(ABC, Generic[GeneralManagerType]):
|
|
22
23
|
def __init__(self, manager_class: Type[GeneralManagerType]):
|
23
24
|
"""
|
24
25
|
Initializes the Bucket with a specified manager class.
|
25
|
-
|
26
|
+
|
26
27
|
Args:
|
27
28
|
manager_class: The class of manager objects this bucket will manage.
|
28
29
|
"""
|
@@ -34,7 +35,7 @@ class Bucket(ABC, Generic[GeneralManagerType]):
|
|
34
35
|
def __eq__(self, other: object) -> bool:
|
35
36
|
"""
|
36
37
|
Checks if this Bucket is equal to another by comparing class, data, and manager class.
|
37
|
-
|
38
|
+
|
38
39
|
Returns:
|
39
40
|
True if both objects are of the same class and have equal internal data and manager class; otherwise, False.
|
40
41
|
"""
|
@@ -45,7 +46,7 @@ class Bucket(ABC, Generic[GeneralManagerType]):
|
|
45
46
|
def __reduce__(self) -> str | tuple[Any, ...]:
|
46
47
|
"""
|
47
48
|
Prepares the object for pickling by returning the class and initialization arguments.
|
48
|
-
|
49
|
+
|
49
50
|
Returns:
|
50
51
|
A tuple containing the class and a tuple of arguments needed to reconstruct the object during unpickling.
|
51
52
|
"""
|
@@ -56,14 +57,18 @@ class Bucket(ABC, Generic[GeneralManagerType]):
|
|
56
57
|
|
57
58
|
@abstractmethod
|
58
59
|
def __or__(
|
59
|
-
self,
|
60
|
+
self,
|
61
|
+
other: (
|
62
|
+
Bucket[GeneralManagerType]
|
63
|
+
| GeneralManager[GeneralManagerType, InterfaceBase]
|
64
|
+
),
|
60
65
|
) -> Bucket[GeneralManagerType]:
|
61
66
|
"""
|
62
67
|
Returns a new bucket representing the union of this bucket and another bucket or manager instance.
|
63
|
-
|
68
|
+
|
64
69
|
Args:
|
65
70
|
other: Another bucket or a single manager instance to combine with this bucket.
|
66
|
-
|
71
|
+
|
67
72
|
Returns:
|
68
73
|
A new bucket containing all unique items from both sources.
|
69
74
|
"""
|
@@ -72,10 +77,10 @@ class Bucket(ABC, Generic[GeneralManagerType]):
|
|
72
77
|
@abstractmethod
|
73
78
|
def __iter__(
|
74
79
|
self,
|
75
|
-
) -> Generator[GeneralManagerType | GroupManager[GeneralManagerType]]:
|
80
|
+
) -> Generator[GeneralManagerType | GroupManager[GeneralManagerType], None, None]:
|
76
81
|
"""
|
77
82
|
Returns an iterator over the items in the bucket.
|
78
|
-
|
83
|
+
|
79
84
|
Yields:
|
80
85
|
Instances of the managed type or group manager contained in the bucket.
|
81
86
|
"""
|
@@ -85,10 +90,10 @@ class Bucket(ABC, Generic[GeneralManagerType]):
|
|
85
90
|
def filter(self, **kwargs: Any) -> Bucket[GeneralManagerType]:
|
86
91
|
"""
|
87
92
|
Returns a new bucket containing only items that match the specified filter criteria.
|
88
|
-
|
93
|
+
|
89
94
|
Args:
|
90
95
|
**kwargs: Field-value pairs used to filter items in the bucket.
|
91
|
-
|
96
|
+
|
92
97
|
Returns:
|
93
98
|
A new Bucket instance with items matching the given criteria.
|
94
99
|
"""
|
@@ -98,10 +103,10 @@ class Bucket(ABC, Generic[GeneralManagerType]):
|
|
98
103
|
def exclude(self, **kwargs: Any) -> Bucket[GeneralManagerType]:
|
99
104
|
"""
|
100
105
|
Returns a new Bucket excluding items that match the specified criteria.
|
101
|
-
|
106
|
+
|
102
107
|
Args:
|
103
108
|
**kwargs: Field-value pairs specifying the exclusion criteria.
|
104
|
-
|
109
|
+
|
105
110
|
Returns:
|
106
111
|
A new Bucket instance with items matching the criteria excluded.
|
107
112
|
"""
|
@@ -111,7 +116,7 @@ class Bucket(ABC, Generic[GeneralManagerType]):
|
|
111
116
|
def first(self) -> GeneralManagerType | GroupManager[GeneralManagerType] | None:
|
112
117
|
"""
|
113
118
|
Returns the first item in the bucket, or None if the bucket is empty.
|
114
|
-
|
119
|
+
|
115
120
|
Returns:
|
116
121
|
The first GeneralManager or GroupManager instance, or None if no items exist.
|
117
122
|
"""
|
@@ -121,7 +126,7 @@ class Bucket(ABC, Generic[GeneralManagerType]):
|
|
121
126
|
def last(self) -> GeneralManagerType | GroupManager[GeneralManagerType] | None:
|
122
127
|
"""
|
123
128
|
Returns the last item in the bucket, or None if the bucket is empty.
|
124
|
-
|
129
|
+
|
125
130
|
Returns:
|
126
131
|
The last GeneralManager or GroupManager instance, or None if no items exist.
|
127
132
|
"""
|
@@ -131,7 +136,7 @@ class Bucket(ABC, Generic[GeneralManagerType]):
|
|
131
136
|
def count(self) -> int:
|
132
137
|
"""
|
133
138
|
Returns the number of items in the bucket.
|
134
|
-
|
139
|
+
|
135
140
|
Subclasses must implement this method to provide the count of contained elements.
|
136
141
|
"""
|
137
142
|
raise NotImplementedError
|
@@ -140,7 +145,7 @@ class Bucket(ABC, Generic[GeneralManagerType]):
|
|
140
145
|
def all(self) -> Bucket[GeneralManagerType]:
|
141
146
|
"""
|
142
147
|
Returns a bucket containing all items managed by this instance.
|
143
|
-
|
148
|
+
|
144
149
|
Subclasses must implement this method to provide access to the complete collection without filters or exclusions applied.
|
145
150
|
"""
|
146
151
|
raise NotImplementedError
|
@@ -151,13 +156,13 @@ class Bucket(ABC, Generic[GeneralManagerType]):
|
|
151
156
|
) -> GeneralManagerType | GroupManager[GeneralManagerType]:
|
152
157
|
"""
|
153
158
|
Retrieves a single item matching the specified criteria.
|
154
|
-
|
159
|
+
|
155
160
|
Args:
|
156
161
|
**kwargs: Field-value pairs used to identify the item.
|
157
|
-
|
162
|
+
|
158
163
|
Returns:
|
159
164
|
The matching GeneralManager or GroupManager instance.
|
160
|
-
|
165
|
+
|
161
166
|
Raises:
|
162
167
|
NotImplementedError: If the method is not implemented by a subclass.
|
163
168
|
"""
|
@@ -173,13 +178,13 @@ class Bucket(ABC, Generic[GeneralManagerType]):
|
|
173
178
|
):
|
174
179
|
"""
|
175
180
|
Retrieves an item or a slice from the bucket.
|
176
|
-
|
181
|
+
|
177
182
|
Args:
|
178
183
|
item: An integer index to retrieve a single element, or a slice to retrieve a subset.
|
179
|
-
|
184
|
+
|
180
185
|
Returns:
|
181
186
|
A single manager instance if an integer is provided, or a new Bucket containing the sliced elements if a slice is provided.
|
182
|
-
|
187
|
+
|
183
188
|
Raises:
|
184
189
|
NotImplementedError: This method must be implemented by subclasses.
|
185
190
|
"""
|
@@ -189,7 +194,7 @@ class Bucket(ABC, Generic[GeneralManagerType]):
|
|
189
194
|
def __len__(self) -> int:
|
190
195
|
"""
|
191
196
|
Returns the number of items in the bucket.
|
192
|
-
|
197
|
+
|
193
198
|
Subclasses must implement this method to provide the count of contained elements.
|
194
199
|
"""
|
195
200
|
raise NotImplementedError
|
@@ -198,12 +203,12 @@ class Bucket(ABC, Generic[GeneralManagerType]):
|
|
198
203
|
def __contains__(self, item: GeneralManagerType) -> bool:
|
199
204
|
"""
|
200
205
|
Checks whether the specified item is present in the bucket.
|
201
|
-
|
206
|
+
|
202
207
|
Args:
|
203
|
-
|
204
|
-
|
208
|
+
item: The manager instance to check for membership.
|
209
|
+
|
205
210
|
Returns:
|
206
|
-
|
211
|
+
True if the item is contained in the bucket, otherwise False.
|
207
212
|
"""
|
208
213
|
raise NotImplementedError
|
209
214
|
|
@@ -215,11 +220,11 @@ class Bucket(ABC, Generic[GeneralManagerType]):
|
|
215
220
|
) -> Bucket[GeneralManagerType]:
|
216
221
|
"""
|
217
222
|
Returns a new Bucket with items sorted by the specified key or keys.
|
218
|
-
|
223
|
+
|
219
224
|
Args:
|
220
225
|
key: A string or tuple of strings specifying the attribute(s) to sort by.
|
221
226
|
reverse: If True, sorts in descending order. Defaults to False.
|
222
|
-
|
227
|
+
|
223
228
|
Returns:
|
224
229
|
A new Bucket instance with items sorted according to the given key(s).
|
225
230
|
"""
|
@@ -228,10 +233,10 @@ class Bucket(ABC, Generic[GeneralManagerType]):
|
|
228
233
|
def group_by(self, *group_by_keys: str) -> GroupBucket[GeneralManagerType]:
|
229
234
|
"""
|
230
235
|
Groups the bucket's data by one or more specified keys.
|
231
|
-
|
236
|
+
|
232
237
|
Args:
|
233
238
|
*group_by_keys: One or more attribute names to group the data by.
|
234
|
-
|
239
|
+
|
235
240
|
Returns:
|
236
241
|
A GroupBucket instance containing the grouped data.
|
237
242
|
"""
|
{generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/bucket/calculationBucket.py
RENAMED
@@ -190,7 +190,7 @@ class CalculationBucket(Bucket[GeneralManagerType]):
|
|
190
190
|
"""
|
191
191
|
return self
|
192
192
|
|
193
|
-
def __iter__(self) -> Generator[GeneralManagerType]:
|
193
|
+
def __iter__(self) -> Generator[GeneralManagerType, None, None]:
|
194
194
|
"""
|
195
195
|
Yields manager instances for each valid combination of input parameters.
|
196
196
|
|
{generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/bucket/databaseBucket.py
RENAMED
@@ -4,6 +4,7 @@ from typing import (
|
|
4
4
|
Any,
|
5
5
|
Generator,
|
6
6
|
TypeVar,
|
7
|
+
TYPE_CHECKING,
|
7
8
|
)
|
8
9
|
from django.db import models
|
9
10
|
from general_manager.interface.baseInterface import (
|
@@ -15,6 +16,9 @@ from general_manager.manager.generalManager import GeneralManager
|
|
15
16
|
|
16
17
|
modelsModel = TypeVar("modelsModel", bound=models.Model)
|
17
18
|
|
19
|
+
if TYPE_CHECKING:
|
20
|
+
from general_manager.interface.databaseInterface import DatabaseInterface
|
21
|
+
|
18
22
|
|
19
23
|
class DatabaseBucket(Bucket[GeneralManagerType]):
|
20
24
|
|
@@ -40,7 +44,7 @@ class DatabaseBucket(Bucket[GeneralManagerType]):
|
|
40
44
|
self.filters = {**(filter_definitions or {})}
|
41
45
|
self.excludes = {**(exclude_definitions or {})}
|
42
46
|
|
43
|
-
def __iter__(self) -> Generator[GeneralManagerType]:
|
47
|
+
def __iter__(self) -> Generator[GeneralManagerType, None, None]:
|
44
48
|
"""
|
45
49
|
Yields manager instances for each item in the underlying queryset.
|
46
50
|
|
@@ -51,7 +55,10 @@ class DatabaseBucket(Bucket[GeneralManagerType]):
|
|
51
55
|
|
52
56
|
def __or__(
|
53
57
|
self,
|
54
|
-
other:
|
58
|
+
other: (
|
59
|
+
Bucket[GeneralManagerType]
|
60
|
+
| GeneralManager[GeneralManagerType, DatabaseInterface]
|
61
|
+
),
|
55
62
|
) -> DatabaseBucket[GeneralManagerType]:
|
56
63
|
"""
|
57
64
|
Combines this bucket with another bucket or manager instance using the union operator.
|
@@ -117,7 +117,7 @@ class GroupBucket(Bucket[GeneralManagerType]):
|
|
117
117
|
self._basis_data | other._basis_data,
|
118
118
|
)
|
119
119
|
|
120
|
-
def __iter__(self) -> Generator[GroupManager[GeneralManagerType]]:
|
120
|
+
def __iter__(self) -> Generator[GroupManager[GeneralManagerType], None, None]:
|
121
121
|
"""
|
122
122
|
Yields each grouped manager in the current GroupBucket.
|
123
123
|
|
@@ -11,15 +11,17 @@ from general_manager.cache.dependencyIndex import (
|
|
11
11
|
class ModelDependencyCollector:
|
12
12
|
|
13
13
|
@staticmethod
|
14
|
-
def collect(
|
14
|
+
def collect(
|
15
|
+
obj,
|
16
|
+
) -> Generator[tuple[general_manager_name, filter_type, str], None, None]:
|
15
17
|
"""
|
16
18
|
Recursively extracts dependency information from Django model-related objects.
|
17
|
-
|
19
|
+
|
18
20
|
Inspects the input object and its nested structures to identify instances of GeneralManager and Bucket, yielding a tuple for each dependency found. Each tuple contains the manager class name, the dependency type ("identification", "filter", or "exclude"), and the string representation of the dependency value.
|
19
|
-
|
21
|
+
|
20
22
|
Args:
|
21
23
|
obj: The object or collection to inspect for model dependencies.
|
22
|
-
|
24
|
+
|
23
25
|
Yields:
|
24
26
|
Tuples of (manager class name, dependency type, dependency value) for each dependency discovered.
|
25
27
|
"""
|
@@ -6,8 +6,10 @@ from django.conf import settings
|
|
6
6
|
from typing import cast
|
7
7
|
from django.db import models
|
8
8
|
from general_manager.manager.generalManager import GeneralManager
|
9
|
+
from general_manager.manager.meta import GeneralManagerMeta
|
9
10
|
from general_manager.api.graphql import GraphQL
|
10
11
|
from django.apps import apps as global_apps
|
12
|
+
from contextlib import suppress
|
11
13
|
|
12
14
|
|
13
15
|
from unittest.mock import ANY
|
@@ -70,7 +72,7 @@ class GMTestCaseMeta(type):
|
|
70
72
|
def __new__(mcs, name, bases, attrs):
|
71
73
|
"""
|
72
74
|
Creates a new test case class with a customized setUpClass method for GeneralManager and GraphQL integration tests.
|
73
|
-
|
75
|
+
|
74
76
|
The generated setUpClass ensures the test environment is properly initialized by resetting GraphQL registries, applying any user-defined setup, clearing default GraphQL URL patterns, creating missing database tables for specified GeneralManager models and their history, initializing GeneralManager and GraphQL configurations, and invoking the base GraphQLTransactionTestCase setup.
|
75
77
|
"""
|
76
78
|
user_setup = attrs.get("setUpClass")
|
@@ -81,7 +83,7 @@ class GMTestCaseMeta(type):
|
|
81
83
|
def wrapped_setUpClass(cls):
|
82
84
|
"""
|
83
85
|
Performs setup for a test case class by resetting GraphQL internals, configuring fallback app lookup, clearing default GraphQL URL patterns, ensuring database tables exist for specified GeneralManager models and their history, initializing GeneralManager and GraphQL configurations, and invoking the base test case setup.
|
84
|
-
|
86
|
+
|
85
87
|
Skips database table creation for any GeneralManager class lacking an `Interface` or `_model` attribute.
|
86
88
|
"""
|
87
89
|
GraphQL._query_class = None
|
@@ -139,12 +141,12 @@ class LoggingCache(LocMemCache):
|
|
139
141
|
def get(self, key, default=None, version=None):
|
140
142
|
"""
|
141
143
|
Retrieve a value from the cache and log whether it was a cache hit or miss.
|
142
|
-
|
144
|
+
|
143
145
|
Parameters:
|
144
146
|
key (str): The cache key to retrieve.
|
145
147
|
default: The value to return if the key is not found.
|
146
148
|
version: Optional cache version.
|
147
|
-
|
149
|
+
|
148
150
|
Returns:
|
149
151
|
The cached value if found; otherwise, the default value.
|
150
152
|
"""
|
@@ -155,7 +157,7 @@ class LoggingCache(LocMemCache):
|
|
155
157
|
def set(self, key, value, timeout=None, version=None):
|
156
158
|
"""
|
157
159
|
Store a value in the cache and log the set operation.
|
158
|
-
|
160
|
+
|
159
161
|
Parameters:
|
160
162
|
key (str): The cache key to set.
|
161
163
|
value (Any): The value to store in the cache.
|
@@ -189,11 +191,68 @@ class GeneralManagerTransactionTestCase(
|
|
189
191
|
setattr(caches._connections, "default", LoggingCache("test-cache", {})) # type: ignore
|
190
192
|
self.__resetCacheCounter()
|
191
193
|
|
194
|
+
@classmethod
|
195
|
+
def tearDownClass(cls) -> None:
|
196
|
+
"""Clean up dynamic managers and restore patched globals."""
|
197
|
+
# remove GraphQL URL pattern added during setUpClass
|
198
|
+
_default_graphql_url_clear()
|
199
|
+
|
200
|
+
# drop generated tables and unregister models from Django's app registry
|
201
|
+
existing = connection.introspection.table_names()
|
202
|
+
with connection.schema_editor() as editor:
|
203
|
+
for manager_class in cls.general_manager_classes:
|
204
|
+
interface = getattr(manager_class, "Interface", None)
|
205
|
+
model = getattr(interface, "_model", None)
|
206
|
+
if not model:
|
207
|
+
continue
|
208
|
+
model = cast(type[models.Model], model)
|
209
|
+
if model._meta.db_table in existing:
|
210
|
+
editor.delete_model(model)
|
211
|
+
history_model = getattr(model, "history", None)
|
212
|
+
if history_model and history_model.model._meta.db_table in existing:
|
213
|
+
editor.delete_model(history_model.model)
|
214
|
+
|
215
|
+
app_label = model._meta.app_label
|
216
|
+
model_key = model.__name__.lower()
|
217
|
+
global_apps.all_models[app_label].pop(model_key, None)
|
218
|
+
app_config = global_apps.get_app_config(app_label)
|
219
|
+
with suppress(LookupError):
|
220
|
+
app_config.models.pop(model_key, None)
|
221
|
+
if history_model:
|
222
|
+
hist_key = history_model.model.__name__.lower()
|
223
|
+
global_apps.all_models[app_label].pop(hist_key, None)
|
224
|
+
with suppress(LookupError):
|
225
|
+
app_config.models.pop(hist_key, None)
|
226
|
+
|
227
|
+
global_apps.clear_cache()
|
228
|
+
|
229
|
+
# remove classes from metaclass registries
|
230
|
+
GeneralManagerMeta.all_classes = [
|
231
|
+
gm
|
232
|
+
for gm in GeneralManagerMeta.all_classes
|
233
|
+
if gm not in cls.general_manager_classes
|
234
|
+
]
|
235
|
+
GeneralManagerMeta.pending_graphql_interfaces = [
|
236
|
+
gm
|
237
|
+
for gm in GeneralManagerMeta.pending_graphql_interfaces
|
238
|
+
if gm not in cls.general_manager_classes
|
239
|
+
]
|
240
|
+
GeneralManagerMeta.pending_attribute_initialization = [
|
241
|
+
gm
|
242
|
+
for gm in GeneralManagerMeta.pending_attribute_initialization
|
243
|
+
if gm not in cls.general_manager_classes
|
244
|
+
]
|
245
|
+
|
246
|
+
# reset fallback app lookup
|
247
|
+
global_apps.get_containing_app_config = _original_get_app
|
248
|
+
|
249
|
+
super().tearDownClass()
|
250
|
+
|
192
251
|
#
|
193
252
|
def assertCacheMiss(self):
|
194
253
|
"""
|
195
254
|
Assert that a cache miss occurred, followed by a cache set operation.
|
196
|
-
|
255
|
+
|
197
256
|
Checks that the cache's `get` method was called and did not find a value, and that the `set` method was subsequently called to store a value. Resets the cache operation log after the assertion.
|
198
257
|
"""
|
199
258
|
ops = getattr(caches["default"], "ops")
|
@@ -208,7 +267,7 @@ class GeneralManagerTransactionTestCase(
|
|
208
267
|
def assertCacheHit(self):
|
209
268
|
"""
|
210
269
|
Assert that a cache get operation resulted in a cache hit and no cache set operation occurred.
|
211
|
-
|
270
|
+
|
212
271
|
Raises an assertion error if the cache did not return a value for a get operation or if a set operation was performed. Resets the cache operation log after the check.
|
213
272
|
"""
|
214
273
|
ops = getattr(caches["default"], "ops")
|
File without changes
|
{generalmanager-0.10.2 → generalmanager-0.10.3}/GeneralManager.egg-info/dependency_links.txt
RENAMED
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
|
{generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/cache/dependencyIndex.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/factory/factoryMethods.py
RENAMED
File without changes
|
File without changes
|
{generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/interface/baseInterface.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/interface/databaseInterface.py
RENAMED
File without changes
|
File without changes
|
{generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/interface/readOnlyInterface.py
RENAMED
File without changes
|
File without changes
|
{generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/manager/generalManager.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/measurement/measurement.py
RENAMED
File without changes
|
{generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/measurement/measurementField.py
RENAMED
File without changes
|
File without changes
|
{generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/permission/basePermission.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{generalmanager-0.10.2 → generalmanager-0.10.3}/src/general_manager/permission/permissionChecks.py
RENAMED
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
|