• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

MrThearMan / undine / 19819090087

01 Dec 2025 09:23AM UTC coverage: 96.147% (+0.8%) from 95.382%
19819090087

push

github

matti-lamppu
Support one_of input objects from graphql-core 3.2.7

11 of 14 new or added lines in 3 files covered. (78.57%)

311 existing lines in 28 files now uncovered.

32636 of 33944 relevant lines covered (96.15%)

3.85 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

87.59
/tests/test_entrypoint/test_basic.py
1
from __future__ import annotations
4✔
2

3
from inspect import cleandoc
4✔
4

5
import pytest
4✔
6
from graphql import DirectiveLocation, GraphQLArgument, GraphQLInt, GraphQLNonNull, GraphQLString
4✔
7

8
from undine import Entrypoint, RootType
4✔
9
from undine.directives import Directive, DirectiveArgument
4✔
10
from undine.exceptions import DirectiveLocationError
4✔
11
from undine.resolvers import EntrypointFunctionResolver
4✔
12

13

14
def test_entrypoint__function() -> None:
4✔
15
    class Query(RootType):
4✔
16
        @Entrypoint
4✔
17
        def double(self, number: int) -> int:
4✔
18
            return number * 2
×
19

20
    assert repr(Query.double) == f"<undine.entrypoint.Entrypoint(ref={Query.double.ref})>"
4✔
21

22

23
def test_entrypoint__function__attributes() -> None:
4✔
24
    class Query(RootType):
4✔
25
        @Entrypoint
4✔
26
        def double(self, number: int) -> int:
4✔
27
            """Description."""
28
            return number * 2
×
29

30
    assert callable(Query.double.ref)
4✔
31
    assert Query.double.many is False
4✔
32
    assert Query.double.description == "Description."
4✔
33
    assert Query.double.deprecation_reason is None
4✔
34
    assert Query.double.complexity == 0
4✔
35
    assert Query.double.extensions == {"undine_entrypoint": Query.double}
4✔
36
    assert Query.double.root_type == Query
4✔
37
    assert Query.double.name == "double"
4✔
38

39

40
def test_entrypoint__function__get_field_type() -> None:
4✔
41
    class Query(RootType):
4✔
42
        @Entrypoint
4✔
43
        def double(self, number: int) -> int:
4✔
UNCOV
44
            return number * 2
×
45

46
    field_type = Query.double.get_field_type()
4✔
47
    assert field_type == GraphQLNonNull(GraphQLInt)
4✔
48

49

50
def test_entrypoint__function__get_field_arguments() -> None:
4✔
51
    class Query(RootType):
4✔
52
        @Entrypoint
4✔
53
        def double(self, number: int) -> int:
4✔
UNCOV
54
            return number * 2
×
55

56
    arguments = Query.double.get_field_arguments()
4✔
57
    assert arguments == {"number": GraphQLArgument(GraphQLNonNull(GraphQLInt), out_name="number")}
4✔
58

59

60
def test_entrypoint__function__get_resolver() -> None:
4✔
61
    class Query(RootType):
4✔
62
        @Entrypoint
4✔
63
        def double(self, number: int) -> int:
4✔
UNCOV
64
            return number * 2
×
65

66
    resolver = Query.double.get_resolver()
4✔
67
    assert isinstance(resolver, EntrypointFunctionResolver)
4✔
68

69

70
def test_entrypoint__function__as_graphql_field() -> None:
4✔
71
    class Query(RootType):
4✔
72
        @Entrypoint
4✔
73
        def double(self, number: int) -> int:
4✔
74
            """Description."""
UNCOV
75
            return number * 2
×
76

77
    graphql_field = Query.double.as_graphql_field()
4✔
78

79
    assert graphql_field.type == GraphQLNonNull(GraphQLInt)
4✔
80
    assert graphql_field.args == {"number": GraphQLArgument(GraphQLNonNull(GraphQLInt), out_name="number")}
4✔
81
    assert isinstance(graphql_field.resolve, EntrypointFunctionResolver)
4✔
82
    assert graphql_field.description == "Description."
4✔
83
    assert graphql_field.deprecation_reason is None
4✔
84
    assert graphql_field.extensions == {"undine_entrypoint": Query.double}
4✔
85

86

87
def test_entrypoint__function__decorator_arguments() -> None:
4✔
88
    class Query(RootType):
4✔
89
        @Entrypoint(deprecation_reason="Use something else.")
4✔
90
        def double(self, number: int) -> int:
4✔
UNCOV
91
            return number * 2
×
92

93
    assert Query.double.deprecation_reason == "Use something else."
4✔
94

95

96
def test_entrypoint__function__directives__root_type() -> None:
4✔
97
    class ValueDirective(Directive, locations=[DirectiveLocation.OBJECT], schema_name="value"):
4✔
98
        value = DirectiveArgument(GraphQLNonNull(GraphQLString))
4✔
99

100
    directives: list[Directive] = [ValueDirective(value="foo")]
4✔
101

102
    class Query(RootType, directives=directives):
4✔
103
        @Entrypoint
