Support nested messages, fix casing. Support test-cases in packages.
This commit is contained in:
@@ -10,6 +10,7 @@ message Test {
|
||||
int32 camelCase = 1;
|
||||
my_enum snake_case = 2;
|
||||
snake_case_message snake_case_message = 3;
|
||||
int32 UPPERCASE = 4;
|
||||
}
|
||||
|
||||
message snake_case_message {
|
||||
|
||||
@@ -8,6 +8,7 @@ def test_message_attributes():
|
||||
message, "snake_case_message"
|
||||
), "snake_case field name is same in python"
|
||||
assert hasattr(message, "camel_case"), "CamelCase field is snake_case in python"
|
||||
assert hasattr(message, "uppercase"), "UPPERCASE field is lowercase in python"
|
||||
|
||||
|
||||
def test_message_casing():
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
# Test cases that are expected to fail, e.g. unimplemented features or bug-fixes.
|
||||
# Remove from list when fixed.
|
||||
tests = {
|
||||
"import_root_sibling", # 61
|
||||
"import_child_package_from_package", # 58
|
||||
"import_root_package_from_child", # 60
|
||||
"import_parent_package_from_child", # 59
|
||||
"import_circular_dependency", # failing because of other bugs now
|
||||
"import_packages_same_name", # 25
|
||||
"import_circular_dependency",
|
||||
"oneof_enum", # 63
|
||||
"casing_message_field_uppercase", # 11
|
||||
"namespace_keywords", # 70
|
||||
@@ -15,6 +10,16 @@ tests = {
|
||||
"googletypes_value", # 9
|
||||
}
|
||||
|
||||
|
||||
# Defines where the main package for this test resides.
|
||||
# Needed to test relative package imports.
|
||||
packages = {
|
||||
"import_root_package_from_child": ".child",
|
||||
"import_parent_package_from_child": ".parent.child",
|
||||
"repeatedmessage": ".repeatedmessage",
|
||||
"service": ".service",
|
||||
}
|
||||
|
||||
services = {
|
||||
"googletypes_response",
|
||||
"googletypes_response_embedded",
|
||||
|
||||
@@ -3,9 +3,9 @@ syntax = "proto3";
|
||||
import "root.proto";
|
||||
import "other.proto";
|
||||
|
||||
// This test-case verifies that future implementations will support circular dependencies in the generated python files.
|
||||
// This test-case verifies support for circular dependencies in the generated python files.
|
||||
//
|
||||
// This becomes important when generating 1 python file/module per package, rather than 1 file per proto file.
|
||||
// This is important because we generate 1 python file/module per package, rather than 1 file per proto file.
|
||||
//
|
||||
// Scenario:
|
||||
//
|
||||
@@ -24,5 +24,5 @@ import "other.proto";
|
||||
// (root: Test & RootPackageMessage) <-------> (other: OtherPackageMessage)
|
||||
message Test {
|
||||
RootPackageMessage message = 1;
|
||||
other.OtherPackageMessage other =2;
|
||||
other.OtherPackageMessage other = 2;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package child;
|
||||
|
||||
import "root.proto";
|
||||
|
||||
// Verify that we can import root message from child package
|
||||
|
||||
message Test {
|
||||
RootMessage message = 1;
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
syntax = "proto3";
|
||||
|
||||
import "root.proto";
|
||||
|
||||
package child;
|
||||
|
||||
// Tests generated imports when a message inside a child-package refers to a message defined in the root.
|
||||
|
||||
message Test {
|
||||
RootMessage message = 1;
|
||||
}
|
||||
@@ -10,7 +10,7 @@ message Test {
|
||||
|
||||
Nested nested = 1;
|
||||
Sibling sibling = 2;
|
||||
Sibling sibling2 = 3;
|
||||
// Sibling sibling2 = 3;
|
||||
}
|
||||
|
||||
message Sibling {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"root": {
|
||||
"top": {
|
||||
"name": "double-nested",
|
||||
"parent": {
|
||||
"child": [{"foo": "hello"}],
|
||||
"enumChild": ["A"],
|
||||
"rootParentChild": [{"a": "hello"}],
|
||||
"middle": {
|
||||
"bottom": [{"foo": "hello"}],
|
||||
"enumBottom": ["A"],
|
||||
"topMiddleBottom": [{"a": "hello"}],
|
||||
"bar": true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
syntax = "proto3";
|
||||
|
||||
message Test {
|
||||
message Root {
|
||||
message Parent {
|
||||
message RootParentChild {
|
||||
message Top {
|
||||
message Middle {
|
||||
message TopMiddleBottom {
|
||||
string a = 1;
|
||||
}
|
||||
enum EnumChild{
|
||||
enum EnumBottom{
|
||||
A = 0;
|
||||
B = 1;
|
||||
}
|
||||
message Child {
|
||||
message Bottom {
|
||||
string foo = 1;
|
||||
}
|
||||
reserved 1;
|
||||
repeated Child child = 2;
|
||||
repeated EnumChild enumChild=3;
|
||||
repeated RootParentChild rootParentChild=4;
|
||||
repeated Bottom bottom = 2;
|
||||
repeated EnumBottom enumBottom=3;
|
||||
repeated TopMiddleBottom topMiddleBottom=4;
|
||||
bool bar = 5;
|
||||
}
|
||||
string name = 1;
|
||||
Parent parent = 2;
|
||||
Middle middle = 2;
|
||||
}
|
||||
Root root = 1;
|
||||
Top top = 1;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package ref;
|
||||
|
||||
import "repeatedmessage.proto";
|
||||
|
||||
message Test {
|
||||
|
||||
Reference in New Issue
Block a user