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

MrThearMan / undine / 17680768688

12 Sep 2025 04:49PM UTC coverage: 96.866% (-0.5%) from 97.325%
17680768688

push

github

MrThearMan
Update CI templates

1805 of 1907 branches covered (94.65%)

Branch coverage included in aggregate %.

29687 of 30604 relevant lines covered (97.0%)

2.91 hits per line

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

87.5
/tests/test_entrypoint/test_basic.py
1
from __future__ import annotations
3✔
2

3
from inspect import cleandoc
3✔
4

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

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

13

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

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

22

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

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

38

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

45
    field_type = Query.double.get_field_type()
3✔
46
    assert field_type == GraphQLNonNull(GraphQLInt)
3✔
47

48

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

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

58

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

65
    resolver = Query.double.get_resolver()
3✔
66
    assert isinstance(resolver, EntrypointFunctionResolver)
3✔
67

68

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

76
    graphql_field = Query.double.as_graphql_field()
3✔
77

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

85

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

92
    assert Query.double.deprecation_reason == "Use something else."
3✔
93

94

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

99
    directives: list[Directive] = [ValueDirective(value="foo")]
3✔
100

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

106
    assert Query.__directives__ == directives
3✔
107

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

118

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

123
    with pytest.raises(DirectiveLocationError):
3✔
124

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

130

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

135
    directives: list[Directive] = [ValueDirective(value="foo")]
3✔
136

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

142
    assert Query.double.directives == directives
3✔
143

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

154

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

159
    directives: list[Directive] = [ValueDirective(value="foo")]
3✔
160

161
    with pytest.raises(DirectiveLocationError):
3✔
162

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

168

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

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

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

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

191

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

198
    assert Query.__extensions__ == {"foo": "bar", "undine_root_type": Query}
3✔
199

200

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

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

209

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

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

226

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

233
    assert str(Query.double) == cleandoc(
3✔
234
        """
235
        double(
236
          number: Int!
237
        ): Int!
238
        """
239
    )
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