File tree Expand file tree Collapse file tree 4 files changed +26
-4
lines changed
packages/notifications-library
src/notifications_library Expand file tree Collapse file tree 4 files changed +26
-4
lines changed Original file line number Diff line number Diff line change 55from jinja2 import Environment
66from jinja2 .exceptions import TemplateNotFound
77
8- from ._models import ProductData , UserData
8+ from ._models import ProductData , SharerData , UserData
99
1010_logger = logging .getLogger (__name__ )
1111
@@ -37,11 +37,12 @@ def render_email_parts(
3737 event_name : str ,
3838 * ,
3939 user : UserData ,
40+ sharer : SharerData ,
4041 product : ProductData ,
4142 ** other_data ,
4243) -> EmailPartsTuple :
4344
44- data = other_data | {"user" : user , "product" : product }
45+ data = other_data | {"user" : user , "sharer" : sharer , " product" : product }
4546
4647 # NOTE: assumes template convention!
4748 subject = env .get_template (f"{ event_name } .email.subject.txt" ).render (data )
Original file line number Diff line number Diff line change @@ -21,6 +21,12 @@ class UserData:
2121 email : str
2222
2323
24+ @dataclass (frozen = True )
25+ class SharerData :
26+ user_name : str
27+ message : str
28+
29+
2430@dataclass (frozen = True )
2531class ProductUIData :
2632 logo_url : str
Original file line number Diff line number Diff line change 1010import notifications_library
1111import pytest
1212from models_library .products import ProductName
13- from notifications_library ._models import ProductData , ProductUIData , UserData
13+ from notifications_library ._models import (
14+ ProductData ,
15+ ProductUIData ,
16+ SharerData ,
17+ UserData ,
18+ )
1419from notifications_library .payments import PaymentData
1520from pydantic import EmailStr
1621from pytest_simcore .helpers .typing_env import EnvVarsDict
@@ -85,6 +90,14 @@ def user_data(
8590 )
8691
8792
93+ @pytest .fixture
94+ def sharer_data (user_name : str , message : str ) -> SharerData :
95+ return SharerData (
96+ user_name = user_name ,
97+ message = message ,
98+ )
99+
100+
88101@pytest .fixture
89102def payment_data (successful_transaction : dict [str , Any ]) -> PaymentData :
90103 return PaymentData (
Original file line number Diff line number Diff line change 4141 get_user_address ,
4242 render_email_parts ,
4343)
44- from notifications_library ._models import ProductData , UserData
44+ from notifications_library ._models import ProductData , SharerData , UserData
4545from notifications_library ._render import (
4646 create_render_environment_from_notifications_library ,
4747)
@@ -186,6 +186,7 @@ async def test_email_event(
186186 smtp_mock_or_none : MagicMock | None ,
187187 user_data : UserData ,
188188 user_email : EmailStr ,
189+ sharer_data : SharerData ,
189190 product_data : ProductData ,
190191 product_name : ProductName ,
191192 event_name : str ,
@@ -202,6 +203,7 @@ async def test_email_event(
202203 ),
203204 event_name = event_name ,
204205 user = user_data ,
206+ sharer = sharer_data ,
205207 product = product_data ,
206208 # extras
207209 ** event_extra_data ,
You can’t perform that action at this time.
0 commit comments