File tree Expand file tree Collapse file tree 2 files changed +36
-2
lines changed Expand file tree Collapse file tree 2 files changed +36
-2
lines changed Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ def __str__(cls):
4343 output = f"type { cls .__name__ } {{\n "
4444 for key , value in cls ._resolved_fields .items ():
4545 output += f" { key } : { value .__name__ } \n "
46- output += "}"
46+ output += "}\n "
4747 return output
4848
4949class QueryBuilder (metaclass = QueryBuilderMeta ):
Original file line number Diff line number Diff line change @@ -84,4 +84,38 @@ class InvalidType(gqlrequests.QueryBuilder):
8484
8585def test_invalid_type_throws_value_error ():
8686 with pytest .raises (ValueError ) as e :
87- InvalidType ().build ()
87+ InvalidType ().build ()
88+
89+
90+ def test_string_representation_of_class_shows_graphql_syntax ():
91+ class EveryType (gqlrequests .QueryBuilder ):
92+ id : int
93+ age : int
94+ money : float
95+ name : str
96+ company : bool
97+
98+ correct_string = """
99+ type EveryType {
100+ id: int
101+ age: int
102+ money: float
103+ name: str
104+ company: bool
105+ }
106+ """ [1 :]
107+ assert str (EveryType ) == correct_string
108+
109+ def test_string_representation_of_nested_class_shows_graphql_syntax ():
110+ correct_string = """
111+ type NestedType {
112+ something: SomethingType
113+ }
114+ """ [1 :]
115+ class SomethingType (gqlrequests .QueryBuilder ):
116+ id : int
117+
118+ class NestedType (gqlrequests .QueryBuilder ):
119+ something : SomethingType
120+
121+ assert str (NestedType ) == correct_string
You can’t perform that action at this time.
0 commit comments