-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimize fetching handlers for events
The code to associate events to streams was incorrect because it was considering handler methods (in event handlers that could belong to a different aggregate) to associate streams with events. This commit fixes the bug and optimizes how handlers for a specific event are fetched.
- Loading branch information
Showing
9 changed files
with
67 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import pytest | ||
|
||
from protean import BaseEvent, BaseEventSourcedAggregate | ||
from protean.fields import String | ||
from protean.fields.basic import Identifier | ||
|
||
|
||
class User(BaseEventSourcedAggregate): | ||
id = Identifier(identifier=True) | ||
email = String() | ||
name = String() | ||
|
||
|
||
class UserLoggedIn(BaseEvent): | ||
user_id = Identifier(identifier=True) | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def register_elements(test_domain): | ||
test_domain.register(User) | ||
test_domain.register(UserLoggedIn, part_of="User") | ||
|
||
|
||
def test_event_does_not_have_stream_name_before_domain_init(): | ||
assert UserLoggedIn.meta_.stream_name is None | ||
|
||
|
||
def test_event_has_stream_name_after_domain_init(test_domain): | ||
test_domain.init(traverse=False) | ||
|
||
assert UserLoggedIn.meta_.stream_name == "user" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters