Skip to content

Commit a914306

Browse files
committed
Put test into test_features, simplify to call parse directly
1 parent 67422db commit a914306

File tree

3 files changed

+16
-41
lines changed

3 files changed

+16
-41
lines changed
Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
syntax = "proto3";
22

3-
package repeated;
4-
53
message Test {
64
repeated string names = 1;
75
}
8-
9-
service ExampleService {
10-
rpc DoThing (Test) returns (Test);
11-
}

betterproto/tests/inputs/repeated/test_repeated.py

Lines changed: 0 additions & 34 deletions
This file was deleted.

betterproto/tests/test_features.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import betterproto
22
from dataclasses import dataclass
3-
from typing import Optional
3+
from typing import Optional, List, Dict
44

55

66
def test_has_field():
@@ -32,6 +32,21 @@ class Foo(betterproto.Message):
3232
foo.bar = Bar()
3333
assert betterproto.serialized_on_wire(foo.bar) == False
3434

35+
@dataclass
36+
class WithCollections(betterproto.Message):
37+
test_list: List[str] = betterproto.string_field(1)
38+
test_map: Dict[str, str] = betterproto.map_field(2, betterproto.TYPE_STRING, betterproto.TYPE_STRING)
39+
40+
# Unset with empty collections
41+
with_collections_empty = WithCollections().parse(bytes(WithCollections()))
42+
assert betterproto.serialized_on_wire(with_collections_empty) == False
43+
44+
# Set with non-empty collections
45+
with_collections_list = WithCollections().parse(bytes(WithCollections(test_list=['a', 'b', 'c'])))
46+
assert betterproto.serialized_on_wire(with_collections_list) == True
47+
with_collections_map = WithCollections().parse(bytes(WithCollections(test_map={'a': 'b', 'c': 'd'})))
48+
assert betterproto.serialized_on_wire(with_collections_map) == True
49+
3550

3651
def test_class_init():
3752
@dataclass

0 commit comments

Comments
 (0)