-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
74 lines (59 loc) · 2.45 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import traceback
from typing import Callable
from strawberry.cli.utils import load_schema
from strawberry.printer import print_schema
def test_field_directive_schema_export():
schema_symbol = load_schema("field_directive:schema", ".")
output = print_schema(schema_symbol)
assert "testDirective" in output
def test_one_of_schema_export():
schema_symbol = load_schema("one_of_directive:schema", ".")
output = print_schema(schema_symbol)
assert "oneOf" in output
def test_field_directive_introspection():
from field_directive import schema
result = schema.introspect()
directives = { directive['name'] for directive in result['__schema']['directives'] }
assert "testDirective" in directives
def test_one_of_introspection():
from one_of_directive import schema
result = schema.introspect()
directives = { directive['name'] for directive in result['__schema']['directives'] }
assert "oneOf" in directives
def test_field_directive_schema_export_types():
schema_symbol = load_schema("field_directive_pass_types:schema", ".")
output = print_schema(schema_symbol)
assert "testDirective" in output
def test_one_of_schema_export_types():
schema_symbol = load_schema("one_of_directive_pass_types:schema", ".")
output = print_schema(schema_symbol)
assert "oneOf" in output
def test_field_directive_introspection_types():
from field_directive_pass_types import schema
result = schema.introspect()
directives = { directive['name'] for directive in result['__schema']['directives'] }
assert "testDirective" in directives
def test_one_of_introspection_types():
from one_of_directive_pass_types import schema
result = schema.introspect()
directives = { directive['name'] for directive in result['__schema']['directives'] }
assert "oneOf" in directives
def run_test(test: Callable):
print("\n" + test.__name__.replace('_', ' ') + ": ", end="")
try:
test()
print("PASS")
except:
print("FAIL")
traceback.print_exc()
def run_tests():
run_test(test_field_directive_schema_export)
run_test(test_one_of_schema_export)
run_test(test_field_directive_introspection)
run_test(test_one_of_introspection)
run_test(test_field_directive_schema_export_types)
run_test(test_one_of_schema_export_types)
run_test(test_field_directive_introspection_types)
run_test(test_one_of_introspection_types)
if __name__ == '__main__':
run_tests()