Skip to content

Commit 9119a0c

Browse files
dependabot[bot]atstaeffgoloroden
authored
feat: Bump thenativeweb/eventsourcingdb from 0.103.1 to 0.113.2 in /tests/shared/docker/eventsourcingdb (#66)
* chore: Bump thenativeweb/eventsourcingdb Bumps thenativeweb/eventsourcingdb from 0.103.1 to 0.113.2. --- updated-dependencies: - dependency-name: thenativeweb/eventsourcingdb dependency-version: 0.113.2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * update ping route * fix event type newest eventsourcingdb version * fix: register event schema * fix: linting * modify poetry lock * fix linting, and pyproject.toml * fix: poetry lock * Delete .github/workflows/dependabot-poetry-lock.yml * Delete .github/workflows/update-poetry-lock.yml * modify makefile. for doing poetry lock auto * fix makefile for adding poetry lock as command. * fix: event schema cannot be string anymore * fix return type EventType * fix read event type * fix: dependabot * fix: event_type * fix: ping.py --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Stefan Poss <[email protected]> Co-authored-by: Golo Roden <[email protected]>
1 parent 4cff5dc commit 9119a0c

File tree

10 files changed

+43
-24
lines changed

10 files changed

+43
-24
lines changed

.github/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ updates:
2727
- package-ecosystem: "github-actions"
2828
directory: "/"
2929
schedule:
30-
interval: "weekly"
30+
interval: weekly
3131
open-pull-requests-limit: 10
3232
assignees:
3333
- thenativeweb/internal_dev

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@ analyze:
66
format:
77
@poetry run autopep8 --in-place --aggressive --max-line-length=100 --recursive eventsourcingdb tests
88

9+
lock:
10+
@poetry lock
11+
912
test:
1013
@poetry run pytest --maxfail=1
1114

1215
clean:
1316

1417
build: qa clean
1518

16-
.PHONY: analyze build clean format qa test
19+
.PHONY: analyze build clean format lock qa test

eventsourcingdb/handlers/ping.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# CloudEvent field names
1111
SPECVERSION_FIELD = "specversion"
1212
TYPE_FIELD = "type"
13-
PING_RECEIVED_TYPE = "io.eventsourcingdb.ping-received"
13+
PING_RECEIVED_TYPE = "io.eventsourcingdb.api.ping-received"
1414

1515

1616
async def ping(client: AbstractBaseClient) -> None:
@@ -34,8 +34,9 @@ async def ping(client: AbstractBaseClient) -> None:
3434
isinstance(response_json, dict)
3535
and SPECVERSION_FIELD in response_json
3636
and TYPE_FIELD in response_json
37+
and response_json.get(TYPE_FIELD) == PING_RECEIVED_TYPE
3738
):
38-
if response_json.get(TYPE_FIELD) == PING_RECEIVED_TYPE:
39-
return
39+
return
40+
4041

4142
raise ServerError(f"Received unexpected response: {response_body}")

eventsourcingdb/handlers/read_event_types/event_type.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from dataclasses import dataclass
2-
from typing import TypeVar
2+
from typing import TypeVar, Any
33

44
from ...errors.validation_error import ValidationError
55

@@ -10,10 +10,10 @@
1010
class EventType:
1111
event_type: str
1212
is_phantom: bool
13-
schema: str | None = None
13+
schema: dict[str, Any] | None = None
1414

1515
@staticmethod
16-
def parse(unknown_object: dict) -> Self:
16+
def parse(unknown_object: dict) -> "EventType":
1717
event_type = unknown_object.get('eventType')
1818
if not isinstance(event_type, str):
1919
raise ValidationError(
@@ -27,9 +27,9 @@ def parse(unknown_object: dict) -> Self:
2727
)
2828

2929
schema = unknown_object.get('schema')
30-
if schema is not None and not isinstance(schema, str):
30+
if schema is not None and not isinstance(schema, (dict)):
3131
raise ValidationError(
32-
f"Failed to parse schema '{schema}' to str."
32+
f"Failed to parse schema '{schema}'. Schema must be dict."
3333
)
3434

3535
return EventType(
@@ -39,4 +39,9 @@ def parse(unknown_object: dict) -> Self:
3939
)
4040

4141
def __hash__(self):
42+
# Convert dictionary schema to a hashable form (tuple of items)
43+
if isinstance(self.schema, dict):
44+
# Sort items to ensure consistent hashing
45+
schema_items = tuple(sorted((k, str(v)) for k, v in self.schema.items()))
46+
return hash((self.event_type, self.is_phantom, schema_items))
4247
return hash((self.event_type, self.is_phantom, self.schema))

