1from proto_schema_parser
import ast
2from proto_schema_parser
import parser
3from proto_structs.ast
import includes_collection
9@pytest.mark.parametrize(
10 (
'proto_path',
'expected_includes'),
20 'userver/proto-structs/io/userver/proto_structs/hash_map.hpp',
21 'userver/proto-structs/io/userver/proto_structs/hash_map_conv.hpp',
26 'box/autobox/unbreakable_cycle.proto',
28 id=
'unbreakable_cycle',
32def test_includes_are_correct(proto_path, expected_includes) -> None:
34 file_ast = parser.Parser().parse(proto_source)
36 includes = includes_collection.collect(file_ast=file_ast, plugin_options=
None, use_induced_deps=
False)
37 assert includes == expected_includes
39 includes_with_induced_deps = includes_collection.collect(file_ast=file_ast, plugin_options=
None)
40 assert includes_with_induced_deps == []
43@pytest.mark.parametrize(
44 (
'file_ast',
'expected_includes'),
50 ast.Package(name=
'google.protobuf'),
51 ast.Import(name=
'google/protobuf/any.proto'),
70 'userver/proto-structs/io/userver/proto_structs/any.hpp',
71 'userver/proto-structs/io/userver/proto_structs/any_conv.hpp',
77def test_deps_within_well_knowns(file_ast, expected_includes) -> None:
78 includes = includes_collection.collect(file_ast=file_ast, plugin_options=
None, use_induced_deps=
False)
79 assert includes == expected_includes
81 includes_with_induced_deps = includes_collection.collect(file_ast=file_ast, plugin_options=
None)
82 assert includes_with_induced_deps == []