eventsourcing 9.3.3__py3-none-any.whl → 9.3.5__py3-none-any.whl

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.

Potentially problematic release.


This version of eventsourcing might be problematic. Click here for more details.

Files changed (129) hide show
  1. eventsourcing/application.py +0 -15
  2. eventsourcing/system.py +25 -2
  3. {eventsourcing-9.3.3.dist-info → eventsourcing-9.3.5.dist-info}/METADATA +1 -1
  4. eventsourcing-9.3.5.dist-info/RECORD +24 -0
  5. eventsourcing/examples/__init__.py +0 -0
  6. eventsourcing/examples/aggregate1/__init__.py +0 -0
  7. eventsourcing/examples/aggregate1/application.py +0 -27
  8. eventsourcing/examples/aggregate1/domainmodel.py +0 -16
  9. eventsourcing/examples/aggregate1/test_application.py +0 -37
  10. eventsourcing/examples/aggregate2/__init__.py +0 -0
  11. eventsourcing/examples/aggregate2/application.py +0 -27
  12. eventsourcing/examples/aggregate2/domainmodel.py +0 -22
  13. eventsourcing/examples/aggregate2/test_application.py +0 -37
  14. eventsourcing/examples/aggregate3/__init__.py +0 -0
  15. eventsourcing/examples/aggregate3/application.py +0 -27
  16. eventsourcing/examples/aggregate3/domainmodel.py +0 -38
  17. eventsourcing/examples/aggregate3/test_application.py +0 -37
  18. eventsourcing/examples/aggregate4/__init__.py +0 -0
  19. eventsourcing/examples/aggregate4/application.py +0 -27
  20. eventsourcing/examples/aggregate4/domainmodel.py +0 -114
  21. eventsourcing/examples/aggregate4/test_application.py +0 -38
  22. eventsourcing/examples/aggregate5/__init__.py +0 -0
  23. eventsourcing/examples/aggregate5/application.py +0 -27
  24. eventsourcing/examples/aggregate5/domainmodel.py +0 -131
  25. eventsourcing/examples/aggregate5/test_application.py +0 -38
  26. eventsourcing/examples/aggregate6/__init__.py +0 -0
  27. eventsourcing/examples/aggregate6/application.py +0 -30
  28. eventsourcing/examples/aggregate6/domainmodel.py +0 -123
  29. eventsourcing/examples/aggregate6/test_application.py +0 -38
  30. eventsourcing/examples/aggregate6a/__init__.py +0 -0
  31. eventsourcing/examples/aggregate6a/application.py +0 -40
  32. eventsourcing/examples/aggregate6a/domainmodel.py +0 -149
  33. eventsourcing/examples/aggregate6a/test_application.py +0 -45
  34. eventsourcing/examples/aggregate7/__init__.py +0 -0
  35. eventsourcing/examples/aggregate7/application.py +0 -53
  36. eventsourcing/examples/aggregate7/domainmodel.py +0 -142
  37. eventsourcing/examples/aggregate7/persistence.py +0 -57
  38. eventsourcing/examples/aggregate7/test_application.py +0 -45
  39. eventsourcing/examples/aggregate7/test_compression_and_encryption.py +0 -45
  40. eventsourcing/examples/aggregate7/test_snapshotting_intervals.py +0 -67
  41. eventsourcing/examples/aggregate7a/__init__.py +0 -0
  42. eventsourcing/examples/aggregate7a/application.py +0 -56
  43. eventsourcing/examples/aggregate7a/domainmodel.py +0 -168
  44. eventsourcing/examples/aggregate7a/test_application.py +0 -46
  45. eventsourcing/examples/aggregate7a/test_compression_and_encryption.py +0 -45
  46. eventsourcing/examples/aggregate8/__init__.py +0 -0
  47. eventsourcing/examples/aggregate8/application.py +0 -47
  48. eventsourcing/examples/aggregate8/domainmodel.py +0 -71
  49. eventsourcing/examples/aggregate8/persistence.py +0 -57
  50. eventsourcing/examples/aggregate8/test_application.py +0 -44
  51. eventsourcing/examples/aggregate8/test_compression_and_encryption.py +0 -44
  52. eventsourcing/examples/aggregate8/test_snapshotting_intervals.py +0 -38
  53. eventsourcing/examples/bankaccounts/__init__.py +0 -0
  54. eventsourcing/examples/bankaccounts/application.py +0 -70
  55. eventsourcing/examples/bankaccounts/domainmodel.py +0 -56
  56. eventsourcing/examples/bankaccounts/test.py +0 -173
  57. eventsourcing/examples/cargoshipping/__init__.py +0 -0
  58. eventsourcing/examples/cargoshipping/application.py +0 -126
  59. eventsourcing/examples/cargoshipping/domainmodel.py +0 -330
  60. eventsourcing/examples/cargoshipping/interface.py +0 -143
  61. eventsourcing/examples/cargoshipping/test.py +0 -231
  62. eventsourcing/examples/contentmanagement/__init__.py +0 -0
  63. eventsourcing/examples/contentmanagement/application.py +0 -118
  64. eventsourcing/examples/contentmanagement/domainmodel.py +0 -69
  65. eventsourcing/examples/contentmanagement/test.py +0 -180
  66. eventsourcing/examples/contentmanagement/utils.py +0 -26
  67. eventsourcing/examples/contentmanagementsystem/__init__.py +0 -0
  68. eventsourcing/examples/contentmanagementsystem/application.py +0 -54
  69. eventsourcing/examples/contentmanagementsystem/postgres.py +0 -17
  70. eventsourcing/examples/contentmanagementsystem/sqlite.py +0 -17
  71. eventsourcing/examples/contentmanagementsystem/system.py +0 -14
  72. eventsourcing/examples/contentmanagementsystem/test_system.py +0 -180
  73. eventsourcing/examples/searchablecontent/__init__.py +0 -0
  74. eventsourcing/examples/searchablecontent/application.py +0 -45
  75. eventsourcing/examples/searchablecontent/persistence.py +0 -23
  76. eventsourcing/examples/searchablecontent/postgres.py +0 -118
  77. eventsourcing/examples/searchablecontent/sqlite.py +0 -136
  78. eventsourcing/examples/searchablecontent/test_application.py +0 -110
  79. eventsourcing/examples/searchablecontent/test_recorder.py +0 -68
  80. eventsourcing/examples/searchabletimestamps/__init__.py +0 -0
  81. eventsourcing/examples/searchabletimestamps/application.py +0 -32
  82. eventsourcing/examples/searchabletimestamps/persistence.py +0 -20
  83. eventsourcing/examples/searchabletimestamps/postgres.py +0 -110
  84. eventsourcing/examples/searchabletimestamps/sqlite.py +0 -99
  85. eventsourcing/examples/searchabletimestamps/test_searchabletimestamps.py +0 -94
  86. eventsourcing/examples/test_invoice.py +0 -176
  87. eventsourcing/examples/test_parking_lot.py +0 -206
  88. eventsourcing/tests/application_tests/__init__.py +0 -0
  89. eventsourcing/tests/application_tests/test_application_with_automatic_snapshotting.py +0 -55
  90. eventsourcing/tests/application_tests/test_application_with_popo.py +0 -22
  91. eventsourcing/tests/application_tests/test_application_with_postgres.py +0 -75
  92. eventsourcing/tests/application_tests/test_application_with_sqlite.py +0 -72
  93. eventsourcing/tests/application_tests/test_cache.py +0 -134
  94. eventsourcing/tests/application_tests/test_event_sourced_log.py +0 -162
  95. eventsourcing/tests/application_tests/test_notificationlog.py +0 -232
  96. eventsourcing/tests/application_tests/test_notificationlogreader.py +0 -126
  97. eventsourcing/tests/application_tests/test_processapplication.py +0 -110
  98. eventsourcing/tests/application_tests/test_processingpolicy.py +0 -109
  99. eventsourcing/tests/application_tests/test_repository.py +0 -504
  100. eventsourcing/tests/application_tests/test_snapshotting.py +0 -68
  101. eventsourcing/tests/application_tests/test_upcasting.py +0 -459
  102. eventsourcing/tests/docs_tests/__init__.py +0 -0
  103. eventsourcing/tests/docs_tests/test_docs.py +0 -293
  104. eventsourcing/tests/domain_tests/__init__.py +0 -0
  105. eventsourcing/tests/domain_tests/test_aggregate.py +0 -1200
  106. eventsourcing/tests/domain_tests/test_aggregate_decorators.py +0 -1604
  107. eventsourcing/tests/domain_tests/test_domainevent.py +0 -80
  108. eventsourcing/tests/interface_tests/__init__.py +0 -0
  109. eventsourcing/tests/interface_tests/test_remotenotificationlog.py +0 -258
  110. eventsourcing/tests/persistence_tests/__init__.py +0 -0
  111. eventsourcing/tests/persistence_tests/test_aes.py +0 -93
  112. eventsourcing/tests/persistence_tests/test_connection_pool.py +0 -722
  113. eventsourcing/tests/persistence_tests/test_eventstore.py +0 -72
  114. eventsourcing/tests/persistence_tests/test_infrastructure_factory.py +0 -21
  115. eventsourcing/tests/persistence_tests/test_mapper.py +0 -113
  116. eventsourcing/tests/persistence_tests/test_noninterleaving_notification_ids.py +0 -69
  117. eventsourcing/tests/persistence_tests/test_popo.py +0 -124
  118. eventsourcing/tests/persistence_tests/test_postgres.py +0 -1120
  119. eventsourcing/tests/persistence_tests/test_sqlite.py +0 -348
  120. eventsourcing/tests/persistence_tests/test_transcoder.py +0 -44
  121. eventsourcing/tests/system_tests/__init__.py +0 -0
  122. eventsourcing/tests/system_tests/test_runner.py +0 -935
  123. eventsourcing/tests/system_tests/test_system.py +0 -284
  124. eventsourcing/tests/utils_tests/__init__.py +0 -0
  125. eventsourcing/tests/utils_tests/test_utils.py +0 -226
  126. eventsourcing-9.3.3.dist-info/RECORD +0 -145
  127. {eventsourcing-9.3.3.dist-info → eventsourcing-9.3.5.dist-info}/AUTHORS +0 -0
  128. {eventsourcing-9.3.3.dist-info → eventsourcing-9.3.5.dist-info}/LICENSE +0 -0
  129. {eventsourcing-9.3.3.dist-info → eventsourcing-9.3.5.dist-info}/WHEEL +0 -0
