eventsourcing 9.3.2__py3-none-any.whl → 9.3.4__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.
- eventsourcing/postgres.py +2 -1
- eventsourcing/system.py +3 -1
- {eventsourcing-9.3.2.dist-info → eventsourcing-9.3.4.dist-info}/METADATA +3 -8
- eventsourcing-9.3.4.dist-info/RECORD +24 -0
- eventsourcing/examples/__init__.py +0 -0
- eventsourcing/examples/aggregate1/__init__.py +0 -0
- eventsourcing/examples/aggregate1/application.py +0 -27
- eventsourcing/examples/aggregate1/domainmodel.py +0 -16
- eventsourcing/examples/aggregate1/test_application.py +0 -37
- eventsourcing/examples/aggregate2/__init__.py +0 -0
- eventsourcing/examples/aggregate2/application.py +0 -27
- eventsourcing/examples/aggregate2/domainmodel.py +0 -22
- eventsourcing/examples/aggregate2/test_application.py +0 -37
- eventsourcing/examples/aggregate3/__init__.py +0 -0
- eventsourcing/examples/aggregate3/application.py +0 -27
- eventsourcing/examples/aggregate3/domainmodel.py +0 -38
- eventsourcing/examples/aggregate3/test_application.py +0 -37
- eventsourcing/examples/aggregate4/__init__.py +0 -0
- eventsourcing/examples/aggregate4/application.py +0 -27
- eventsourcing/examples/aggregate4/domainmodel.py +0 -114
- eventsourcing/examples/aggregate4/test_application.py +0 -38
- eventsourcing/examples/aggregate5/__init__.py +0 -0
- eventsourcing/examples/aggregate5/application.py +0 -27
- eventsourcing/examples/aggregate5/domainmodel.py +0 -131
- eventsourcing/examples/aggregate5/test_application.py +0 -38
- eventsourcing/examples/aggregate6/__init__.py +0 -0
- eventsourcing/examples/aggregate6/application.py +0 -30
- eventsourcing/examples/aggregate6/domainmodel.py +0 -123
- eventsourcing/examples/aggregate6/test_application.py +0 -38
- eventsourcing/examples/aggregate6a/__init__.py +0 -0
- eventsourcing/examples/aggregate6a/application.py +0 -40
- eventsourcing/examples/aggregate6a/domainmodel.py +0 -149
- eventsourcing/examples/aggregate6a/test_application.py +0 -45
- eventsourcing/examples/aggregate7/__init__.py +0 -0
- eventsourcing/examples/aggregate7/application.py +0 -48
- eventsourcing/examples/aggregate7/domainmodel.py +0 -144
- eventsourcing/examples/aggregate7/persistence.py +0 -57
- eventsourcing/examples/aggregate7/test_application.py +0 -38
- eventsourcing/examples/aggregate7/test_compression_and_encryption.py +0 -45
- eventsourcing/examples/aggregate7/test_snapshotting_intervals.py +0 -67
- eventsourcing/examples/aggregate7a/__init__.py +0 -0
- eventsourcing/examples/aggregate7a/application.py +0 -56
- eventsourcing/examples/aggregate7a/domainmodel.py +0 -170
- eventsourcing/examples/aggregate7a/test_application.py +0 -46
- eventsourcing/examples/aggregate7a/test_compression_and_encryption.py +0 -45
- eventsourcing/examples/aggregate8/__init__.py +0 -0
- eventsourcing/examples/aggregate8/application.py +0 -47
- eventsourcing/examples/aggregate8/domainmodel.py +0 -65
- eventsourcing/examples/aggregate8/persistence.py +0 -57
- eventsourcing/examples/aggregate8/test_application.py +0 -37
- eventsourcing/examples/aggregate8/test_compression_and_encryption.py +0 -44
- eventsourcing/examples/aggregate8/test_snapshotting_intervals.py +0 -38
- eventsourcing/examples/bankaccounts/__init__.py +0 -0
- eventsourcing/examples/bankaccounts/application.py +0 -70
- eventsourcing/examples/bankaccounts/domainmodel.py +0 -56
- eventsourcing/examples/bankaccounts/test.py +0 -173
- eventsourcing/examples/cargoshipping/__init__.py +0 -0
- eventsourcing/examples/cargoshipping/application.py +0 -126
- eventsourcing/examples/cargoshipping/domainmodel.py +0 -330
- eventsourcing/examples/cargoshipping/interface.py +0 -143
- eventsourcing/examples/cargoshipping/test.py +0 -231
- eventsourcing/examples/contentmanagement/__init__.py +0 -0
- eventsourcing/examples/contentmanagement/application.py +0 -118
- eventsourcing/examples/contentmanagement/domainmodel.py +0 -69
- eventsourcing/examples/contentmanagement/test.py +0 -180
- eventsourcing/examples/contentmanagement/utils.py +0 -26
- eventsourcing/examples/contentmanagementsystem/__init__.py +0 -0
- eventsourcing/examples/contentmanagementsystem/application.py +0 -54
- eventsourcing/examples/contentmanagementsystem/postgres.py +0 -17
- eventsourcing/examples/contentmanagementsystem/sqlite.py +0 -17
- eventsourcing/examples/contentmanagementsystem/system.py +0 -14
- eventsourcing/examples/contentmanagementsystem/test_system.py +0 -180
- eventsourcing/examples/searchablecontent/__init__.py +0 -0
- eventsourcing/examples/searchablecontent/application.py +0 -45
- eventsourcing/examples/searchablecontent/persistence.py +0 -23
- eventsourcing/examples/searchablecontent/postgres.py +0 -118
- eventsourcing/examples/searchablecontent/sqlite.py +0 -136
- eventsourcing/examples/searchablecontent/test_application.py +0 -110
- eventsourcing/examples/searchablecontent/test_recorder.py +0 -68
- eventsourcing/examples/searchabletimestamps/__init__.py +0 -0
- eventsourcing/examples/searchabletimestamps/application.py +0 -32
- eventsourcing/examples/searchabletimestamps/persistence.py +0 -20
- eventsourcing/examples/searchabletimestamps/postgres.py +0 -110
- eventsourcing/examples/searchabletimestamps/sqlite.py +0 -99
- eventsourcing/examples/searchabletimestamps/test_searchabletimestamps.py +0 -94
- eventsourcing/examples/test_invoice.py +0 -176
- eventsourcing/examples/test_parking_lot.py +0 -206
- eventsourcing/tests/application_tests/__init__.py +0 -0
- eventsourcing/tests/application_tests/test_application_with_automatic_snapshotting.py +0 -55
- eventsourcing/tests/application_tests/test_application_with_popo.py +0 -22
- eventsourcing/tests/application_tests/test_application_with_postgres.py +0 -75
- eventsourcing/tests/application_tests/test_application_with_sqlite.py +0 -72
- eventsourcing/tests/application_tests/test_cache.py +0 -134
- eventsourcing/tests/application_tests/test_event_sourced_log.py +0 -162
- eventsourcing/tests/application_tests/test_notificationlog.py +0 -232
- eventsourcing/tests/application_tests/test_notificationlogreader.py +0 -126
- eventsourcing/tests/application_tests/test_processapplication.py +0 -110
- eventsourcing/tests/application_tests/test_processingpolicy.py +0 -109
- eventsourcing/tests/application_tests/test_repository.py +0 -504
- eventsourcing/tests/application_tests/test_snapshotting.py +0 -68
- eventsourcing/tests/application_tests/test_upcasting.py +0 -459
- eventsourcing/tests/docs_tests/__init__.py +0 -0
- eventsourcing/tests/docs_tests/test_docs.py +0 -293
- eventsourcing/tests/domain_tests/__init__.py +0 -0
- eventsourcing/tests/domain_tests/test_aggregate.py +0 -1200
- eventsourcing/tests/domain_tests/test_aggregate_decorators.py +0 -1604
- eventsourcing/tests/domain_tests/test_domainevent.py +0 -80
- eventsourcing/tests/interface_tests/__init__.py +0 -0
- eventsourcing/tests/interface_tests/test_remotenotificationlog.py +0 -258
- eventsourcing/tests/persistence_tests/__init__.py +0 -0
- eventsourcing/tests/persistence_tests/test_aes.py +0 -93
- eventsourcing/tests/persistence_tests/test_connection_pool.py +0 -722
- eventsourcing/tests/persistence_tests/test_eventstore.py +0 -72
- eventsourcing/tests/persistence_tests/test_infrastructure_factory.py +0 -21
- eventsourcing/tests/persistence_tests/test_mapper.py +0 -113
- eventsourcing/tests/persistence_tests/test_noninterleaving_notification_ids.py +0 -69
- eventsourcing/tests/persistence_tests/test_popo.py +0 -124
- eventsourcing/tests/persistence_tests/test_postgres.py +0 -1119
- eventsourcing/tests/persistence_tests/test_sqlite.py +0 -348
- eventsourcing/tests/persistence_tests/test_transcoder.py +0 -44
- eventsourcing/tests/system_tests/__init__.py +0 -0
- eventsourcing/tests/system_tests/test_runner.py +0 -935
- eventsourcing/tests/system_tests/test_system.py +0 -284
- eventsourcing/tests/utils_tests/__init__.py +0 -0
- eventsourcing/tests/utils_tests/test_utils.py +0 -226
- eventsourcing-9.3.2.dist-info/RECORD +0 -145
- {eventsourcing-9.3.2.dist-info → eventsourcing-9.3.4.dist-info}/AUTHORS +0 -0
- {eventsourcing-9.3.2.dist-info → eventsourcing-9.3.4.dist-info}/LICENSE +0 -0
- {eventsourcing-9.3.2.dist-info → eventsourcing-9.3.4.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
|