eventsourcingdb/handlers/register_event_schema/register_event_schema.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import json
22
from http import HTTPStatus
3+
from typing import Any
34

45
from ...abstract_base_client import AbstractBaseClient
56
from ...errors.custom_error import CustomError
@@ -14,7 +15,7 @@
1415
async def register_event_schema(
1516
client: AbstractBaseClient,
1617
event_type: str,
17-
json_schema: str,
18+
json_schema: dict[str, Any],
1819
) -> None:
1920
try:
2021
validate_type(event_type)
@@ -27,7 +28,7 @@ async def register_event_schema(
2728

2829
request_body = json.dumps({
2930
'eventType': event_type,
30-
'schema': json_schema,
31+
'schema': json_schema,
3132
})
3233

3334
response: Response

poetry.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
FROM thenativeweb/eventsourcingdb:0.103.1
1+
FROM thenativeweb/eventsourcingdb:0.113.2

tests/test_read_event_types.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,14 @@ async def test_reads_all_types_of_existing_events_and_registered_schemas(
5050
),
5151
])
5252

53-
await client.register_event_schema("org.ban.ban", '{"type":"object"}')
54-
await client.register_event_schema("org.bing.chilling", '{"type":"object"}')
53+
await client.register_event_schema(
54+
"org.ban.ban",
55+
{"type": "object"} # type: ignore
56+
)
57+
await client.register_event_schema(
58+
"org.bing.chilling",
59+
{"type": "object"} # type: ignore
60+
)
5561

5662
actual_event_types: set[EventType] = set()
5763
async for event_type in client.read_event_types():
@@ -81,12 +87,12 @@ async def test_reads_all_types_of_existing_events_and_registered_schemas(
8187
EventType(
8288
event_type="org.ban.ban",
8389
is_phantom=True,
84-
schema='{"type":"object"}',
90+
schema={"type": "object"},
8591
),
8692
EventType(
8793
event_type="org.bing.chilling",
8894
is_phantom=True,
89-
schema='{"type":"object"}',
95+
schema={"type": "object"},
9096
),
9197
}
9298

tests/test_register_event_schema.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ async def test_registers_new_schema_if_it_doesnt_conflict_with_existing_events(
2525
):
2626
client = database.with_authorization.client
2727

28-
await client.register_event_schema("com.bar.baz", '{"type":"object"}')
28+
await client.register_event_schema(
29+
"com.bar.baz",
30+
{"type": "object"}
31+
)
2932

3033
@staticmethod
3134
@pytest.mark.asyncio
@@ -48,7 +51,7 @@ async def test_throws_error_if_schema_conflicts_with_existing_events(
4851
with pytest.raises(ClientError, match="additionalProperties"):
4952
await client.register_event_schema(
5053
"com.gornisht.ekht",
51-
'{"type":"object","additionalProperties":false}'
54+
{"type": "object", "additionalProperties": False}
5255
)
5356

5457
@staticmethod
@@ -60,13 +63,13 @@ async def test_throws_error_if_schema_already_exists(
6063

6164
await client.register_event_schema(
6265
"com.gornisht.ekht",
63-
'{"type":"object","additionalProperties":false}'
66+
{"type": "object", "additionalProperties": False}
6467
)
6568

6669
with pytest.raises(ClientError, match="schema already exists"):
6770
await client.register_event_schema(
6871
"com.gornisht.ekht",
69-
'{"type":"object","additionalProperties":false}'
72+
{"type": "object", "additionalProperties": False}
7073
)
7174

7275
@staticmethod
@@ -77,7 +80,7 @@ async def test_throws_error_if_schema_is_invalid(
7780
client = database.with_authorization.client
7881

7982
with pytest.raises(ClientError, match="'/type' does not validate"):
80-
await client.register_event_schema("com.gornisht.ekht", '{"type":"gurkenwasser"}')
83+
await client.register_event_schema("com.gornisht.ekht", {"type": "gurkenwasser"})
8184

8285

8386
class TestRegisterEventSchemaWithMockServer:

tests/test_write_events.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ async def test_throws_error_if_event_does_not_match_schema(
202202

203203
await client.register_event_schema(
204204
"com.super.duper",
205-
'{"type":"object","additionalProperties":false}'
205+
{"type": "object", "additionalProperties": False}
206206
)
207207

208208
with pytest.raises(ClientError, match="event candidate does not match schema"):

0 commit comments

Comments
 (0)