Organize test-cases into folders, extract compatibility test into proper test, support adding test-case specific tests
This commit is contained in:
3
betterproto/tests/inputs/bool/bool.json
Normal file
3
betterproto/tests/inputs/bool/bool.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"value": true
|
||||
}
|
||||
5
betterproto/tests/inputs/bool/bool.proto
Normal file
5
betterproto/tests/inputs/bool/bool.proto
Normal file
@@ -0,0 +1,5 @@
|
||||
syntax = "proto3";
|
||||
|
||||
message Test {
|
||||
bool value = 1;
|
||||
}
|
||||
8
betterproto/tests/inputs/bool/test.py
Normal file
8
betterproto/tests/inputs/bool/test.py
Normal file
@@ -0,0 +1,8 @@
|
||||
from betterproto.tests.output_betterproto.bool.bool import Test
|
||||
from betterproto.tests.util import read_relative
|
||||
|
||||
|
||||
def test_value():
|
||||
message = Test().from_json(read_relative(__file__, 'bool.json'))
|
||||
assert message.value
|
||||
|
||||
3
betterproto/tests/inputs/bytes/bytes.json
Normal file
3
betterproto/tests/inputs/bytes/bytes.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"data": "SGVsbG8sIFdvcmxkIQ=="
|
||||
}
|
||||
5
betterproto/tests/inputs/bytes/bytes.proto
Normal file
5
betterproto/tests/inputs/bytes/bytes.proto
Normal file
@@ -0,0 +1,5 @@
|
||||
syntax = "proto3";
|
||||
|
||||
message Test {
|
||||
bytes data = 1;
|
||||
}
|
||||
4
betterproto/tests/inputs/casing/casing.json
Normal file
4
betterproto/tests/inputs/casing/casing.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"camelCase": 1,
|
||||
"snakeCase": "ONE"
|
||||
}
|
||||
17
betterproto/tests/inputs/casing/casing.proto
Normal file
17
betterproto/tests/inputs/casing/casing.proto
Normal file
@@ -0,0 +1,17 @@
|
||||
syntax = "proto3";
|
||||
|
||||
enum my_enum {
|
||||
ZERO = 0;
|
||||
ONE = 1;
|
||||
TWO = 2;
|
||||
}
|
||||
|
||||
message Test {
|
||||
int32 camelCase = 1;
|
||||
my_enum snake_case = 2;
|
||||
snake_case_message snake_case_message = 3;
|
||||
}
|
||||
|
||||
message snake_case_message {
|
||||
|
||||
}
|
||||
3
betterproto/tests/inputs/double/double-negative.json
Normal file
3
betterproto/tests/inputs/double/double-negative.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"count": -123.45
|
||||
}
|
||||
3
betterproto/tests/inputs/double/double.json
Normal file
3
betterproto/tests/inputs/double/double.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"count": 123.45
|
||||
}
|
||||
5
betterproto/tests/inputs/double/double.proto
Normal file
5
betterproto/tests/inputs/double/double.proto
Normal file
@@ -0,0 +1,5 @@
|
||||
syntax = "proto3";
|
||||
|
||||
message Test {
|
||||
double count = 1;
|
||||
}
|
||||
3
betterproto/tests/inputs/enums/enums.json
Normal file
3
betterproto/tests/inputs/enums/enums.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"greeting": "HEY"
|
||||
}
|
||||
14
betterproto/tests/inputs/enums/enums.proto
Normal file
14
betterproto/tests/inputs/enums/enums.proto
Normal file
@@ -0,0 +1,14 @@
|
||||
syntax = "proto3";
|
||||
|
||||
// Enum for the different greeting types
|
||||
enum Greeting {
|
||||
HI = 0;
|
||||
HEY = 1;
|
||||
// Formal greeting
|
||||
HELLO = 2;
|
||||
}
|
||||
|
||||
message Test {
|
||||
// Greeting enum example
|
||||
Greeting greeting = 1;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{}
|
||||
5
betterproto/tests/inputs/googletypes/googletypes.json
Normal file
5
betterproto/tests/inputs/googletypes/googletypes.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"maybe": false,
|
||||
"ts": "1972-01-01T10:00:20.021Z",
|
||||
"duration": "1.200s"
|
||||
}
|
||||
12
betterproto/tests/inputs/googletypes/googletypes.proto
Normal file
12
betterproto/tests/inputs/googletypes/googletypes.proto
Normal file
@@ -0,0 +1,12 @@
|
||||
syntax = "proto3";
|
||||
|
||||
import "google/protobuf/duration.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
import "google/protobuf/wrappers.proto";
|
||||
|
||||
message Test {
|
||||
google.protobuf.BoolValue maybe = 1;
|
||||
google.protobuf.Timestamp ts = 2;
|
||||
google.protobuf.Duration duration = 3;
|
||||
google.protobuf.Int32Value important = 4;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
syntax = "proto3";
|
||||
|
||||
import "google/protobuf/wrappers.proto";
|
||||
|
||||
service Test {
|
||||
rpc GetInt32 (Input) returns (google.protobuf.Int32Value);
|
||||
rpc GetAnotherInt32 (Input) returns (google.protobuf.Int32Value);
|
||||
rpc GetInt64 (Input) returns (google.protobuf.Int64Value);
|
||||
rpc GetOutput (Input) returns (Output);
|
||||
}
|
||||
|
||||
message Input {
|
||||
|
||||
}
|
||||
|
||||
message Output {
|
||||
google.protobuf.Int64Value int64 = 1;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
from typing import Optional
|
||||
|
||||
import pytest
|
||||
|
||||
from betterproto.tests.output_betterproto.googletypes_response.googletypes_response import TestStub
|
||||
|
||||
|
||||
class TestStubChild(TestStub):
|
||||
async def _unary_unary(self, route, request, response_type, **kwargs):
|
||||
self.response_type = response_type
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test():
|
||||
pytest.skip('todo')
|
||||
stub = TestStubChild(None)
|
||||
await stub.get_int64()
|
||||
assert stub.response_type != Optional[int]
|
||||
3
betterproto/tests/inputs/int32/int32-negative.json
Normal file
3
betterproto/tests/inputs/int32/int32-negative.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"count": -150
|
||||
}
|
||||
3
betterproto/tests/inputs/int32/int32.json
Normal file
3
betterproto/tests/inputs/int32/int32.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"count": 150
|
||||
}
|
||||
7
betterproto/tests/inputs/int32/int32.proto
Normal file
7
betterproto/tests/inputs/int32/int32.proto
Normal file
@@ -0,0 +1,7 @@
|
||||
syntax = "proto3";
|
||||
|
||||
// Some documentation about the Test message.
|
||||
message Test {
|
||||
// Some documentation about the count.
|
||||
int32 count = 1;
|
||||
}
|
||||
5
betterproto/tests/inputs/keywords/keywords.json
Normal file
5
betterproto/tests/inputs/keywords/keywords.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"for": 1,
|
||||
"with": 2,
|
||||
"as": 3
|
||||
}
|
||||
7
betterproto/tests/inputs/keywords/keywords.proto
Normal file
7
betterproto/tests/inputs/keywords/keywords.proto
Normal file
@@ -0,0 +1,7 @@
|
||||
syntax = "proto3";
|
||||
|
||||
message Test {
|
||||
int32 for = 1;
|
||||
int32 with = 2;
|
||||
int32 as = 3;
|
||||
}
|
||||
7
betterproto/tests/inputs/map/map.json
Normal file
7
betterproto/tests/inputs/map/map.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"counts": {
|
||||
"item1": 1,
|
||||
"item2": 2,
|
||||
"item3": 3
|
||||
}
|
||||
}
|
||||
5
betterproto/tests/inputs/map/map.proto
Normal file
5
betterproto/tests/inputs/map/map.proto
Normal file
@@ -0,0 +1,5 @@
|
||||
syntax = "proto3";
|
||||
|
||||
message Test {
|
||||
map<string, int32> counts = 1;
|
||||
}
|
||||
10
betterproto/tests/inputs/mapmessage/mapmessage.json
Normal file
10
betterproto/tests/inputs/mapmessage/mapmessage.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"items": {
|
||||
"foo": {
|
||||
"count": 1
|
||||
},
|
||||
"bar": {
|
||||
"count": 2
|
||||
}
|
||||
}
|
||||
}
|
||||
9
betterproto/tests/inputs/mapmessage/mapmessage.proto
Normal file
9
betterproto/tests/inputs/mapmessage/mapmessage.proto
Normal file
@@ -0,0 +1,9 @@
|
||||
syntax = "proto3";
|
||||
|
||||
message Test {
|
||||
map<string, Nested> items = 1;
|
||||
}
|
||||
|
||||
message Nested {
|
||||
int32 count = 1;
|
||||
}
|
||||
6
betterproto/tests/inputs/nested/nested.json
Normal file
6
betterproto/tests/inputs/nested/nested.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"nested": {
|
||||
"count": 150
|
||||
},
|
||||
"sibling": {}
|
||||
}
|
||||
18
betterproto/tests/inputs/nested/nested.proto
Normal file
18
betterproto/tests/inputs/nested/nested.proto
Normal file
@@ -0,0 +1,18 @@
|
||||
syntax = "proto3";
|
||||
|
||||
// A test message with a nested message inside of it.
|
||||
message Test {
|
||||
// This is the nested type.
|
||||
message Nested {
|
||||
// Stores a simple counter.
|
||||
int32 count = 1;
|
||||
}
|
||||
|
||||
Nested nested = 1;
|
||||
Sibling sibling = 2;
|
||||
Sibling sibling2 = 3;
|
||||
}
|
||||
|
||||
message Sibling {
|
||||
int32 foo = 1;
|
||||
}
|
||||
11
betterproto/tests/inputs/nestedtwice/nestedtwice.json
Normal file
11
betterproto/tests/inputs/nestedtwice/nestedtwice.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"root": {
|
||||
"name": "double-nested",
|
||||
"parent": {
|
||||
"child": [{"foo": "hello"}],
|
||||
"enumChild": ["A"],
|
||||
"rootParentChild": [{"a": "hello"}],
|
||||
"bar": true
|
||||
}
|
||||
}
|
||||
}
|
||||
26
betterproto/tests/inputs/nestedtwice/nestedtwice.proto
Normal file
26
betterproto/tests/inputs/nestedtwice/nestedtwice.proto
Normal file
@@ -0,0 +1,26 @@
|
||||
syntax = "proto3";
|
||||
|
||||
message Test {
|
||||
message Root {
|
||||
message Parent {
|
||||
message RootParentChild {
|
||||
string a = 1;
|
||||
}
|
||||
enum EnumChild{
|
||||
A = 0;
|
||||
B = 1;
|
||||
}
|
||||
message Child {
|
||||
string foo = 1;
|
||||
}
|
||||
reserved 1;
|
||||
repeated Child child = 2;
|
||||
repeated EnumChild enumChild=3;
|
||||
repeated RootParentChild rootParentChild=4;
|
||||
bool bar = 5;
|
||||
}
|
||||
string name = 1;
|
||||
Parent parent = 2;
|
||||
}
|
||||
Root root = 1;
|
||||
}
|
||||
3
betterproto/tests/inputs/oneof/oneof-name.json
Normal file
3
betterproto/tests/inputs/oneof/oneof-name.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"name": "foo"
|
||||
}
|
||||
3
betterproto/tests/inputs/oneof/oneof.json
Normal file
3
betterproto/tests/inputs/oneof/oneof.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"count": 1
|
||||
}
|
||||
8
betterproto/tests/inputs/oneof/oneof.proto
Normal file
8
betterproto/tests/inputs/oneof/oneof.proto
Normal file
@@ -0,0 +1,8 @@
|
||||
syntax = "proto3";
|
||||
|
||||
message Test {
|
||||
oneof foo {
|
||||
int32 count = 1;
|
||||
string name = 2;
|
||||
}
|
||||
}
|
||||
5
betterproto/tests/inputs/ref/ref.json
Normal file
5
betterproto/tests/inputs/ref/ref.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"greeting": {
|
||||
"greeting": "hello"
|
||||
}
|
||||
}
|
||||
9
betterproto/tests/inputs/ref/ref.proto
Normal file
9
betterproto/tests/inputs/ref/ref.proto
Normal file
@@ -0,0 +1,9 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package ref;
|
||||
|
||||
import "repeatedmessage.proto";
|
||||
|
||||
message Test {
|
||||
repeatedmessage.Sub greeting = 1;
|
||||
}
|
||||
11
betterproto/tests/inputs/ref/repeatedmessage.proto
Normal file
11
betterproto/tests/inputs/ref/repeatedmessage.proto
Normal file
@@ -0,0 +1,11 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package repeatedmessage;
|
||||
|
||||
message Test {
|
||||
repeated Sub greetings = 1;
|
||||
}
|
||||
|
||||
message Sub {
|
||||
string greeting = 1;
|
||||
}
|
||||
3
betterproto/tests/inputs/repeated/repeated.json
Normal file
3
betterproto/tests/inputs/repeated/repeated.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"names": ["one", "two", "three"]
|
||||
}
|
||||
5
betterproto/tests/inputs/repeated/repeated.proto
Normal file
5
betterproto/tests/inputs/repeated/repeated.proto
Normal file
@@ -0,0 +1,5 @@
|
||||
syntax = "proto3";
|
||||
|
||||
message Test {
|
||||
repeated string names = 1;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"greetings": [
|
||||
{
|
||||
"greeting": "hello"
|
||||
},
|
||||
{
|
||||
"greeting": "hi"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package repeatedmessage;
|
||||
|
||||
message Test {
|
||||
repeated Sub greetings = 1;
|
||||
}
|
||||
|
||||
message Sub {
|
||||
string greeting = 1;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"counts": [1, 2, -1, -2],
|
||||
"signed": ["1", "2", "-1", "-2"],
|
||||
"fixed": [1.0, 2.7, 3.4]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
syntax = "proto3";
|
||||
|
||||
message Test {
|
||||
repeated int32 counts = 1;
|
||||
repeated sint64 signed = 2;
|
||||
repeated double fixed = 3;
|
||||
}
|
||||
15
betterproto/tests/inputs/service/service.proto
Normal file
15
betterproto/tests/inputs/service/service.proto
Normal file
@@ -0,0 +1,15 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package service;
|
||||
|
||||
message DoThingRequest {
|
||||
int32 iterations = 1;
|
||||
}
|
||||
|
||||
message DoThingResponse {
|
||||
int32 successfulIterations = 1;
|
||||
}
|
||||
|
||||
service ExampleService {
|
||||
rpc DoThing (DoThingRequest) returns (DoThingResponse);
|
||||
}
|
||||
4
betterproto/tests/inputs/signed/signed-negative.json
Normal file
4
betterproto/tests/inputs/signed/signed-negative.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"signed_32": -150,
|
||||
"signed_64": "-150"
|
||||
}
|
||||
4
betterproto/tests/inputs/signed/signed.json
Normal file
4
betterproto/tests/inputs/signed/signed.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"signed_32": 150,
|
||||
"signed_64": "150"
|
||||
}
|
||||
6
betterproto/tests/inputs/signed/signed.proto
Normal file
6
betterproto/tests/inputs/signed/signed.proto
Normal file
@@ -0,0 +1,6 @@
|
||||
syntax = "proto3";
|
||||
|
||||
message Test {
|
||||
sint32 signed_32 = 1;
|
||||
sint64 signed_64 = 2;
|
||||
}
|
||||
Reference in New Issue
Block a user