Skip to content

Commit 2fbcf29

Browse files
committed
feat: change lower_bound_id and upper_bound_id to lower_bound and upper_bound
1 parent f33c7fe commit 2fbcf29

File tree

5 files changed

+36
-36
lines changed

5 files changed

+36
-36
lines changed

eventsourcingdb_client_python/handlers/observe_events/observe_events_options.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@
1010
@dataclass
1111
class ObserveEventsOptions:
1212
recursive: bool
13-
lower_bound_id: str | None = None
13+
lower_bound: str | None = None
1414
from_latest_event: ObserveFromLatestEvent | None = None
1515

1616
def validate(self) -> None:
17-
if self.lower_bound_id is not None and not is_non_negative_integer(self.lower_bound_id):
17+
if self.lower_bound is not None and not is_non_negative_integer(self.lower_bound):
1818
raise ValidationError(
19-
'ReadEventOptions are invalid: lower_bound_id must be 0 or greater.'
19+
'ReadEventOptions are invalid: lower_bound must be 0 or greater.'
2020
)
2121

2222
if self.from_latest_event is not None:
23-
if self.lower_bound_id is not None:
23+
if self.lower_bound is not None:
2424
raise ValidationError(
2525
'ReadEventsOptions are invalid: '
2626
'lowerBoundId and fromLatestEvent are mutually exclusive'
@@ -47,8 +47,8 @@ def to_json(self):
4747
'recursive': self.recursive
4848
}
4949

50-
if self.lower_bound_id is not None:
51-
json['lowerBoundId'] = self.lower_bound_id
50+
if self.lower_bound is not None:
51+
json['lowerBoundId'] = self.lower_bound
5252
if self.from_latest_event is not None:
5353
json['fromLatestEvent'] = self.from_latest_event.to_json()
5454

