Skip to content

Commit 6eab36f

Browse files
authored
fix: Fix bug related to serialization of preconditions (#25)
1 parent 3ee5f45 commit 6eab36f

File tree

16 files changed

+264
-234
lines changed

16 files changed

+264
-234
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
- name: Create new version
4444
if: ${{ steps.get_next_version.outputs.hasNextVersion == 'true' }}
4545
run: |
46-
sed -i -r "s/(version = \")([0-9]+\.[0-9]+\.[0-9]+)(\")/\1{{ steps.get_next_version.outputs.version }}\3/" pyproject.toml
46+
sed -i -r "s/(version = \")([0-9]+\.[0-9]+\.[0-9]+)(\")/\1${{ steps.get_next_version.outputs.version }}\3/" pyproject.toml
4747
git config --global user.email "[email protected]"
4848
git config --global user.name "${{ github.actor }}"
4949
git add .

eventsourcingdb_client_python/client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from .http_client import HttpClient
1111
from .handlers.ping import ping
1212
from .handlers.read_events import read_events, ReadEventsOptions
13-
from .handlers.read_subjects import read_subjects, ReadSubjectsOptions
13+
from .handlers.read_subjects import read_subjects
1414
from .handlers.store_item import StoreItem
1515
from .handlers.write_events import Precondition, write_events
1616

@@ -40,9 +40,9 @@ def ping(self) -> None:
4040

4141
def read_subjects(
4242
self,
43-
options: ReadSubjectsOptions = ReadSubjectsOptions()
43+
base_subject: str
4444
) -> Generator[str, None, None]:
45-
return read_subjects(self, options)
45+
return read_subjects(self, base_subject)
4646

4747
def read_events(
4848
self,
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
from .read_subjects import read_subjects
2-
from .read_subjects_options import ReadSubjectsOptions

eventsourcingdb_client_python/handlers/read_subjects/read_subjects.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,23 @@
1313
from ..is_stream_error import is_stream_error
1414
from ..parse_raw_message import parse_raw_message
1515
from .is_subject import is_subject
16-
from .read_subjects_options import ReadSubjectsOptions
16+
from ...event.validate_subject import validate_subject
1717

1818

1919
def read_subjects(
2020
client: AbstractBaseClient,
21-
options: ReadSubjectsOptions
21+
base_subject: str
2222
) -> Generator[str, None, None]:
2323
try:
24-
options.validate()
24+
validate_subject(base_subject)
2525
except ValidationError as validation_error:
26-
raise InvalidParameterError('options', str(validation_error)) from validation_error
26+
raise InvalidParameterError('base_subject', str(validation_error)) from validation_error
2727
except Exception as other_error:
2828
raise InternalError(str(other_error)) from other_error
2929

30-
request_body = json.dumps(options.to_json())
30+
request_body = json.dumps({
31+
'baseSubject': base_subject
32+
})
3133

3234
response: requests.Response
3335
try:

eventsourcingdb_client_python/handlers/read_subjects/read_subjects_options.py

Lines changed: 0 additions & 20 deletions
This file was deleted.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
from .preconditions import Precondition
1+
from .preconditions import Precondition, \
2+
IsSubjectPristinePrecondition, \
3+
IsSubjectOnEventIdPrecondition
24
from .write_events import write_events

eventsourcingdb_client_python/handlers/write_events/preconditions.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ class IsSubjectPristinePrecondition(Precondition):
1414

1515
def to_json(self):
1616
return {
17-
'subject': self.subject
17+
'type': 'isSubjectPristine',
18+
'payload': {
19+
'subject': self.subject
20+
}
1821
}
1922

2023

@@ -25,6 +28,9 @@ class IsSubjectOnEventIdPrecondition(Precondition):
2528

2629
def to_json(self):
2730
return {
28-
'subject': self.subject,
29-
'eventId': self.event_id
31+
'type': 'isSubjectOnEventId',
32+
'payload': {
33+
'subject': self.subject,
34+
'eventId': self.event_id
35+
}
3036
}

poetry.lock

Lines changed: 86 additions & 118 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
[tool.poetry]
22
name = "eventsourcingdb-client-python"
3-
version = "{{ steps.get_next_version.outputs.version }}"
3+
version = "0.1.0"
44
description = "The Python client for the EventSourcingDB."
55
authors = [ "Alexander Kampf", "Golo Roden", "Noah Hummel" ]
66
readme = "README.md"
77
packages = [{include = "eventsourcingdb_client_python"}]
88

99
[tool.poetry.dependencies]
1010
python = "^3.10"
11-
requests = "2.28.2"
11+
requests = "2.31.0"
1212

1313

1414
[tool.poetry.group.dev.dependencies]

tests/shared/database.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,14 @@ def __init__(self):
1515
access_token = str(uuid.uuid4())
1616
with_authorization = ContainerizedTestingDatabase(
1717
image,
18-
['run', '--dev', '--ui', '--access-token', f'{access_token}'],
18+
['run', '--access-token', f'{access_token}', '--store-temporary'],
1919
ClientOptions(access_token=access_token)
2020
)
2121

22-
without_authorization = ContainerizedTestingDatabase(
23-
image,
24-
['run', '--dev', '--ui']
25-
)
26-
2722
with_invalid_url = TestingDatabase(Client('http://localhost.invalid'))
2823

2924
self.with_authorization: ContainerizedTestingDatabase = with_authorization
30-
self.without_authorization: ContainerizedTestingDatabase = without_authorization
3125
self.with_invalid_url: TestingDatabase = with_invalid_url
3226

3327
def stop(self):
3428
self.with_authorization.stop()
35-
self.without_authorization.stop()

0 commit comments

Comments
 (0)