Skip to content

Commit ff19d96

Browse files
committed
Test, add #99 #100 unitest
1 parent 488781f commit ff19d96

File tree

82 files changed

+670
-84
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+670
-84
lines changed

example/example_proto/demo/demo.proto

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,3 +171,17 @@ message DemoResp {
171171
message DemoState {
172172
int64 paramsDID = 4;
173173
}
174+
175+
// Test optional enum are not code gen
176+
// from:
177+
// - https://github.com/so1n/protobuf_to_pydantic/issues/101
178+
// - https://github.com/so1n/protobuf_to_pydantic/issues/99
179+
message WithOptionalEnumMsgEntry {
180+
optional OptionalEnum enum = 1;
181+
}
182+
183+
enum OptionalEnum {
184+
FOO = 0;
185+
BAR = 1;
186+
BAZ = 2;
187+
}

example/proto_3_20_pydanticv1/demo_gen_code.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This is an automatically generated file, please do not change
2-
# gen by protobuf_to_pydantic[v0.3.2.0](https://github.com/so1n/protobuf_to_pydantic)
2+
# gen by protobuf_to_pydantic[v0.3.3.0](https://github.com/so1n/protobuf_to_pydantic)
33
# Protobuf Version: 3.20.3
44
# Pydantic Version: 1.10.7
55
import typing
@@ -179,6 +179,19 @@ class Body(BaseModel):
179179
body: Body = Field(default_factory=Body)
180180

181181

182+
class OptionalEnum(IntEnum):
183+
FOO = 0
184+
BAR = 1
185+
BAZ = 2
186+
187+
188+
class WithOptionalEnumMsgEntry(BaseModel):
189+
class Config:
190+
validate_all = True
191+
192+
enum: typing.Optional[OptionalEnum] = Field(default=0)
193+
194+
182195
class Demo1(BaseModel):
183196
pass
184197

example/proto_3_20_pydanticv1/demo_gen_code_by_p2p.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This is an automatically generated file, please do not change
2-
# gen by protobuf_to_pydantic[v0.3.2.0](https://github.com/so1n/protobuf_to_pydantic)
2+
# gen by protobuf_to_pydantic[v0.3.3.0](https://github.com/so1n/protobuf_to_pydantic)
33
# Protobuf Version: 3.20.3
44
# Pydantic Version: 1.10.7
55
import typing

example/proto_3_20_pydanticv1/demo_gen_code_by_pgv.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This is an automatically generated file, please do not change
2-
# gen by protobuf_to_pydantic[v0.3.2.0](https://github.com/so1n/protobuf_to_pydantic)
2+
# gen by protobuf_to_pydantic[v0.3.3.0](https://github.com/so1n/protobuf_to_pydantic)
33
# Protobuf Version: 3.20.3
44
# Pydantic Version: 1.10.7
55
import typing

example/proto_3_20_pydanticv1/demo_gen_code_by_text_comment_protobuf_field.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This is an automatically generated file, please do not change
2-
# gen by protobuf_to_pydantic[v0.3.2.0](https://github.com/so1n/protobuf_to_pydantic)
2+
# gen by protobuf_to_pydantic[v0.3.3.0](https://github.com/so1n/protobuf_to_pydantic)
33
# Protobuf Version: 3.20.3
44
# Pydantic Version: 1.10.7
55
import typing
@@ -179,3 +179,16 @@ class Body(BaseModel):
179179
output_info: typing.Dict[str, str] = Field(default_factory=dict)
180180

181181
body: Body = Field(default_factory=Body)
182+
183+
184+
class OptionalEnum(IntEnum):
185+
FOO = 0
186+
BAR = 1
187+
BAZ = 2
188+
189+
190+
class WithOptionalEnumMsgEntry(BaseModel):
191+
class Config:
192+
validate_all = True
193+
194+
enum: typing.Optional[OptionalEnum] = Field(default=0)

example/proto_3_20_pydanticv1/demo_gen_code_by_text_comment_pyi.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This is an automatically generated file, please do not change
2-
# gen by protobuf_to_pydantic[v0.3.2.0](https://github.com/so1n/protobuf_to_pydantic)
2+
# gen by protobuf_to_pydantic[v0.3.3.0](https://github.com/so1n/protobuf_to_pydantic)
33
# Protobuf Version: 3.20.3
44
# Pydantic Version: 1.10.7
55
import typing
@@ -179,3 +179,16 @@ class Body(BaseModel):
179179
output_info: typing.Dict[str, str] = Field(default_factory=dict)
180180

181181
body: Body = Field(default_factory=Body)
182+
183+
184+
class OptionalEnum(IntEnum):
185+
FOO = 0
186+
BAR = 1
187+
BAZ = 2
188+
189+
190+
class WithOptionalEnumMsgEntry(BaseModel):
191+
class Config:
192+
validate_all = True
193+
194+
enum: typing.Optional[OptionalEnum] = Field(default=0)

example/proto_3_20_pydanticv1/example/example_proto/common/single_p2p.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This is an automatically generated file, please do not change
2-
# gen by protobuf_to_pydantic[v0.3.2.0](https://github.com/so1n/protobuf_to_pydantic)
2+
# gen by protobuf_to_pydantic[v0.3.3.0](https://github.com/so1n/protobuf_to_pydantic)
33
# Protobuf Version: 3.20.3
44
# Pydantic Version: 1.10.7
55
from enum import IntEnum

example/proto_3_20_pydanticv1/example/example_proto/demo/alias_demo_p2p.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This is an automatically generated file, please do not change
2-
# gen by protobuf_to_pydantic[v0.3.2.0](https://github.com/so1n/protobuf_to_pydantic)
2+
# gen by protobuf_to_pydantic[v0.3.3.0](https://github.com/so1n/protobuf_to_pydantic)
33
# Protobuf Version: 3.20.3
44
# Pydantic Version: 1.10.7
55
import typing

example/proto_3_20_pydanticv1/example/example_proto/demo/all_feidl_set_optional_demo_p2p.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This is an automatically generated file, please do not change
2-
# gen by protobuf_to_pydantic[v0.3.2.0](https://github.com/so1n/protobuf_to_pydantic)
2+
# gen by protobuf_to_pydantic[v0.3.3.0](https://github.com/so1n/protobuf_to_pydantic)
33
# Protobuf Version: 3.20.3
44
# Pydantic Version: 1.10.7
55
import typing

example/proto_3_20_pydanticv1/example/example_proto/demo/custom_comment_handler_p2p.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This is an automatically generated file, please do not change
2-
# gen by protobuf_to_pydantic[v0.3.2.0](https://github.com/so1n/protobuf_to_pydantic)
2+
# gen by protobuf_to_pydantic[v0.3.3.0](https://github.com/so1n/protobuf_to_pydantic)
33
# Protobuf Version: 3.20.3
44
# Pydantic Version: 1.10.7
55
from google.protobuf.message import Message # type: ignore

0 commit comments

Comments
 (0)