Fixes #23 again, a broken test made it seem the issue was fixed before.

This commit is contained in:
boukeversteegh
2020-07-05 17:14:53 +02:00
parent dedead048f
commit 3f519d4fb1
6 changed files with 131 additions and 76 deletions

View File

@@ -0,0 +1,7 @@
syntax = "proto3";
package child;
message ChildRequestMessage {
int32 child_argument = 1;
}

View File

@@ -1,11 +1,14 @@
syntax = "proto3";
import "request_message.proto";
import "child_package_request_message.proto";
// Tests generated service correctly imports the RequestMessage
service Test {
rpc DoThing (RequestMessage) returns (RequestResponse);
rpc DoThing2 (child.ChildRequestMessage) returns (RequestResponse);
rpc DoThing3 (Nested.RequestMessage) returns (RequestResponse);
}
@@ -13,3 +16,8 @@ message RequestResponse {
int32 value = 1;
}
message Nested {
message RequestMessage {
int32 nestedArgument = 1;
}
}

View File

@@ -1,16 +0,0 @@
import pytest
from betterproto.tests.mocks import MockChannel
from betterproto.tests.output_betterproto.import_service_input_message import (
RequestResponse,
TestStub,
)
@pytest.mark.xfail(reason="#68 Request Input Messages are not imported for service")
@pytest.mark.asyncio
async def test_service_correctly_imports_reference_message():
mock_response = RequestResponse(value=10)
service = TestStub(MockChannel([mock_response]))
response = await service.do_thing()
assert mock_response == response

View File

@@ -0,0 +1,31 @@
import pytest
from betterproto.tests.mocks import MockChannel
from betterproto.tests.output_betterproto.import_service_input_message import (
RequestResponse,
TestStub,
)
@pytest.mark.asyncio
async def test_service_correctly_imports_reference_message():
mock_response = RequestResponse(value=10)
service = TestStub(MockChannel([mock_response]))
response = await service.do_thing(argument=1)
assert mock_response == response
@pytest.mark.asyncio
async def test_service_correctly_imports_reference_message_from_child_package():
mock_response = RequestResponse(value=10)
service = TestStub(MockChannel([mock_response]))
response = await service.do_thing2(child_argument=1)
assert mock_response == response
@pytest.mark.asyncio
async def test_service_correctly_imports_nested_reference():
mock_response = RequestResponse(value=10)
service = TestStub(MockChannel([mock_response]))
response = await service.do_thing3(nested_argument=1)
assert mock_response == response