4✔
104
        def double(self, number: int) -> int:
4✔
UNCOV
105
            return number * 2
×
106

107
    assert Query.__directives__ == directives
4✔
108

109
    assert str(Query) == cleandoc(
4✔
110
        """
111
        type Query @value(value: "foo") {
112
          double(
113
            number: Int!
114
          ): Int!
115
        }
116
        """
117
    )
118

119

120
def test_entrypoint__function__directives__root_type__not_applicable() -> None:
4✔
121
    class ValueDirective(Directive, locations=[DirectiveLocation.ENUM_VALUE], schema_name="value"):
4✔
122
        value = DirectiveArgument(GraphQLNonNull(GraphQLString))
4✔
123

124
    with pytest.raises(DirectiveLocationError):
4✔
125

126
        class Query(RootType, directives=[ValueDirective(value="foo")]):
4✔
127
            @Entrypoint()
4✔
128
            def double(self, number: int) -> int:
4✔
UNCOV
129
                return number * 2
×
130

131

132
def test_entrypoint__function__directives__entrypoint() -> None:
4✔
133
    class ValueDirective(Directive, locations=[DirectiveLocation.FIELD_DEFINITION], schema_name="value"):
4✔
134
        value = DirectiveArgument(GraphQLNonNull(GraphQLString))
4✔
135

136
    directives: list[Directive] = [ValueDirective(value="foo")]
4✔
137

138
    class Query(RootType):
4✔
139
        @Entrypoint(directives=directives)
4✔
140
        def double(self, number: int) -> int:
4✔
UNCOV
141
            return number * 2
×
142

143
    assert Query.double.directives == directives
4✔
144

145
    assert str(Query) == cleandoc(
4✔
146
        """
147
        type Query {
148
          double(
149
            number: Int!
150
          ): Int! @value(value: "foo")
151
        }
152
        """
153
    )
154

155

156
def test_entrypoint__function__directives__entrypoint__not_applicable() -> None:
4✔
157
    class ValueDirective(Directive, locations=[DirectiveLocation.ENUM_VALUE], schema_name="value"):
4✔
158
        value = DirectiveArgument(GraphQLNonNull(GraphQLString))
4✔
159

160
    directives: list[Directive] = [ValueDirective(value="foo")]
4✔
161

162
    with pytest.raises(DirectiveLocationError):
4✔
163

164
        class Query(RootType):
4✔
165
            @Entrypoint(directives=directives)
4✔
166
            def double(self, number: int) -> int:
×
UNCOV
167
                return number * 2
×
168

169

170
def test_entrypoint__function__directives__decorator() -> None:
4✔
171
    class ValueDirective(Directive, locations=[DirectiveLocation.FIELD_DEFINITION], schema_name="value"):
4✔
172
        value = DirectiveArgument(GraphQLNonNull(GraphQLString))
4✔
173

174
    class Query(RootType):
4✔
175
        @ValueDirective(value="foo")
4✔
176
        @Entrypoint()
4✔
177
        def double(self, number: int) -> int:
4✔
UNCOV
178
            return number * 2
×
179

180
    assert Query.double.directives == [ValueDirective(value="foo")]
4✔
181

182
    assert str(Query) == cleandoc(
4✔
183
        """
184
        type Query {
185
          double(
186
            number: Int!
187
          ): Int! @value(value: "foo")
188
        }
189
        """
190
    )
191

192

193
def test_entrypoint__function__extensions__root_type() -> None:
4✔
194
    class Query(RootType, extensions={"foo": "bar"}):
4✔
195
        @Entrypoint
4✔
196
        def double(self, number: int) -> int:
4✔
UNCOV
197
            return number * 2
×
198

199
    assert Query.__extensions__ == {"foo": "bar", "undine_root_type": Query}
4✔
200

201

202
def test_entrypoint__function__extensions__entrypoint() -> None:
4✔
203
    class Query(RootType):
4✔
204
        @Entrypoint(extensions={"foo": "bar"})
4✔
205
        def double(self, number: int) -> int:
4✔
UNCOV
206
            return number * 2
×
207

208
    assert Query.double.extensions == {"foo": "bar", "undine_entrypoint": Query.double}
4✔
209

210

211
def test_entrypoint__function__str__root_type() -> None:
4✔
212
    class Query(RootType):
4✔
213
        @Entrypoint
4✔
214
        def double(self, number: int) -> int:
4✔
UNCOV
215
            return number * 2
×
216

217
    assert str(Query) == cleandoc(
4✔
218
        """
219
        type Query {
220
          double(
221
            number: Int!
222
          ): Int!
223
        }
224
        """
225
    )
226

227

228
def test_entrypoint__function__str__entrypoint() -> None:
4✔
229
    class Query(RootType):
4✔
230
        @Entrypoint
4✔
231
        def double(self, number: int) -> int:
4✔
UNCOV
232
            return number * 2
×
233

234
    assert str(Query.double) == cleandoc(
4✔
235
        """
236
        double(
237
          number: Int!
238
        ): Int!
239
        """
240
    )
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc