-
-
Notifications
You must be signed in to change notification settings - Fork 565
feat(interface): input type cannot inherit an interface type #1254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
import pytest | ||
|
||
import strawberry | ||
from strawberry.exceptions import InvalidSuperclassInterface | ||
|
||
|
||
def test_query_interface(): | ||
|
@@ -161,3 +162,27 @@ def anime(self) -> Anime: | |
|
||
assert not result.errors | ||
assert result.data == {"anime": {"name": "One Piece"}} | ||
|
||
|
||
def test_input_cannot_inherit_from_interface(): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can these tests cover the actual messages of the errors as well? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do yo know how to catch the exception message with pytest? Or I need to try, catch, save, raise, assert? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can use with pytest.raises(ExceptionType) as exc:
...
assert exc.value == "something" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, note that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let me have a look, thanks |
||
@strawberry.interface | ||
class SomeInterface: | ||
some_arg: str | ||
|
||
with pytest.raises(InvalidSuperclassInterface): | ||
|
||
@strawberry.input | ||
class SomeInput(SomeInterface): # this should throw an error | ||
another_arg: str | ||
|
||
@strawberry.interface | ||
class SomeOtherInterface: | ||
some_other_arg: str | ||
|
||
with pytest.raises(InvalidSuperclassInterface): | ||
|
||
@strawberry.input | ||
class SomeOtherInput( | ||
SomeInterface, SomeOtherInterface | ||
): # this should throw an error | ||
another_arg: str |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, now that I think about it, wouldn't it be better to take a
type
andList[type]
instead? Let the Exception handle everything related to output?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right