eventsourcingdb_client_python/handlers/read_events/read_events.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ async def read_events(
7070
raise ServerError(f'{message["payload"]["error"]}.')
7171

7272
if is_event(message):
73-
event = Event.parse(message['payload']['event'])
73+
event = Event.parse(message['payload'])
7474

7575
yield StoreItem(event, message['payload']['hash']) # type: ignore
7676
continue

eventsourcingdb_client_python/handlers/read_events/read_events_options.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,22 @@
1212
class ReadEventsOptions:
1313
recursive: bool
1414
order: Order | None = None
15-
lower_bound_id: str | None = None
16-
upper_bound_id: str | None = None
15+
lower_bound: str | None = None
16+
upper_bound: str | None = None
1717
from_latest_event: ReadFromLatestEvent | None = None
1818

1919
def validate(self) -> None:
20-
if self.lower_bound_id is not None and not is_non_negative_integer(self.lower_bound_id):
20+
if self.lower_bound is not None and not is_non_negative_integer(self.lower_bound):
2121
raise ValidationError(
22-
'ReadEventOptions are invalid: lower_bound_id must be 0 or greater.'
22+
'ReadEventOptions are invalid: lower_bound must be 0 or greater.'
2323
)
24-
if self.upper_bound_id is not None and not is_non_negative_integer(self.upper_bound_id):
24+
if self.upper_bound is not None and not is_non_negative_integer(self.upper_bound):
2525
raise ValidationError(
26-
'ReadEventOptions are invalid: upper_bound_id must be 0 or greater.'
26+
'ReadEventOptions are invalid: upper_bound must be 0 or greater.'
2727
)
2828

2929
if self.from_latest_event is not None:
30-
if self.lower_bound_id is not None:
30+
if self.lower_bound is not None:
3131
raise ValidationError(
3232
'ReadEventsOptions are invalid: '
3333
'lowerBoundId and fromLatestEvent are mutually exclusive'
@@ -56,10 +56,10 @@ def to_json(self):
5656

5757
if self.order is not None:
5858
json['order'] = self.order.value
59-
if self.lower_bound_id is not None:
60-
json['lowerBoundId'] = self.lower_bound_id
61-
if self.upper_bound_id is not None:
62-
json['upperBoundId'] = self.upper_bound_id
59+
if self.lower_bound is not None:
60+
json['lowerBound'] = self.lower_bound
61+
if self.upper_bound is not None:
62+
json['upperBound'] = self.upper_bound
6363
if self.from_latest_event is not None:
6464
json['fromLatestEvent'] = self.from_latest_event.to_json()
6565

tests/test_observe_events.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ async def test_observes_event_starting_from_given_event_name(
251251

252252
@staticmethod
253253
@pytest.mark.asyncio
254-
async def test_observes_event_starting_from_given_lower_bound_id(
254+
async def test_observes_event_starting_from_given_lower_bound(
255255
prepared_database: Database,
256256
test_data: TestData
257257
):
@@ -263,7 +263,7 @@ async def test_observes_event_starting_from_given_lower_bound_id(
263263
'/users',
264264
ObserveEventsOptions(
265265
recursive=True,
266-
lower_bound_id='2'
266+
lower_bound='2'
267267
)
268268
):
269269
observed_items.append(event)
@@ -322,7 +322,7 @@ async def test_throws_error_for_mutually_exclusive_options(
322322
'/users',
323323
ObserveEventsOptions(
324324
recursive=True,
325-
lower_bound_id='3',
325+
lower_bound='3',
326326
from_latest_event=ObserveFromLatestEvent(
327327
subject='/',
328328
type='com.foo.bar',
@@ -344,7 +344,7 @@ async def test_throws_error_for_non_integer_lower_bound(
344344
'/users',
345345
ObserveEventsOptions(
346346
recursive=True,
347-
lower_bound_id='hello',
347+
lower_bound='hello',
348348
)
349349
):
350350
pass
@@ -361,7 +361,7 @@ async def test_throws_error_for_negative_lower_bound(
361361
'/users',
362362
ObserveEventsOptions(
363363
recursive=True,
364-
lower_bound_id='-1',
364+
lower_bound='-1',
365365
)
366366
):
367367
pass

tests/test_read_events.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ async def test_read_events_recursive_from_latest_event_in_child_subject(
216216

217217
@staticmethod
218218
@pytest.mark.asyncio
219-
async def test_read_events_starting_from_lower_bound_id(
219+
async def test_read_events_starting_from_lower_bound(
220220
prepared_database: Database,
221221
test_data: TestData
222222
):
@@ -227,7 +227,7 @@ async def test_read_events_starting_from_lower_bound_id(
227227
'/users',
228228
ReadEventsOptions(
229229
recursive=True,
230-
lower_bound_id='2'
230+
lower_bound='2'
231231
)
232232
):
233233
result.append(event)
@@ -255,7 +255,7 @@ async def test_read_events_starting_from_lower_bound_id(
255255

256256
@staticmethod
257257
@pytest.mark.asyncio
258-
async def test_read_events_up_to_the_upper_bound_id(
258+
async def test_read_events_up_to_the_upper_bound(
259259
prepared_database: Database,
260260
test_data: TestData
261261
):
@@ -266,7 +266,7 @@ async def test_read_events_up_to_the_upper_bound_id(
266266
'/users',
267267
ReadEventsOptions(
268268
recursive=True,
269-
upper_bound_id='1'
269+
upper_bound='1'
270270
)
271271
):
272272
result.append(event)
@@ -309,7 +309,7 @@ async def test_throws_error_for_exclusive_options(
309309
type='com.foo.bar',
310310
if_event_is_missing=IfEventIsMissingDuringRead.READ_EVERYTHING
311311
),
312-
lower_bound_id='0'
312+
lower_bound='0'
313313
)
314314
):
315315
pass
@@ -332,7 +332,7 @@ async def test_throws_error_for_invalid_subject(
332332

333333
@staticmethod
334334
@pytest.mark.asyncio
335-
async def test_throws_error_for_invalid_lower_bound_id(
335+
async def test_throws_error_for_invalid_lower_bound(
336336
prepared_database: Database
337337
):
338338
client = prepared_database.with_authorization.client
@@ -342,14 +342,14 @@ async def test_throws_error_for_invalid_lower_bound_id(
342342
'/',
343343
ReadEventsOptions(
344344
recursive=True,
345-
lower_bound_id='hello'
345+
lower_bound='hello'
346346
)
347347
):
348348
pass
349349

350350
@staticmethod
351351
@pytest.mark.asyncio
352-
async def test_throws_error_for_negative_lower_bound_id(
352+
async def test_throws_error_for_negative_lower_bound(
353353
prepared_database: Database
354354
):
355355
client = prepared_database.with_authorization.client
@@ -359,14 +359,14 @@ async def test_throws_error_for_negative_lower_bound_id(
359359
'/',
360360
ReadEventsOptions(
361361
recursive=True,
362-
lower_bound_id='-1'
362+
lower_bound='-1'
363363
)
364364
):
365365
pass
366366

367367
@staticmethod
368368
@pytest.mark.asyncio
369-
async def test_throws_error_for_invalid_upper_bound_id(
369+
async def test_throws_error_for_invalid_upper_bound(
370370
prepared_database: Database
371371
):
372372
client = prepared_database.with_authorization.client
@@ -376,14 +376,14 @@ async def test_throws_error_for_invalid_upper_bound_id(
376376
'/',
377377
ReadEventsOptions(
378378
recursive=True,
379-
upper_bound_id='hello'
379+
upper_bound='hello'
380380
)
381381
):
382382
pass
383383

384384
@staticmethod
385385
@pytest.mark.asyncio
386-
async def test_throws_error_for_negative_upper_bound_id(
386+
async def test_throws_error_for_negative_upper_bound(
387387
prepared_database: Database
388388
):
389389
client = prepared_database.with_authorization.client
@@ -393,7 +393,7 @@ async def test_throws_error_for_negative_upper_bound_id(
393393
'/',
394394
ReadEventsOptions(
395395
recursive=True,
396-
upper_bound_id='-1'
396+
upper_bound='-1'
397397
)
398398
):
399399
pass

0 commit comments

Comments
 (0)