@@ -1,459 +0,0 @@
1
- from __future__ import annotations
2
-
3
- import os
4
- from decimal import Decimal
5
- from unittest import TestCase
6
- from uuid import uuid4
7
-
8
- from eventsourcing.application import Application
9
- from eventsourcing.domain import Aggregate, AggregateEvent
10
- from eventsourcing.utils import _topic_cache, get_topic
11
-
12
-
13
- class TestUpcasting(TestCase):
14
- def setUp(self) -> None:
15
- os.environ["IS_SNAPSHOTTING_ENABLED"] = "y"
16
-
17
- def tearDown(self) -> None:
18
- del os.environ["IS_SNAPSHOTTING_ENABLED"]
19
- type(self).UpcastFixtureV1 = type(self).original_cls_v1
20
- type(self).UpcastFixtureV2 = type(self).original_cls_v2
21
- type(self).UpcastFixtureV3 = type(self).original_cls_v3
22
-
23
- topic_v1 = get_topic(self.UpcastFixtureV1)
24
- topic_v1_created = get_topic(self.UpcastFixtureV1.Created)
25
-
26
- if topic_v1 in _topic_cache:
27
- del _topic_cache[topic_v1]
28
- if topic_v1_created in _topic_cache:
29
- del _topic_cache[topic_v1_created]
30
-
31
- topic_v2 = get_topic(self.UpcastFixtureV2)
32
- topic_v2_created = get_topic(self.UpcastFixtureV2.Created)
33
-
34
- if topic_v2 in _topic_cache:
35
- del _topic_cache[topic_v2]
36
- if topic_v2_created in _topic_cache:
37
- del _topic_cache[topic_v2_created]
38
-
39
- topic_v3 = get_topic(self.UpcastFixtureV3)
40
- topic_v3_created = get_topic(self.UpcastFixtureV3.Created)
41
-
42
- if topic_v3 in _topic_cache:
43
- del _topic_cache[topic_v3]
44
- if topic_v3_created in _topic_cache:
45
- del _topic_cache[topic_v3_created]
46
-
47
- def test_upcast_created_event_from_v1(self):
48
- app = Application()
49
-
50
- topic_v1 = get_topic(self.UpcastFixtureV1)
51
- topic_v1_created = get_topic(self.UpcastFixtureV1.Created)
52
-
53
- aggregate = self.UpcastFixtureV1.create(a="text")
54
- app.save(aggregate)
55
- copy = app.repository.get(aggregate.id)
56
- self.assertEqual(copy.a, "text")
57
- self.assertFalse(hasattr(copy, "b"))
58
- self.assertFalse(hasattr(copy, "c"))
59
- self.assertFalse(hasattr(copy, "d"))
60
-
61
- # "Deploy" v2.
62
- del _topic_cache[topic_v1]
63
- del _topic_cache[topic_v1_created]
64
- type(self).UpcastFixtureV1 = self.UpcastFixtureV2
65
-
66
- copy = app.repository.get(aggregate.id)
67
- self.assertFalse(hasattr(copy, "a"))
68
- self.assertEqual(copy.aa, "TEXT")
69
- self.assertEqual(copy.b, 0)
70
- self.assertFalse(hasattr(copy, "c"))
71
- self.assertFalse(hasattr(copy, "d"))
72
-
73
- # "Deploy" v3.
74
- del _topic_cache[topic_v1]
75
- del _topic_cache[topic_v1_created]
76
- type(self).UpcastFixtureV1 = self.UpcastFixtureV3
77
-
78
- copy = app.repository.get(aggregate.id)
79
- self.assertFalse(hasattr(copy, "a"))
80
- self.assertEqual(copy.aa, "TEXT")
81
- self.assertEqual(copy.b, 0)
82
- self.assertEqual(copy.c, [])
83
-
84
- # "Deploy" v4.
85
- del _topic_cache[topic_v1]
86
- type(self).UpcastFixtureV1 = self.UpcastFixtureV4
87
-
88
- copy = app.repository.get(aggregate.id)
89
- self.assertFalse(hasattr(copy, "a"))
90
- self.assertEqual(copy.aa, "TEXT")
91
- self.assertEqual(copy.b, 0)
92
- self.assertEqual(copy.c, [])
93
- self.assertEqual(copy.d, None)
94
-
95
- def test_upcast_aggregate_snapshot_from_v1(self):
96
- app = Application()
97
-
98
- topic_v1 = get_topic(self.UpcastFixtureV1)
99
-
100
- aggregate = self.UpcastFixtureV1.create(a="text")
101
- app.save(aggregate)
102
- copy = app.repository.get(aggregate.id)
103
- self.assertEqual(copy.a, "text")
104
- self.assertFalse(hasattr(copy, "b"))
105
- self.assertFalse(hasattr(copy, "c"))
106
- self.assertFalse(hasattr(copy, "d"))
107
-
108
- app.take_snapshot(aggregate.id)
109
-
110
- # "Deploy" v2.
111
- del _topic_cache[topic_v1]
112
- type(self).UpcastFixtureV1 = self.UpcastFixtureV2
113
-
114
- copy = app.repository.get(aggregate.id)
115
- self.assertEqual(copy.aa, "TEXT")
116
- self.assertEqual(copy.b, 0)
117
- self.assertFalse(hasattr(copy, "c"))
118
- self.assertFalse(hasattr(copy, "d"))
119
-
120
- # "Deploy" v3.
121
- del _topic_cache[topic_v1]
122
- type(self).UpcastFixtureV1 = self.UpcastFixtureV3
123
-
124
- copy = app.repository.get(aggregate.id)
125
- self.assertFalse(hasattr(copy, "a"))
126
- self.assertEqual(copy.aa, "TEXT")
127
- self.assertEqual(copy.b, 0)
128
- self.assertEqual(copy.c, [])
129
- self.assertFalse(hasattr(copy, "d"))
130
-
131
- # "Deploy" v4.
132
- del _topic_cache[topic_v1]
133
- type(self).UpcastFixtureV1 = self.UpcastFixtureV4
134
-
135
- copy = app.repository.get(aggregate.id)
136
- self.assertFalse(hasattr(copy, "a"))
137
- self.assertEqual(copy.aa, "TEXT")
138
- self.assertEqual(copy.b, 0)
139
- self.assertEqual(copy.c, [])
140
- self.assertEqual(copy.d, None)
141
-
142
- def test_upcast_created_event_from_v2(self):
143
- app = Application()
144
-
145
- topic_v2 = get_topic(self.UpcastFixtureV2)
146
- topic_v2_created = get_topic(self.UpcastFixtureV2.Created)
147
-
148
- aggregate = self.UpcastFixtureV2.create(aa="TEXT", b=1)
149
- app.save(aggregate)
150
- copy = app.repository.get(aggregate.id)
151
- self.assertFalse(hasattr(copy, "a"))
152
- self.assertEqual(copy.aa, "TEXT")
153
- self.assertEqual(copy.b, 1)
154
- self.assertFalse(hasattr(copy, "c"))
155
- self.assertFalse(hasattr(copy, "d"))
156
-
157
- # "Deploy" v3.
158
- del _topic_cache[topic_v2]
159
- del _topic_cache[topic_v2_created]
160
- type(self).UpcastFixtureV2 = self.UpcastFixtureV3
161
-
162
- copy = app.repository.get(aggregate.id)
163
- self.assertFalse(hasattr(copy, "a"))
164
- self.assertEqual(copy.aa, "TEXT")
165
- self.assertEqual(copy.b, 1)
166
- self.assertEqual(copy.c, [])
167
- self.assertFalse(hasattr(copy, "d"))
168
-
169
- # "Deploy" v4.
170
- del _topic_cache[topic_v2]
171
- del _topic_cache[topic_v2_created]
172
- type(self).UpcastFixtureV2 = self.UpcastFixtureV4
173
-
174
- copy = app.repository.get(aggregate.id)
175
- self.assertFalse(hasattr(copy, "a"))
176
- self.assertEqual(copy.aa, "TEXT")
177
- self.assertEqual(copy.b, 1)
178
- self.assertEqual(copy.c, [])
179
- self.assertEqual(copy.d, None)
180
-
181
- def test_upcast_aggregate_snapshot_from_v2(self):
182
- app = Application()
183
-
184
- topic_v2 = get_topic(self.UpcastFixtureV2)
185
-
186
- aggregate = self.UpcastFixtureV2.create(aa="TEXT", b=1)
187
- app.save(aggregate)
188
- copy = app.repository.get(aggregate.id)
189
- self.assertFalse(hasattr(copy, "a"))
190
- self.assertEqual(copy.aa, "TEXT")
191
- self.assertEqual(copy.b, 1)
192
- self.assertFalse(hasattr(copy, "c"))
193
- self.assertFalse(hasattr(copy, "d"))
194
-
195
- app.take_snapshot(aggregate.id)
196
-
197
- # "Deploy" v3.
198
- del _topic_cache[topic_v2]
199
- type(self).UpcastFixtureV2 = self.UpcastFixtureV3
200
-
201
- copy = app.repository.get(aggregate.id)
202
- self.assertFalse(hasattr(copy, "a"))
203
- self.assertEqual(copy.aa, "TEXT")
204
- self.assertEqual(copy.b, 1)
205
- self.assertEqual(copy.c, [])
206
- self.assertFalse(hasattr(copy, "d"))
207
-
208
- # "Deploy" v4.
209
- del _topic_cache[topic_v2]
210
- type(self).UpcastFixtureV2 = self.UpcastFixtureV4
211
-
212
- copy = app.repository.get(aggregate.id)
213
- self.assertFalse(hasattr(copy, "a"))
214
- self.assertEqual(copy.aa, "TEXT")
215
- self.assertEqual(copy.b, 1)
216
- self.assertEqual(copy.c, [])
217
- self.assertEqual(copy.d, None)
218
-
219
- def test_upcast_created_event_from_v3(self):
220
- app = Application()
221
-
222
- topic_v3 = get_topic(self.UpcastFixtureV3)
223
- topic_v3_created = get_topic(self.UpcastFixtureV3.Created)
224
-
225
- aggregate = self.UpcastFixtureV3.create(aa="TEXT", b=1, c=[1, 2])
226
- app.save(aggregate)
227
- copy = app.repository.get(aggregate.id)
228
- self.assertFalse(hasattr(copy, "a"))
229
- self.assertEqual(copy.aa, "TEXT")
230
- self.assertEqual(copy.b, 1)
231
- self.assertEqual(copy.c, [1, 2])
232
- self.assertFalse(hasattr(copy, "d"))
233
-
234
- # "Deploy" v3.
235
- del _topic_cache[topic_v3]
236
- del _topic_cache[topic_v3_created]
237
- type(self).UpcastFixtureV3 = self.UpcastFixtureV4
238
-
239
- copy = app.repository.get(aggregate.id)
240
- self.assertFalse(hasattr(copy, "a"))
241
- self.assertEqual(copy.aa, "TEXT")
242
- self.assertEqual(copy.b, 1)
243
- self.assertEqual(copy.c, [1, 2])
244
- self.assertEqual(copy.d, None)
245
-
246
- copy.set_d(value=Decimal("10.0"))
247
- app.save(copy)
248
-
249
- copy = app.repository.get(aggregate.id)
250
- self.assertFalse(hasattr(copy, "a"))
251
- self.assertEqual(copy.aa, "TEXT")
252
- self.assertEqual(copy.b, 1)
253
- self.assertEqual(copy.c, [1, 2])
254
- self.assertEqual(copy.d, 10)
255
-
256
- def test_upcast_aggregate_snapshot_from_v3(self):
257
- app = Application()
258
-
259
- topic_v3 = get_topic(self.UpcastFixtureV3)
260
-
261
- aggregate = self.UpcastFixtureV3.create(aa="TEXT", b=1, c=[1, 2])
262
- app.save(aggregate)
263
- copy = app.repository.get(aggregate.id)
264
- self.assertFalse(hasattr(copy, "a"))
265
- self.assertEqual(copy.aa, "TEXT")
266
- self.assertEqual(copy.b, 1)
267
- self.assertEqual(copy.c, [1, 2])
268
- self.assertFalse(hasattr(copy, "d"))
269
-
270
- app.take_snapshot(aggregate.id)
271
-
272
- # "Deploy" v3.
273
- del _topic_cache[topic_v3]
274
- type(self).UpcastFixtureV3 = self.UpcastFixtureV4
275
-
276
- copy = app.repository.get(aggregate.id)
277
- self.assertFalse(hasattr(copy, "a"))
278
- self.assertEqual(copy.aa, "TEXT")
279
- self.assertEqual(copy.b, 1)
280
- self.assertEqual(copy.c, [1, 2])
281
- self.assertEqual(copy.d, None)
282
-
283
- copy.set_d(value=Decimal("10.0"))
284
- app.save(copy)
285
-
286
- copy = app.repository.get(aggregate.id)
287
- self.assertFalse(hasattr(copy, "a"))
288
- self.assertEqual(copy.aa, "TEXT")
289
- self.assertEqual(copy.b, 1)
290
- self.assertEqual(copy.c, [1, 2])
291
- self.assertEqual(copy.d, 10)
292
-
293
- app.take_snapshot(aggregate.id)
294
-
295
- copy = app.repository.get(aggregate.id)
296
- self.assertFalse(hasattr(copy, "a"))
297
- self.assertEqual(copy.aa, "TEXT")
298
- self.assertEqual(copy.b, 1)
299
- self.assertEqual(copy.c, [1, 2])
300
- self.assertEqual(copy.d, 10)
301
-
302
- def test_upcast_created_event_from_v4(self):
303
- app = Application()
304
-
305
- aggregate = self.UpcastFixtureV4.create(aa="TEXT", b=1, c=[1, 2])
306
- app.save(aggregate)
307
- copy = app.repository.get(aggregate.id)
308
- self.assertFalse(hasattr(copy, "a"))
309
- self.assertEqual(copy.aa, "TEXT")
310
- self.assertEqual(copy.b, 1)
311
- self.assertEqual(copy.c, [1, 2])
312
- self.assertEqual(copy.d, None)
313
-
314
- def test_upcast_aggregate_snapshot_from_v4(self):
315
- app = Application()
316
-
317
- aggregate = self.UpcastFixtureV4.create(aa="TEXT", b=1, c=[1, 2])
318
- app.save(aggregate)
319
-
320
- app.take_snapshot(aggregate.id)
321
-
322
- copy = app.repository.get(aggregate.id)
323
- self.assertFalse(hasattr(copy, "a"))
324
- self.assertEqual(copy.aa, "TEXT")
325
- self.assertEqual(copy.b, 1)
326
- self.assertEqual(copy.c, [1, 2])
327
- self.assertEqual(copy.d, None)
328
-
329
- class UpcastFixtureV1(Aggregate):
330
- def __init__(self, a):
331
- self.a = a
332
-
333
- @classmethod
334
- def create(cls, *, a):
335
- return cls._create(cls.Created, id=uuid4(), a=a)
336
-
337
- class Created(Aggregate.Created):
338
- a: str
339
-
340
- original_cls_v1 = UpcastFixtureV1
341
-
342
- class UpcastFixtureV2(Aggregate):
343
- def __init__(self, aa, b):
344
- self.aa = aa
345
- self.b = b
346
-
347
- @classmethod
348
- def create(cls, *, aa, b):
349
- return cls._create(cls.Created, id=uuid4(), aa=aa, b=b)
350
-
351
- class Created(Aggregate.Created):
352
- aa: str
353
- b: str
354
-
355
- class_version = 2
356
-
357
- @staticmethod
358
- def upcast_v1_v2(state):
359
- state["aa"] = state.pop("a").upper()
360
- state["b"] = 0
361
-
362
- class_version = 2
363
-
364
- @staticmethod
365
- def upcast_v1_v2(state):
366
- state["aa"] = state.pop("a").upper()
367
- state["b"] = 0
368
-
369
- original_cls_v2 = UpcastFixtureV2
370
-
371
- class UpcastFixtureV3(Aggregate):
372
- def __init__(self, aa, b, c):
373
- self.aa = aa
374
- self.b = b
375
- self.c = c
376
-
377
- @classmethod
378
- def create(cls, *, aa, b, c):
379
- return cls._create(cls.Created, id=uuid4(), aa=aa, b=b, c=c)
380
-
381
- class Created(Aggregate.Created):
382
- aa: str
383
- b: int
384
- c: list
385
-
386
- class_version = 3
387
-
388
- @staticmethod
389
- def upcast_v1_v2(state):
390
- state["aa"] = state.pop("a").upper()
391
- state["b"] = 0
392
-
393
- @staticmethod
394
- def upcast_v2_v3(state):
395
- state["c"] = []
396
-
397
- class_version = 3
398
-
399
- @staticmethod
400
- def upcast_v1_v2(state):
401
- state["aa"] = state.pop("a").upper()
402
- state["b"] = 0
403
-
404
- @staticmethod
405
- def upcast_v2_v3(state):
406
- state["c"] = []
407
-
408
- original_cls_v3 = UpcastFixtureV3
409
-
410
- class UpcastFixtureV4(Aggregate):
411
- def __init__(self, aa, b, c):
412
- self.aa = aa
413
- self.b = b
414
- self.c = c
415
- self.d: Decimal | None = None
416
-
417
- @classmethod
418
- def create(cls, *, aa, b, c):
419
- return cls._create(cls.Created, id=uuid4(), aa=aa, b=b, c=c)
420
-
421
- class Created(Aggregate.Created):
422
- aa: str
423
- b: int
424
- c: list
425
-
426
- class_version = 3
427
-
428
- @staticmethod
429
- def upcast_v1_v2(state):
430
- state["aa"] = state.pop("a").upper()
431
- state["b"] = 0
432
-
433
- @staticmethod
434
- def upcast_v2_v3(state):
435
- state["c"] = []
436
-
437
- def set_d(self, value: Decimal):
438
- self.trigger_event(self.DUpdated, d=value)
439
-
440
- class DUpdated(AggregateEvent):
441
- d: Decimal
442
-
443
- def apply(self, aggregate: Aggregate) -> None:
444
- aggregate.d = self.d
445
-
446
- class_version = 4
447
-
448
- @staticmethod
449
- def upcast_v1_v2(state):
450
- state["aa"] = state.pop("a").upper()
451
- state["b"] = 0
452
-
453
- @staticmethod
454
- def upcast_v2_v3(state):
455
- state["c"] = []
456
-
457
- @staticmethod
458
- def upcast_v3_v4(state):
459
- state["d"] = None
File without changes