File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed
python-packages/smithy-core Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -177,6 +177,9 @@ def member(
177
177
:param target: The schema the member is targeting.
178
178
:param index: The member's index.
179
179
"""
180
+ id .expect_member ()
181
+ if target .member_target is not None :
182
+ raise ExpectationNotMetException ("Member targets must not be members." )
180
183
resolved_traits = target .traits .copy ()
181
184
if member_traits :
182
185
resolved_traits .update ({t .id : t for t in member_traits })
Original file line number Diff line number Diff line change @@ -104,3 +104,16 @@ def test_member_constructor():
104
104
)
105
105
106
106
assert actual == expected
107
+
108
+
109
+ def test_member_constructor_asserts_id ():
110
+ with pytest .raises (ExpectationNotMetException ):
111
+ Schema .member (id = ShapeID ("smithy.example#foo" ), target = STRING , index = 0 )
112
+
113
+
114
+ def test_member_constructor_asserts_target_is_not_member ():
115
+ target = Schema .member (
116
+ id = ShapeID ("smithy.example#Spam$eggs" ), target = STRING , index = 0
117
+ )
118
+ with pytest .raises (ExpectationNotMetException ):
119
+ Schema .member (id = ShapeID ("smithy.example#Foo$bar" ), target = target , index = 0 )
You can’t perform that action at this time.
0 commit comments